0001
0002
0003
0004
0005
0006 #include <linux/err.h>
0007 #include <linux/leds.h>
0008 #include <linux/platform_device.h>
0009 #include <linux/slab.h>
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 struct platform_device *__init gpio_led_register_device(
0024 int id, const struct gpio_led_platform_data *pdata)
0025 {
0026 struct platform_device *ret;
0027 struct gpio_led_platform_data _pdata = *pdata;
0028
0029 if (!pdata->num_leds)
0030 return ERR_PTR(-EINVAL);
0031
0032 _pdata.leds = kmemdup(pdata->leds,
0033 pdata->num_leds * sizeof(*pdata->leds), GFP_KERNEL);
0034 if (!_pdata.leds)
0035 return ERR_PTR(-ENOMEM);
0036
0037 ret = platform_device_register_resndata(NULL, "leds-gpio", id,
0038 NULL, 0, &_pdata, sizeof(_pdata));
0039 if (IS_ERR(ret))
0040 kfree(_pdata.leds);
0041
0042 return ret;
0043 }