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

JIRA: https://issues.redhat.com/browse/RHEL-32110

commit 9bbd6b7209cf1e26390975b7617a29901c8990a1
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date:   Fri Nov 3 21:53:07 2023 +0200

    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: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
    Link: https://lore.kernel.org/r/20231103195310.948327-1-andriy.shevchenko@linux.intel.com
    Signed-off-by: Lee Jones <lee@kernel.org>

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
This commit is contained in:
Michal Schmidt 2024-04-23 12:18:33 +02:00
parent 9d41bd9c2f
commit b37dd15057
1 changed files with 3 additions and 4 deletions

View File

@ -89,10 +89,7 @@ static int gpio_trig_activate(struct led_classdev *led)
* The generic property "trigger-sources" is followed,
* and we hope that this is a GPIO.
*/
gpio_data->gpiod = fwnode_gpiod_get_index(dev->fwnode,
"trigger-sources",
0, GPIOD_IN,
"led-trigger");
gpio_data->gpiod = gpiod_get_optional(dev, "trigger-sources", GPIOD_IN);
if (IS_ERR(gpio_data->gpiod)) {
ret = PTR_ERR(gpio_data->gpiod);
kfree(gpio_data);
@ -104,6 +101,8 @@ static int gpio_trig_activate(struct led_classdev *led)
return -EINVAL;
}
gpiod_set_consumer_name(gpio_data->gpiod, "led-trigger");
gpio_data->led = led;
led_set_trigger_data(led, gpio_data);