[PATCH v2 1/2] ARM: mxc: Introduce imx_add_gpio_leds

Uwe Kleine-König u.kleine-koenig at pengutronix.de
Tue Apr 5 03:43:15 EDT 2011


On Tue, Apr 05, 2011 at 08:40:17AM +0100, Russell King - ARM Linux wrote:
> On Tue, Apr 05, 2011 at 09:30:30AM +0200, Uwe Kleine-König wrote:
> > I like my approach better, without using mxc specific functions it would
> > look as follows:
> > 
> > struct platform_device *__init gpio_led_register_device(
> > 		const gpio_led_platform_data *pdata)
> > {
> > 	struct platform_device *ret = ERR_PTR(-ENOMEM);
> > 	struct gpio_led_platform_data *_pdata = *pdata;
> > 	_pdata->leds = kmemdup(pdata->leds,
> > 			 pdata->num_leds * sizeof(*pdata->leds), GFP_KERNEL);
> > 
> > 	if (!_pdata->leds)
> > 		return ERR_PTR(-ENOMEM);
> > 
> > 	ret = platform_device_register_resndata(NULL, "leds-gpio", -1,
> > 		NULL, 0, _pdata, sizeof(_pdata));
> > 
> > 	if (IS_ERR(ret))
> > 		kfree(_pdata->leds);
> > 
> > 	return ret;
> > }
> 
> But this is inconsistent.  The gpio_led_platform_data isn't copied,
> but a sub-structure is - which makes this a candidate for people adding
> __initdata to the wrong thing.  Also marking the LEDs array as __initdata
> but leaving the gpio_led_platform_data without __initdata will lead to
> warnings.
platform_device_register_resndata does the copying.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |



More information about the linux-arm-kernel mailing list