diff options
-rw-r--r-- | drivers/Makefile | 2 | ||||
-rw-r--r-- | drivers/leds/Kconfig | 7 | ||||
-rw-r--r-- | drivers/leds/Makefile | 1 | ||||
-rw-r--r-- | drivers/leds/leds-gpio-register.c | 42 | ||||
-rw-r--r-- | include/linux/leds.h | 2 |
5 files changed, 53 insertions, 1 deletions
diff --git a/drivers/Makefile b/drivers/Makefile index 145aeadb6c03..bceb60c85c01 100644 --- a/drivers/Makefile +++ b/drivers/Makefile | |||
@@ -94,7 +94,7 @@ obj-$(CONFIG_CPU_IDLE) += cpuidle/ | |||
94 | obj-$(CONFIG_DMA_ENGINE) += dma/ | 94 | obj-$(CONFIG_DMA_ENGINE) += dma/ |
95 | obj-$(CONFIG_MMC) += mmc/ | 95 | obj-$(CONFIG_MMC) += mmc/ |
96 | obj-$(CONFIG_MEMSTICK) += memstick/ | 96 | obj-$(CONFIG_MEMSTICK) += memstick/ |
97 | obj-$(CONFIG_NEW_LEDS) += leds/ | 97 | obj-y += leds/ |
98 | obj-$(CONFIG_INFINIBAND) += infiniband/ | 98 | obj-$(CONFIG_INFINIBAND) += infiniband/ |
99 | obj-$(CONFIG_SGI_SN) += sn/ | 99 | obj-$(CONFIG_SGI_SN) += sn/ |
100 | obj-y += firmware/ | 100 | obj-y += firmware/ |
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index a4a77734ab6e..1d027b475b22 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig | |||
@@ -14,6 +14,13 @@ config LEDS_CLASS | |||
14 | This option enables the led sysfs class in /sys/class/leds. You'll | 14 | This option enables the led sysfs class in /sys/class/leds. You'll |
15 | need this to do anything useful with LEDs. If unsure, say N. | 15 | need this to do anything useful with LEDs. If unsure, say N. |
16 | 16 | ||
17 | config LEDS_GPIO_REGISTER | ||
18 | bool | ||
19 | help | ||
20 | This option provides the function gpio_led_register_device. | ||
21 | As this function is used by arch code it must not be compiled as a | ||
22 | module. | ||
23 | |||
17 | if NEW_LEDS | 24 | if NEW_LEDS |
18 | 25 | ||
19 | comment "LED drivers" | 26 | comment "LED drivers" |
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 0b6ad375bfdb..bccb96c9bb45 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile | |||
@@ -21,6 +21,7 @@ obj-$(CONFIG_LEDS_COBALT_QUBE) += leds-cobalt-qube.o | |||
21 | obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o | 21 | obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o |
22 | obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o | 22 | obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o |
23 | obj-$(CONFIG_LEDS_PCA9532) += leds-pca9532.o | 23 | obj-$(CONFIG_LEDS_PCA9532) += leds-pca9532.o |
24 | obj-$(CONFIG_LEDS_GPIO_REGISTER) += leds-gpio-register.o | ||
24 | obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o | 25 | obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o |
25 | obj-$(CONFIG_LEDS_LP3944) += leds-lp3944.o | 26 | obj-$(CONFIG_LEDS_LP3944) += leds-lp3944.o |
26 | obj-$(CONFIG_LEDS_LP5521) += leds-lp5521.o | 27 | obj-$(CONFIG_LEDS_LP5521) += leds-lp5521.o |
diff --git a/drivers/leds/leds-gpio-register.c b/drivers/leds/leds-gpio-register.c new file mode 100644 index 000000000000..1c4ed5510f35 --- /dev/null +++ b/drivers/leds/leds-gpio-register.c | |||
@@ -0,0 +1,42 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2011 Pengutronix | ||
3 | * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it under | ||
6 | * the terms of the GNU General Public License version 2 as published by the | ||
7 | * Free Software Foundation. | ||
8 | */ | ||
9 | #include <linux/err.h> | ||
10 | #include <linux/platform_device.h> | ||
11 | #include <linux/slab.h> | ||
12 | #include <linux/leds.h> | ||
13 | |||
14 | /** | ||
15 | * gpio_led_register_device - register a gpio-led device | ||
16 | * @pdata: the platform data used for the new device | ||
17 | * | ||
18 | * Makes a copy of pdata and pdata->leds and registers a new leds-gpio device | ||
19 | * with the result. This allows to have pdata and pdata-leds in .init.rodata | ||
20 | * and so saves some bytes compared to a static struct platform_device with | ||
21 | * static platform data. | ||
22 | * | ||
23 | * Returns the registered device or an error pointer. | ||
24 | */ | ||
25 | struct platform_device *__init gpio_led_register_device( | ||
26 | int id, const struct gpio_led_platform_data *pdata) | ||
27 | { | ||
28 | struct platform_device *ret; | ||
29 | struct gpio_led_platform_data _pdata = *pdata; | ||
30 | |||
31 | _pdata.leds = kmemdup(pdata->leds, | ||
32 | pdata->num_leds * sizeof(*pdata->leds), GFP_KERNEL); | ||
33 | if (!_pdata.leds) | ||
34 | return ERR_PTR(-ENOMEM); | ||
35 | |||
36 | ret = platform_device_register_resndata(NULL, "leds-gpio", id, | ||
37 | NULL, 0, &_pdata, sizeof(_pdata)); | ||
38 | if (IS_ERR(ret)) | ||
39 | kfree(_pdata.leds); | ||
40 | |||
41 | return ret; | ||
42 | } | ||
diff --git a/include/linux/leds.h b/include/linux/leds.h index 61e0340a4b77..5884def15a24 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h | |||
@@ -207,5 +207,7 @@ struct gpio_led_platform_data { | |||
207 | unsigned long *delay_off); | 207 | unsigned long *delay_off); |
208 | }; | 208 | }; |
209 | 209 | ||
210 | struct platform_device *gpio_led_register_device( | ||
211 | int id, const struct gpio_led_platform_data *pdata); | ||
210 | 212 | ||
211 | #endif /* __LINUX_LEDS_H_INCLUDED */ | 213 | #endif /* __LINUX_LEDS_H_INCLUDED */ |