The patch titled leds-provide-helper-to-register-leds-gpio-devices-v4 has been added to the -mm tree. Its filename is leds-provide-helper-to-register-leds-gpio-devices-v4.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: leds-provide-helper-to-register-leds-gpio-devices-v4 From: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx> - new commit log - improved documentation and moved it to .c file - used obj-$(CONFIG..) and renamed source file - provide an example usage (in a seperate patch) Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx> Cc: Fabio Estevam <fabio.estevam@xxxxxxxxxxxxx> Cc: H Hartley Sweeten <hartleys@xxxxxxxxxxxxxxxxxxx> Cc: Richard Purdie <richard.purdie@xxxxxxxxxxxxxxxxxxx> Cc: Russell King <rmk@xxxxxxxxxxxxxxxx> Cc: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/leds/Kconfig | 4 ++ drivers/leds/Makefile | 2 - drivers/leds/led-register.c | 33 ---------------------- drivers/leds/leds-gpio-register.c | 42 ++++++++++++++++++++++++++++ include/linux/leds.h | 10 ------ 5 files changed, 46 insertions(+), 45 deletions(-) diff -puN drivers/leds/Kconfig~leds-provide-helper-to-register-leds-gpio-devices-v4 drivers/leds/Kconfig --- a/drivers/leds/Kconfig~leds-provide-helper-to-register-leds-gpio-devices-v4 +++ a/drivers/leds/Kconfig @@ -14,10 +14,12 @@ config LEDS_CLASS This option enables the led sysfs class in /sys/class/leds. You'll need this to do anything useful with LEDs. If unsure, say N. -config LEDS_REGISTER_GPIO +config LEDS_GPIO_REGISTER bool help This option provides the function gpio_led_register_device. + As this function is used by arch code it must not be compiled as a + module. if NEW_LEDS diff -puN drivers/leds/Makefile~leds-provide-helper-to-register-leds-gpio-devices-v4 drivers/leds/Makefile --- a/drivers/leds/Makefile~leds-provide-helper-to-register-leds-gpio-devices-v4 +++ a/drivers/leds/Makefile @@ -3,7 +3,6 @@ obj-$(CONFIG_NEW_LEDS) += led-core.o obj-$(CONFIG_LEDS_CLASS) += led-class.o obj-$(CONFIG_LEDS_TRIGGERS) += led-triggers.o -obj-y += led-register.o # LED Platform Drivers obj-$(CONFIG_LEDS_88PM860X) += leds-88pm860x.o @@ -21,6 +20,7 @@ obj-$(CONFIG_LEDS_COBALT_QUBE) += leds- obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o obj-$(CONFIG_LEDS_PCA9532) += leds-pca9532.o +obj-$(CONFIG_LEDS_GPIO_REGISTER) += leds-gpio-register.o obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o obj-$(CONFIG_LEDS_LP3944) += leds-lp3944.o obj-$(CONFIG_LEDS_LP5521) += leds-lp5521.o diff -puN drivers/leds/led-register.c~leds-provide-helper-to-register-leds-gpio-devices-v4 /dev/null --- a/drivers/leds/led-register.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2011 Pengutronix - * Uwe Kleine-Koenig <u.kleine-koenig@xxxxxxxxxxxxxx> - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License version 2 as published by the - * Free Software Foundation. - */ -#include <linux/err.h> -#include <linux/platform_device.h> -#include <linux/slab.h> -#include <linux/leds.h> - -#if defined(CONFIG_LEDS_REGISTER_GPIO) -struct platform_device *__init gpio_led_register_device( - int id, const struct gpio_led_platform_data *pdata) -{ - struct platform_device *ret; - 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", id, - NULL, 0, &_pdata, sizeof(_pdata)); - if (IS_ERR(ret)) - kfree(_pdata.leds); - - return ret; -} -#endif diff -puN /dev/null drivers/leds/leds-gpio-register.c --- /dev/null +++ a/drivers/leds/leds-gpio-register.c @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2011 Pengutronix + * Uwe Kleine-Koenig <u.kleine-koenig@xxxxxxxxxxxxxx> + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License version 2 as published by the + * Free Software Foundation. + */ +#include <linux/err.h> +#include <linux/platform_device.h> +#include <linux/slab.h> +#include <linux/leds.h> + +/** + * gpio_led_register_device - register a gpio-led device + * @pdata: the platform data used for the new device + * + * Makes a copy of pdata and pdata->leds and registers a new leds-gpio device + * with the result. This allows to have pdata and pdata-leds in .init.rodata + * and so saves some bytes compared to a static struct platform_device with + * static platform data. + * + * Returns the registered device or an error pointer. + */ +struct platform_device *__init gpio_led_register_device( + int id, const struct gpio_led_platform_data *pdata) +{ + struct platform_device *ret; + 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", id, + NULL, 0, &_pdata, sizeof(_pdata)); + if (IS_ERR(ret)) + kfree(_pdata.leds); + + return ret; +} diff -puN include/linux/leds.h~leds-provide-helper-to-register-leds-gpio-devices-v4 include/linux/leds.h --- a/include/linux/leds.h~leds-provide-helper-to-register-leds-gpio-devices-v4 +++ a/include/linux/leds.h @@ -207,16 +207,6 @@ struct gpio_led_platform_data { unsigned long *delay_off); }; -/** - * gpio_led_register_device - register a gpio-led device - * @pdata: the platform data used for the new device - * - * Use this function instead of platform_device_add()ing a static struct - * platform_device. - * - * Note: as pdata and pdata->leds is copied these usually can and should be - * __initdata. - */ struct platform_device *gpio_led_register_device( int id, const struct gpio_led_platform_data *pdata); _ Patches currently in -mm which might be from u.kleine-koenig@xxxxxxxxxxxxxx are linux-next.patch leds-provide-helper-to-register-leds-gpio-devices.patch leds-provide-helper-to-register-leds-gpio-devices-v4.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html