diff options
Diffstat (limited to 'drivers/leds')
28 files changed, 77 insertions, 102 deletions
diff --git a/drivers/leds/leds-88pm860x.c b/drivers/leds/leds-88pm860x.c index c2def5551ce1..1497a09166d6 100644 --- a/drivers/leds/leds-88pm860x.c +++ b/drivers/leds/leds-88pm860x.c @@ -237,7 +237,6 @@ static int pm860x_led_remove(struct platform_device *pdev) static struct platform_driver pm860x_led_driver = { .driver = { .name = "88pm860x-led", - .owner = THIS_MODULE, }, .probe = pm860x_led_probe, .remove = pm860x_led_remove, diff --git a/drivers/leds/leds-adp5520.c b/drivers/leds/leds-adp5520.c index 5036d7b4f82e..07e66cae32d3 100644 --- a/drivers/leds/leds-adp5520.c +++ b/drivers/leds/leds-adp5520.c @@ -201,7 +201,6 @@ static int adp5520_led_remove(struct platform_device *pdev) static struct platform_driver adp5520_led_driver = { .driver = { .name = "adp5520-led", - .owner = THIS_MODULE, }, .probe = adp5520_led_probe, .remove = adp5520_led_remove, diff --git a/drivers/leds/leds-asic3.c b/drivers/leds/leds-asic3.c index 70c74a7f0dfe..1b71eac639f0 100644 --- a/drivers/leds/leds-asic3.c +++ b/drivers/leds/leds-asic3.c @@ -168,7 +168,6 @@ static struct platform_driver asic3_led_driver = { .remove = asic3_led_remove, .driver = { .name = "leds-asic3", - .owner = THIS_MODULE, .pm = &asic3_led_pm_ops, }, }; diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c index f58a354428e3..0f9ed1ea0e89 100644 --- a/drivers/leds/leds-clevo-mail.c +++ b/drivers/leds/leds-clevo-mail.c @@ -168,7 +168,6 @@ static struct platform_driver clevo_mail_led_driver = { .remove = clevo_mail_led_remove, .driver = { .name = KBUILD_MODNAME, - .owner = THIS_MODULE, }, }; diff --git a/drivers/leds/leds-cobalt-qube.c b/drivers/leds/leds-cobalt-qube.c index 910339d86edf..d97522080491 100644 --- a/drivers/leds/leds-cobalt-qube.c +++ b/drivers/leds/leds-cobalt-qube.c @@ -76,7 +76,6 @@ static struct platform_driver cobalt_qube_led_driver = { .remove = cobalt_qube_led_remove, .driver = { .name = "cobalt-qube-leds", - .owner = THIS_MODULE, }, }; diff --git a/drivers/leds/leds-cobalt-raq.c b/drivers/leds/leds-cobalt-raq.c index 001088b31373..06dbe18a2065 100644 --- a/drivers/leds/leds-cobalt-raq.c +++ b/drivers/leds/leds-cobalt-raq.c @@ -124,7 +124,6 @@ static struct platform_driver cobalt_raq_led_driver = { .remove = cobalt_raq_led_remove, .driver = { .name = "cobalt-raq-leds", - .owner = THIS_MODULE, }, }; diff --git a/drivers/leds/leds-da903x.c b/drivers/leds/leds-da903x.c index 54b8b5216b8b..952ba96e5b38 100644 --- a/drivers/leds/leds-da903x.c +++ b/drivers/leds/leds-da903x.c @@ -144,7 +144,6 @@ static int da903x_led_remove(struct platform_device *pdev) static struct platform_driver da903x_led_driver = { .driver = { .name = "da903x-led", - .owner = THIS_MODULE, }, .probe = da903x_led_probe, .remove = da903x_led_remove, diff --git a/drivers/leds/leds-da9052.c b/drivers/leds/leds-da9052.c index e4da1f460ac5..28291b6acc8e 100644 --- a/drivers/leds/leds-da9052.c +++ b/drivers/leds/leds-da9052.c @@ -199,7 +199,6 @@ static int da9052_led_remove(struct platform_device *pdev) static struct platform_driver da9052_led_driver = { .driver = { .name = "da9052-leds", - .owner = THIS_MODULE, }, .probe = da9052_led_probe, .remove = da9052_led_remove, diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index b4518c8751c8..8a8ba11c5c14 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -12,25 +12,23 @@ */ #include <linux/err.h> #include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/kernel.h> #include <linux/leds.h> #include <linux/module.h> -#include <linux/of.h> -#include <linux/of_gpio.h> -#include <linux/of_platform.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/slab.h> #include <linux/workqueue.h> struct gpio_led_data { struct led_classdev cdev; - unsigned gpio; + struct gpio_desc *gpiod; struct work_struct work; u8 new_level; u8 can_sleep; - u8 active_low; u8 blinking; - int (*platform_gpio_blink_set)(unsigned gpio, int state, + int (*platform_gpio_blink_set)(struct gpio_desc *desc, int state, unsigned long *delay_on, unsigned long *delay_off); }; @@ -40,12 +38,11 @@ static void gpio_led_work(struct work_struct *work) container_of(work, struct gpio_led_data, work); if (led_dat->blinking) { - led_dat->platform_gpio_blink_set(led_dat->gpio, - led_dat->new_level, - NULL, NULL); + led_dat->platform_gpio_blink_set(led_dat->gpiod, + led_dat->new_level, NULL, NULL); led_dat->blinking = 0; } else - gpio_set_value_cansleep(led_dat->gpio, led_dat->new_level); + gpiod_set_value_cansleep(led_dat->gpiod, led_dat->new_level); } static void gpio_led_set(struct led_classdev *led_cdev, @@ -60,9 +57,6 @@ static void gpio_led_set(struct led_classdev *led_cdev, else level = 1; - if (led_dat->active_low) - level = !level; - /* Setting GPIOs with I2C/etc requires a task context, and we don't * seem to have a reliable way to know if we're already in one; so * let's just assume the worst. @@ -72,11 +66,11 @@ static void gpio_led_set(struct led_classdev *led_cdev, schedule_work(&led_dat->work); } else { if (led_dat->blinking) { - led_dat->platform_gpio_blink_set(led_dat->gpio, level, + led_dat->platform_gpio_blink_set(led_dat->gpiod, level, NULL, NULL); led_dat->blinking = 0; } else - gpio_set_value(led_dat->gpio, level); + gpiod_set_value(led_dat->gpiod, level); } } @@ -87,34 +81,49 @@ static int gpio_blink_set(struct led_classdev *led_cdev, container_of(led_cdev, struct gpio_led_data, cdev); led_dat->blinking = 1; - return led_dat->platform_gpio_blink_set(led_dat->gpio, GPIO_LED_BLINK, + return led_dat->platform_gpio_blink_set(led_dat->gpiod, GPIO_LED_BLINK, delay_on, delay_off); } static int create_gpio_led(const struct gpio_led *template, struct gpio_led_data *led_dat, struct device *parent, - int (*blink_set)(unsigned, int, unsigned long *, unsigned long *)) + int (*blink_set)(struct gpio_desc *, int, unsigned long *, + unsigned long *)) { int ret, state; - led_dat->gpio = -1; + led_dat->gpiod = template->gpiod; + if (!led_dat->gpiod) { + /* + * This is the legacy code path for platform code that + * still uses GPIO numbers. Ultimately we would like to get + * rid of this block completely. + */ + unsigned long flags = 0; + + /* skip leds that aren't available */ + if (!gpio_is_valid(template->gpio)) { + dev_info(parent, "Skipping unavailable LED gpio %d (%s)\n", + template->gpio, template->name); + return 0; + } - /* skip leds that aren't available */ - if (!gpio_is_valid(template->gpio)) { - dev_info(parent, "Skipping unavailable LED gpio %d (%s)\n", - template->gpio, template->name); - return 0; - } + if (template->active_low) + flags |= GPIOF_ACTIVE_LOW; - ret = devm_gpio_request(parent, template->gpio, template->name); - if (ret < 0) - return ret; + ret = devm_gpio_request_one(parent, template->gpio, flags, + template->name); + if (ret < 0) + return ret; + + led_dat->gpiod = gpio_to_desc(template->gpio); + if (IS_ERR(led_dat->gpiod)) + return PTR_ERR(led_dat->gpiod); + } led_dat->cdev.name = template->name; led_dat->cdev.default_trigger = template->default_trigger; - led_dat->gpio = template->gpio; - led_dat->can_sleep = gpio_cansleep(template->gpio); - led_dat->active_low = template->active_low; + led_dat->can_sleep = gpiod_cansleep(led_dat->gpiod); led_dat->blinking = 0; if (blink_set) { led_dat->platform_gpio_blink_set = blink_set; @@ -122,30 +131,24 @@ static int create_gpio_led(const struct gpio_led *template, } led_dat->cdev.brightness_set = gpio_led_set; if (template->default_state == LEDS_GPIO_DEFSTATE_KEEP) - state = !!gpio_get_value_cansleep(led_dat->gpio) ^ led_dat->active_low; + state = !!gpiod_get_value_cansleep(led_dat->gpiod); else state = (template->default_state == LEDS_GPIO_DEFSTATE_ON); led_dat->cdev.brightness = state ? LED_FULL : LED_OFF; if (!template->retain_state_suspended) led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; - ret = gpio_direction_output(led_dat->gpio, led_dat->active_low ^ state); + ret = gpiod_direction_output(led_dat->gpiod, state); if (ret < 0) return ret; INIT_WORK(&led_dat->work, gpio_led_work); - ret = led_classdev_register(parent, &led_dat->cdev); - if (ret < 0) - return ret; - - return 0; + return led_classdev_register(parent, &led_dat->cdev); } static void delete_gpio_led(struct gpio_led_data *led) { - if (!gpio_is_valid(led->gpio)) - return; led_classdev_unregister(&led->cdev); cancel_work_sync(&led->work); } @@ -161,40 +164,47 @@ static inline int sizeof_gpio_leds_priv(int num_leds) (sizeof(struct gpio_led_data) * num_leds); } -/* Code to create from OpenFirmware platform devices */ -#ifdef CONFIG_OF_GPIO -static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev) +static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev) { - struct device_node *np = pdev->dev.of_node, *child; + struct device *dev = &pdev->dev; + struct fwnode_handle *child; struct gpio_leds_priv *priv; int count, ret; + struct device_node *np; - /* count LEDs in this device, so we know how much to allocate */ - count = of_get_available_child_count(np); + count = device_get_child_node_count(dev); if (!count) return ERR_PTR(-ENODEV); - for_each_available_child_of_node(np, child) - if (of_get_gpio(child, 0) == -EPROBE_DEFER) - return ERR_PTR(-EPROBE_DEFER); - - priv = devm_kzalloc(&pdev->dev, sizeof_gpio_leds_priv(count), - GFP_KERNEL); + priv = devm_kzalloc(dev, sizeof_gpio_leds_priv(count), GFP_KERNEL); if (!priv) return ERR_PTR(-ENOMEM); - for_each_available_child_of_node(np, child) { + device_for_each_child_node(dev, child) { struct gpio_led led = {}; - enum of_gpio_flags flags; - const char *state; - - led.gpio = of_get_gpio_flags(child, 0, &flags); - led.active_low = flags & OF_GPIO_ACTIVE_LOW; - led.name = of_get_property(child, "label", NULL) ? : child->name; - led.default_trigger = - of_get_property(child, "linux,default-trigger", NULL); - state = of_get_property(child, "default-state", NULL); - if (state) { + const char *state = NULL; + + led.gpiod = devm_get_gpiod_from_child(dev, child); + if (IS_ERR(led.gpiod)) { + fwnode_handle_put(child); + goto err; + } + + np = of_node(child); + + if (fwnode_property_present(child, "label")) { + fwnode_property_read_string(child, "label", &led.name); + } else { + if (IS_ENABLED(CONFIG_OF) && !led.name && np) + led.name = np->name; + if (!led.name) + return ERR_PTR(-EINVAL); + } + fwnode_property_read_string(child, "linux,default-trigger", + &led.default_trigger); + + if (!fwnode_property_read_string(child, "linux,default_state", + &state)) { if (!strcmp(state, "keep")) led.default_state = LEDS_GPIO_DEFSTATE_KEEP; else if (!strcmp(state, "on")) @@ -203,13 +213,13 @@ static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev) led.default_state = LEDS_GPIO_DEFSTATE_OFF; } - if (of_get_property(child, "retain-state-suspended", NULL)) + if (fwnode_property_present(child, "retain-state-suspended")) led.retain_state_suspended = 1; ret = create_gpio_led(&led, &priv->leds[priv->num_leds++], - &pdev->dev, NULL); + dev, NULL); if (ret < 0) { - of_node_put(child); + fwnode_handle_put(child); goto err; } } @@ -228,12 +238,6 @@ static const struct of_device_id of_gpio_leds_match[] = { }; MODULE_DEVICE_TABLE(of, of_gpio_leds_match); -#else /* CONFIG_OF_GPIO */ -static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev) -{ - return ERR_PTR(-ENODEV); -} -#endif /* CONFIG_OF_GPIO */ static int gpio_led_probe(struct platform_device *pdev) { @@ -261,7 +265,7 @@ static int gpio_led_probe(struct platform_device *pdev) } } } else { - priv = gpio_leds_create_of(pdev); + priv = gpio_leds_create(pdev); if (IS_ERR(priv)) return PTR_ERR(priv); } @@ -287,8 +291,7 @@ static struct platform_driver gpio_led_driver = { .remove = gpio_led_remove, .driver = { .name = "leds-gpio", - .owner = THIS_MODULE, - .of_match_table = of_match_ptr(of_gpio_leds_match), + .of_match_table = of_gpio_leds_match, }, }; diff --git a/drivers/leds/leds-hp6xx.c b/drivers/leds/leds-hp6xx.c index d61a98896c71..0b84c0113126 100644 --- a/drivers/leds/leds-hp6xx.c +++ b/drivers/leds/leds-hp6xx.c @@ -83,7 +83,6 @@ static struct platform_driver hp6xxled_driver = { .remove = hp6xxled_remove, .driver = { .name = "hp6xx-led", - .owner = THIS_MODULE, }, }; diff --git a/drivers/leds/leds-lm3533.c b/drivers/leds/leds-lm3533.c index cbf61a40137d..6e2e02035dd7 100644 --- a/drivers/leds/leds-lm3533.c +++ b/drivers/leds/leds-lm3533.c @@ -766,7 +766,6 @@ static void lm3533_led_shutdown(struct platform_device *pdev) static struct platform_driver lm3533_led_driver = { .driver = { .name = "lm3533-leds", - .owner = THIS_MODULE, }, .probe = lm3533_led_probe, .remove = lm3533_led_remove, diff --git a/drivers/leds/leds-lp8788.c b/drivers/leds/leds-lp8788.c index 7c2cb384e7ae..3409f03c1fa8 100644 --- a/drivers/leds/leds-lp8788.c +++ b/drivers/leds/leds-lp8788.c @@ -183,7 +183,6 @@ static struct platform_driver lp8788_led_driver = { .remove = lp8788_led_remove, .driver = { .name = LP8788_DEV_KEYLED, - .owner = THIS_MODULE, }, }; module_platform_driver(lp8788_led_driver); diff --git a/drivers/leds/leds-lt3593.c b/drivers/leds/leds-lt3593.c index 059f5b1f3553..9f41124765cc 100644 --- a/drivers/leds/leds-lt3593.c +++ b/drivers/leds/leds-lt3593.c @@ -184,7 +184,6 @@ static struct platform_driver lt3593_led_driver = { .remove = lt3593_led_remove, .driver = { .name = "leds-lt3593", - .owner = THIS_MODULE, }, }; diff --git a/drivers/leds/leds-max8997.c b/drivers/leds/leds-max8997.c index 607bc2755aba..c592aa5662bb 100644 --- a/drivers/leds/leds-max8997.c +++ b/drivers/leds/leds-max8997.c @@ -303,7 +303,6 @@ static int max8997_led_remove(struct platform_device *pdev) static struct platform_driver max8997_led_driver = { .driver = { .name = "max8997-led", - .owner = THIS_MODULE, }, .probe = max8997_led_probe, .remove = max8997_led_remove, diff --git a/drivers/leds/leds-mc13783.c b/drivers/leds/leds-mc13783.c index f1db88e25138..85c3714e1b5a 100644 --- a/drivers/leds/leds-mc13783.c +++ b/drivers/leds/leds-mc13783.c @@ -325,7 +325,6 @@ MODULE_DEVICE_TABLE(platform, mc13xxx_led_id_table); static struct platform_driver mc13xxx_led_driver = { .driver = { .name = "mc13xxx-led", - .owner = THIS_MODULE, }, .remove = mc13xxx_led_remove, .id_table = mc13xxx_led_id_table, diff --git a/drivers/leds/leds-menf21bmc.c b/drivers/leds/leds-menf21bmc.c index 89dd57769e3b..4b9eea815b1a 100644 --- a/drivers/leds/leds-menf21bmc.c +++ b/drivers/leds/leds-menf21bmc.c @@ -119,7 +119,6 @@ static struct platform_driver menf21bmc_led = { .remove = menf21bmc_led_remove, .driver = { .name = "menf21bmc_led", - .owner = THIS_MODULE, }, }; diff --git a/drivers/leds/leds-net48xx.c b/drivers/leds/leds-net48xx.c index 27d06c528246..ec3a2e8adcae 100644 --- a/drivers/leds/leds-net48xx.c +++ b/drivers/leds/leds-net48xx.c @@ -53,7 +53,6 @@ static struct platform_driver net48xx_led_driver = { .remove = net48xx_led_remove, .driver = { .name = DRVNAME, - .owner = THIS_MODULE, }, }; diff --git a/drivers/leds/leds-netxbig.c b/drivers/leds/leds-netxbig.c index 64fde485dcaa..26515c27ea8c 100644 --- a/drivers/leds/leds-netxbig.c +++ b/drivers/leds/leds-netxbig.c @@ -404,7 +404,6 @@ static struct platform_driver netxbig_led_driver = { .remove = netxbig_led_remove, .driver = { .name = "leds-netxbig", - .owner = THIS_MODULE, }, }; diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index 231993d1fe21..1fd6adbb43b7 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c @@ -380,7 +380,6 @@ static struct platform_driver ns2_led_driver = { .remove = ns2_led_remove, .driver = { .name = "leds-ns2", - .owner = THIS_MODULE, .of_match_table = of_match_ptr(of_ns2_leds_match), }, }; diff --git a/drivers/leds/leds-ot200.c b/drivers/leds/leds-ot200.c index c9d906098466..39870de20a26 100644 --- a/drivers/leds/leds-ot200.c +++ b/drivers/leds/leds-ot200.c @@ -158,7 +158,6 @@ static struct platform_driver ot200_led_driver = { .remove = ot200_led_remove, .driver = { .name = "leds-ot200", - .owner = THIS_MODULE, }, }; diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c index d672bb4480f6..f668500a2157 100644 --- a/drivers/leds/leds-pwm.c +++ b/drivers/leds/leds-pwm.c @@ -232,7 +232,6 @@ static struct platform_driver led_pwm_driver = { .remove = led_pwm_remove, .driver = { .name = "leds_pwm", - .owner = THIS_MODULE, .of_match_table = of_pwm_leds_match, }, }; diff --git a/drivers/leds/leds-rb532.c b/drivers/leds/leds-rb532.c index 2e746d257b02..fcd1215b64a2 100644 --- a/drivers/leds/leds-rb532.c +++ b/drivers/leds/leds-rb532.c @@ -53,7 +53,6 @@ static struct platform_driver rb532_led_driver = { .remove = rb532_led_remove, .driver = { .name = "rb532-led", - .owner = THIS_MODULE, }, }; diff --git a/drivers/leds/leds-regulator.c b/drivers/leds/leds-regulator.c index a6354f1ce7b2..ffc21397a675 100644 --- a/drivers/leds/leds-regulator.c +++ b/drivers/leds/leds-regulator.c @@ -213,7 +213,6 @@ static int regulator_led_remove(struct platform_device *pdev) static struct platform_driver regulator_led_driver = { .driver = { .name = "leds-regulator", - .owner = THIS_MODULE, }, .probe = regulator_led_probe, .remove = regulator_led_remove, diff --git a/drivers/leds/leds-s3c24xx.c b/drivers/leds/leds-s3c24xx.c index 785eb53a87fc..83641a7b299a 100644 --- a/drivers/leds/leds-s3c24xx.c +++ b/drivers/leds/leds-s3c24xx.c @@ -116,7 +116,6 @@ static struct platform_driver s3c24xx_led_driver = { .remove = s3c24xx_led_remove, .driver = { .name = "s3c24xx_led", - .owner = THIS_MODULE, }, }; diff --git a/drivers/leds/leds-sunfire.c b/drivers/leds/leds-sunfire.c index 0b8cc4a021a6..c2553c54f2cf 100644 --- a/drivers/leds/leds-sunfire.c +++ b/drivers/leds/leds-sunfire.c @@ -223,7 +223,6 @@ static struct platform_driver sunfire_clockboard_led_driver = { .remove = sunfire_led_generic_remove, .driver = { .name = "sunfire-clockboard-leds", - .owner = THIS_MODULE, }, }; @@ -232,7 +231,6 @@ static struct platform_driver sunfire_fhc_led_driver = { .remove = sunfire_led_generic_remove, .driver = { .name = "sunfire-fhc-leds", - .owner = THIS_MODULE, }, }; diff --git a/drivers/leds/leds-wm831x-status.c b/drivers/leds/leds-wm831x-status.c index 1b71e0701002..56027ef7c7e8 100644 --- a/drivers/leds/leds-wm831x-status.c +++ b/drivers/leds/leds-wm831x-status.c @@ -312,7 +312,6 @@ static int wm831x_status_remove(struct platform_device *pdev) static struct platform_driver wm831x_status_driver = { .driver = { .name = "wm831x-status", - .owner = THIS_MODULE, }, .probe = wm831x_status_probe, .remove = wm831x_status_remove, diff --git a/drivers/leds/leds-wm8350.c b/drivers/leds/leds-wm8350.c index 4133ffe29015..0d121835673f 100644 --- a/drivers/leds/leds-wm8350.c +++ b/drivers/leds/leds-wm8350.c @@ -272,7 +272,6 @@ static int wm8350_led_remove(struct platform_device *pdev) static struct platform_driver wm8350_led_driver = { .driver = { .name = "wm8350-led", - .owner = THIS_MODULE, }, .probe = wm8350_led_probe, .remove = wm8350_led_remove, diff --git a/drivers/leds/leds-wrap.c b/drivers/leds/leds-wrap.c index b358cc05eff5..1ba3defdd460 100644 --- a/drivers/leds/leds-wrap.c +++ b/drivers/leds/leds-wrap.c @@ -111,7 +111,6 @@ static struct platform_driver wrap_led_driver = { .remove = wrap_led_remove, .driver = { .name = DRVNAME, - .owner = THIS_MODULE, }, }; |