Loading drivers/gpio/gpio-stmpe.c +5 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson */ #include <linux/cleanup.h> #include <linux/init.h> #include <linux/platform_device.h> #include <linux/slab.h> Loading Loading @@ -255,7 +256,6 @@ static void stmpe_dbg_show_one(struct seq_file *s, { struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(gc); struct stmpe *stmpe = stmpe_gpio->stmpe; const char *label = gpiochip_is_requested(gc, offset); bool val = !!stmpe_gpio_get(gc, offset); u8 bank = offset / 8; u8 dir_reg = stmpe->regs[STMPE_IDX_GPDR_LSB + bank]; Loading @@ -263,6 +263,10 @@ static void stmpe_dbg_show_one(struct seq_file *s, int ret; u8 dir; char *label __free(kfree) = gpiochip_dup_line_label(gc, offset); if (IS_ERR(label)) return; ret = stmpe_reg_read(stmpe, dir_reg); if (ret < 0) return; Loading drivers/gpio/gpio-wm831x.c +9 −5 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ * */ #include <linux/cleanup.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/module.h> Loading Loading @@ -160,18 +161,21 @@ static void wm831x_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, *pull, *powerdomain; const char *pull, *powerdomain; /* 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(wm831x->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 = wm831x_reg_read(wm831x, WM831X_GPIO1_CONTROL + i); if (reg < 0) { Loading drivers/gpio/gpio-wm8994.c +8 −5 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ * */ #include <linux/cleanup.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/module.h> Loading Loading @@ -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) { Loading drivers/gpio/gpiolib.c +21 −14 Original line number Diff line number Diff line Loading @@ -1085,7 +1085,7 @@ void gpiochip_remove(struct gpio_chip *gc) spin_lock_irqsave(&gpio_lock, flags); for (i = 0; i < gdev->ngpio; i++) { if (gpiochip_is_requested(gc, i)) if (test_bit(FLAG_REQUESTED, &gdev->descs[i].flags)) break; } spin_unlock_irqrestore(&gpio_lock, flags); Loading Loading @@ -2374,31 +2374,38 @@ void gpiod_free(struct gpio_desc *desc) } /** * gpiochip_is_requested - return string iff signal was requested * @gc: controller managing the signal * @offset: of signal within controller's 0..(ngpio - 1) range * gpiochip_dup_line_label - Get a copy of the consumer label. * @gc: GPIO chip controlling this line. * @offset: Hardware offset of the line. * * Returns NULL if the GPIO is not currently requested, else a string. * The string returned is the label passed to gpio_request(); if none has been * passed it is a meaningless, non-NULL constant. * Returns: * Pointer to a copy of the consumer label if the line is requested or NULL * if it's not. If a valid pointer was returned, it must be freed using * kfree(). In case of a memory allocation error, the function returns %ENOMEM. * * This function is for use by GPIO controller drivers. The label can * help with diagnostics, and knowing that the signal is used as a GPIO * can help avoid accidentally multiplexing it to another controller. * Must not be called from atomic context. */ const char *gpiochip_is_requested(struct gpio_chip *gc, unsigned int offset) char *gpiochip_dup_line_label(struct gpio_chip *gc, unsigned int offset) { struct gpio_desc *desc; char *label; desc = gpiochip_get_desc(gc, offset); if (IS_ERR(desc)) return NULL; if (test_bit(FLAG_REQUESTED, &desc->flags) == 0) guard(spinlock_irqsave)(&gpio_lock); if (!test_bit(FLAG_REQUESTED, &desc->flags)) return NULL; return desc->label; label = kstrdup(desc->label, GFP_KERNEL); if (!label) return ERR_PTR(-ENOMEM); return label; } EXPORT_SYMBOL_GPL(gpiochip_is_requested); EXPORT_SYMBOL_GPL(gpiochip_dup_line_label); /** * gpiochip_request_own_desc - Allow GPIO chip to request its own descriptor Loading drivers/pinctrl/intel/pinctrl-baytrail.c +6 −5 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ #include <linux/acpi.h> #include <linux/array_size.h> #include <linux/bitops.h> #include <linux/cleanup.h> #include <linux/gpio/driver.h> #include <linux/init.h> #include <linux/interrupt.h> Loading Loading @@ -1173,7 +1174,6 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) const char *pull_str = NULL; const char *pull = NULL; unsigned long flags; const char *label; unsigned int pin; pin = vg->soc->pins[i].number; Loading @@ -1200,9 +1200,10 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) seq_printf(s, "Pin %i: can't retrieve community\n", pin); continue; } label = gpiochip_is_requested(chip, i); if (!label) label = "Unrequested"; char *label __free(kfree) = gpiochip_dup_line_label(chip, i); if (IS_ERR(label)) continue; switch (conf0 & BYT_PULL_ASSIGN_MASK) { case BYT_PULL_ASSIGN_UP: Loading Loading @@ -1231,7 +1232,7 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) seq_printf(s, " gpio-%-3d (%-20.20s) %s %s %s pad-%-3d offset:0x%03x mux:%d %s%s%s", pin, label, label ?: "Unrequested", val & BYT_INPUT_EN ? " " : "in", val & BYT_OUTPUT_EN ? " " : "out", str_hi_lo(val & BYT_LEVEL), Loading Loading
drivers/gpio/gpio-stmpe.c +5 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson */ #include <linux/cleanup.h> #include <linux/init.h> #include <linux/platform_device.h> #include <linux/slab.h> Loading Loading @@ -255,7 +256,6 @@ static void stmpe_dbg_show_one(struct seq_file *s, { struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(gc); struct stmpe *stmpe = stmpe_gpio->stmpe; const char *label = gpiochip_is_requested(gc, offset); bool val = !!stmpe_gpio_get(gc, offset); u8 bank = offset / 8; u8 dir_reg = stmpe->regs[STMPE_IDX_GPDR_LSB + bank]; Loading @@ -263,6 +263,10 @@ static void stmpe_dbg_show_one(struct seq_file *s, int ret; u8 dir; char *label __free(kfree) = gpiochip_dup_line_label(gc, offset); if (IS_ERR(label)) return; ret = stmpe_reg_read(stmpe, dir_reg); if (ret < 0) return; Loading
drivers/gpio/gpio-wm831x.c +9 −5 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ * */ #include <linux/cleanup.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/module.h> Loading Loading @@ -160,18 +161,21 @@ static void wm831x_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, *pull, *powerdomain; const char *pull, *powerdomain; /* 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(wm831x->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 = wm831x_reg_read(wm831x, WM831X_GPIO1_CONTROL + i); if (reg < 0) { Loading
drivers/gpio/gpio-wm8994.c +8 −5 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ * */ #include <linux/cleanup.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/module.h> Loading Loading @@ -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) { Loading
drivers/gpio/gpiolib.c +21 −14 Original line number Diff line number Diff line Loading @@ -1085,7 +1085,7 @@ void gpiochip_remove(struct gpio_chip *gc) spin_lock_irqsave(&gpio_lock, flags); for (i = 0; i < gdev->ngpio; i++) { if (gpiochip_is_requested(gc, i)) if (test_bit(FLAG_REQUESTED, &gdev->descs[i].flags)) break; } spin_unlock_irqrestore(&gpio_lock, flags); Loading Loading @@ -2374,31 +2374,38 @@ void gpiod_free(struct gpio_desc *desc) } /** * gpiochip_is_requested - return string iff signal was requested * @gc: controller managing the signal * @offset: of signal within controller's 0..(ngpio - 1) range * gpiochip_dup_line_label - Get a copy of the consumer label. * @gc: GPIO chip controlling this line. * @offset: Hardware offset of the line. * * Returns NULL if the GPIO is not currently requested, else a string. * The string returned is the label passed to gpio_request(); if none has been * passed it is a meaningless, non-NULL constant. * Returns: * Pointer to a copy of the consumer label if the line is requested or NULL * if it's not. If a valid pointer was returned, it must be freed using * kfree(). In case of a memory allocation error, the function returns %ENOMEM. * * This function is for use by GPIO controller drivers. The label can * help with diagnostics, and knowing that the signal is used as a GPIO * can help avoid accidentally multiplexing it to another controller. * Must not be called from atomic context. */ const char *gpiochip_is_requested(struct gpio_chip *gc, unsigned int offset) char *gpiochip_dup_line_label(struct gpio_chip *gc, unsigned int offset) { struct gpio_desc *desc; char *label; desc = gpiochip_get_desc(gc, offset); if (IS_ERR(desc)) return NULL; if (test_bit(FLAG_REQUESTED, &desc->flags) == 0) guard(spinlock_irqsave)(&gpio_lock); if (!test_bit(FLAG_REQUESTED, &desc->flags)) return NULL; return desc->label; label = kstrdup(desc->label, GFP_KERNEL); if (!label) return ERR_PTR(-ENOMEM); return label; } EXPORT_SYMBOL_GPL(gpiochip_is_requested); EXPORT_SYMBOL_GPL(gpiochip_dup_line_label); /** * gpiochip_request_own_desc - Allow GPIO chip to request its own descriptor Loading
drivers/pinctrl/intel/pinctrl-baytrail.c +6 −5 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ #include <linux/acpi.h> #include <linux/array_size.h> #include <linux/bitops.h> #include <linux/cleanup.h> #include <linux/gpio/driver.h> #include <linux/init.h> #include <linux/interrupt.h> Loading Loading @@ -1173,7 +1174,6 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) const char *pull_str = NULL; const char *pull = NULL; unsigned long flags; const char *label; unsigned int pin; pin = vg->soc->pins[i].number; Loading @@ -1200,9 +1200,10 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) seq_printf(s, "Pin %i: can't retrieve community\n", pin); continue; } label = gpiochip_is_requested(chip, i); if (!label) label = "Unrequested"; char *label __free(kfree) = gpiochip_dup_line_label(chip, i); if (IS_ERR(label)) continue; switch (conf0 & BYT_PULL_ASSIGN_MASK) { case BYT_PULL_ASSIGN_UP: Loading Loading @@ -1231,7 +1232,7 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) seq_printf(s, " gpio-%-3d (%-20.20s) %s %s %s pad-%-3d offset:0x%03x mux:%d %s%s%s", pin, label, label ?: "Unrequested", val & BYT_INPUT_EN ? " " : "in", val & BYT_OUTPUT_EN ? " " : "out", str_hi_lo(val & BYT_LEVEL), Loading