Skip to content

Commit

Permalink
gpio: wm8994: use gpiochip_dup_line_label()
Browse files Browse the repository at this point in the history
Use the new gpiochip_dup_line_label() helper to safely retrieve the
descriptor label.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Bartosz Golaszewski committed Dec 8, 2023
1 parent 1610cd5 commit abeec1a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions drivers/gpio/gpio-wm8994.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*
*/

#include <linux/cleanup.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/module.h>
Expand Down Expand Up @@ -193,18 +194,20 @@ static void wm8994_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
for (i = 0; i < chip->ngpio; i++) {
int gpio = i + chip->base;
int reg;
const char *label;

/* We report the GPIO even if it's not requested since
* we're also reporting things like alternate
* functions which apply even when the GPIO is not in
* use as a GPIO.
*/
label = gpiochip_is_requested(chip, i);
if (!label)
label = "Unrequested";
char *label __free(kfree) = gpiochip_dup_line_label(chip, i);
if (IS_ERR(label)) {
dev_err(wm8994->dev, "Failed to duplicate label\n");
continue;
}

seq_printf(s, " gpio-%-3d (%-20.20s) ", gpio, label);
seq_printf(s, " gpio-%-3d (%-20.20s) ", gpio,
label ?: "Unrequested");

reg = wm8994_reg_read(wm8994, WM8994_GPIO_1 + i);
if (reg < 0) {
Expand Down

0 comments on commit abeec1a

Please sign in to comment.