Commit 9bbd6b72 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Lee Jones

leds: trigger: gpio: Replace custom code for gpiod_get_optional()

gpiod_get_optional() and currently used fwnode_gpiod_get_index()
are both wrappers against the same engine internally. Since we
have a pointer to struct device there is no reason to use fwnode
type of GPIO call. So, replace the current fwnode call by respective
gpiod ones.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20231103195310.948327-1-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarLee Jones <lee@kernel.org>
parent 75469bb0
...@@ -89,10 +89,7 @@ static int gpio_trig_activate(struct led_classdev *led) ...@@ -89,10 +89,7 @@ static int gpio_trig_activate(struct led_classdev *led)
* The generic property "trigger-sources" is followed, * The generic property "trigger-sources" is followed,
* and we hope that this is a GPIO. * and we hope that this is a GPIO.
*/ */
gpio_data->gpiod = fwnode_gpiod_get_index(dev->fwnode, gpio_data->gpiod = gpiod_get_optional(dev, "trigger-sources", GPIOD_IN);
"trigger-sources",
0, GPIOD_IN,
"led-trigger");
if (IS_ERR(gpio_data->gpiod)) { if (IS_ERR(gpio_data->gpiod)) {
ret = PTR_ERR(gpio_data->gpiod); ret = PTR_ERR(gpio_data->gpiod);
kfree(gpio_data); kfree(gpio_data);
...@@ -104,6 +101,8 @@ static int gpio_trig_activate(struct led_classdev *led) ...@@ -104,6 +101,8 @@ static int gpio_trig_activate(struct led_classdev *led)
return -EINVAL; return -EINVAL;
} }
gpiod_set_consumer_name(gpio_data->gpiod, "led-trigger");
gpio_data->led = led; gpio_data->led = led;
led_set_trigger_data(led, gpio_data); led_set_trigger_data(led, gpio_data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment