Root/
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 | } |
43 |
Branches:
ben-wpan
ben-wpan-stefan
javiroman/ks7010
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9