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 <[email protected]>
---
drivers/leds/trigger/ledtrig-gpio.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/leds/trigger/ledtrig-gpio.c b/drivers/leds/trigger/ledtrig-gpio.c
index 9b7fe5dd5208..d91ae7fde3cf 100644
--- a/drivers/leds/trigger/ledtrig-gpio.c
+++ b/drivers/leds/trigger/ledtrig-gpio.c
@@ -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);
--
2.40.0.1.gaa8946217a0b
Follow the advice of the Documentation/filesystems/sysfs.rst and show()
should only use sysfs_emit() or sysfs_emit_at() when formatting the
value to be returned to user space.
Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/leds/trigger/ledtrig-gpio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/leds/trigger/ledtrig-gpio.c b/drivers/leds/trigger/ledtrig-gpio.c
index 8a30f9228186..8824be19881f 100644
--- a/drivers/leds/trigger/ledtrig-gpio.c
+++ b/drivers/leds/trigger/ledtrig-gpio.c
@@ -46,7 +46,7 @@ static ssize_t gpio_trig_brightness_show(struct device *dev,
{
struct gpio_trig_data *gpio_data = led_trigger_get_drvdata(dev);
- return sprintf(buf, "%u\n", gpio_data->desired_brightness);
+ return sysfs_emit(buf, "%u\n", gpio_data->desired_brightness);
}
static ssize_t gpio_trig_brightness_store(struct device *dev,
--
2.40.0.1.gaa8946217a0b
On Fri, Nov 3, 2023 at 8:53 PM Andy Shevchenko
<[email protected]> wrote:
> Follow the advice of the Documentation/filesystems/sysfs.rst and show()
> should only use sysfs_emit() or sysfs_emit_at() when formatting the
> value to be returned to user space.
>
> Signed-off-by: Andy Shevchenko <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>
Yours,
Linus Walleij
On Fri, Nov 3, 2023 at 8:53 PM Andy Shevchenko
<[email protected]> wrote:
> 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 <[email protected]>
I don't know what I was thinking here. Probably I was thinking that
the nodes doesn't always have a device, but hey, it does...
Reviewed-by: Linus Walleij <[email protected]>
Yours,
Linus Walleij
On Fri, 03 Nov 2023 21:53:07 +0200, Andy Shevchenko wrote:
> 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.
>
>
> [...]
Applied, thanks!
[1/4] leds: trigger: gpio: Replace custom code for gpiod_get_optional()
commit: cafe2f8ed515e586b020a60df44e9f251f4d6248
[2/4] leds: trigger: gpio: Convert to use kstrtox()
commit: 001813a6f0c7b05c139cde5d5177a4a9bfe39b09
[3/4] leds: trigger: gpio: Use sysfs_emit() to instead of s*printf()
commit: bd4f0709c66394bb746c985872c4153ac93877b7
[4/4] leds: trigger: gpio: Convert to DEVICE_ATTR_RW()
commit: 0603a253b18421a336c3be14bdcd1c5d75b6503b
--
Lee Jones [李琼斯]