Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: wm8994: use gpiochip_dup_line_label()

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>

+8 -5
+8 -5
drivers/gpio/gpio-wm8994.c
··· 8 8 * 9 9 */ 10 10 11 + #include <linux/cleanup.h> 11 12 #include <linux/kernel.h> 12 13 #include <linux/slab.h> 13 14 #include <linux/module.h> ··· 194 193 for (i = 0; i < chip->ngpio; i++) { 195 194 int gpio = i + chip->base; 196 195 int reg; 197 - const char *label; 198 196 199 197 /* We report the GPIO even if it's not requested since 200 198 * we're also reporting things like alternate 201 199 * functions which apply even when the GPIO is not in 202 200 * use as a GPIO. 203 201 */ 204 - label = gpiochip_is_requested(chip, i); 205 - if (!label) 206 - label = "Unrequested"; 202 + char *label __free(kfree) = gpiochip_dup_line_label(chip, i); 203 + if (IS_ERR(label)) { 204 + dev_err(wm8994->dev, "Failed to duplicate label\n"); 205 + continue; 206 + } 207 207 208 - seq_printf(s, " gpio-%-3d (%-20.20s) ", gpio, label); 208 + seq_printf(s, " gpio-%-3d (%-20.20s) ", gpio, 209 + label ?: "Unrequested"); 209 210 210 211 reg = wm8994_reg_read(wm8994, WM8994_GPIO_1 + i); 211 212 if (reg < 0) {