Re: [PATCH 2/2 v2] Driver core: reduce duplicated code

From: Eric Miao
Date: Mon Jun 28 2010 - 00:56:26 EST


2010/6/22 Uwe Kleine-KÃnig <u.kleine-koenig@xxxxxxxxxxxxxx>:
> Hi Greg,
>
>> > I changed the semantic slightly to only call
>> > platform_device_add_resources if data != NULL instead of size != 0. ÂThe
>> > idea is to support wrappers like:
>> >
>> > Â Â #define add_blablub(id, pdata) \
>> > Â Â Â Â Â Â platform_device_register_resndata(NULL, "blablub", id, \
>> > Â Â Â Â Â Â Â Â Â Â NULL, 0, pdata, sizeof(struct blablub_platform_data))
>> >
>> > that don't fail if pdata=NULL. ÂDitto for res.
>>
>> That's fine, but why would you want to have a #define for something like
>> this? ÂIs it really needed?
> Well, what is really needed? ÂI intend to use it on arm/imx. ÂI have
> several different machines using similar SoCs and so I want to have a
> function à la:
>
> Â Â Â Âstruct platform_device *__init imx_add_imx_i2c(int id,
> Â Â Â Â Â Â Â Âresource_size_t iobase, resource_size_t iosize, int irq,
> Â Â Â Â Â Â Â Âconst struct imxi2c_platform_data *pdata)
>
> that builds a struct resource[] and then calls
> platform_device_register_resndata(). ÂAnd then I have a set of macros
> like:
>
> Â Â Â Â#define imx21_add_i2c_imx(pdata) Â Â Â Â\
> Â Â Â Â Â Â Â Âimx_add_imx_i2c(0, MX2x_I2C_BASE_ADDR, SZ_4K, MX2x_INT_I2C, pdata)
> Â Â Â Â#define imx25_add_imx_i2c0(pdata) Â Â Â \
> Â Â Â Â Â Â Â Âimx_add_imx_i2c(0, MX25_I2C1_BASE_ADDR, SZ_16K, MX25_INT_I2C1, pdata)
> Â Â Â Â##define imx25_add_imx_i2c1(pdata) Â Â Â\
> Â Â Â Â Â Â Â Âimx_add_imx_i2c(1, MX25_I2C2_BASE_ADDR, SZ_16K, MX25_INT_I2C2, pdata)
>
> etc. ÂThe final goal is to get rid of files like
> arch/arm/mach-mx3/devices.c.
>

Hi Uwe,

I suggest you to have a look into arch/arm/mach-mmp/devices.c and
arch/arm/mach-mmp/pxa{168,910}.c as well as
arch/arm/mach-mmp/include/mach/pxa{168,910}.h, maybe we can find
some common practice.

>> Anyway, this version looks fine to me, I'll go apply it.
> \o/
>
> Best regards and thanks
> Uwe
>
> --
> Pengutronix e.K.              | Uwe Kleine-KÃnig      Â|
> Industrial Linux Solutions         | http://www.pengutronix.de/ Â|
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/