gpiolib: introduce gpio_name() helper
Subsystems (18)
RFC PATCH 1/1 gpiolib: introduce gpio_name() helper
From: Arnd Bergmann <[email protected]>
Most remaining users of desc_to_gpio() only call it for printing debug information.
Replace this with a new gpiod_name() helper that returns the gpio_desc->name string after checking the gpio_desc pointer.
---
Not sure if this the way we want to take this, or if the gpio name is an appropriate replacement in debug printk.
Since most of the callers of desc_to_gpio() and gpio_to_desc() are otherwise in drivers that already depend on CONFIG_GPIOLIB_LEGACY and include linux/gpio/legacy.h, only a handful of instances remain that are otherwise in files that otherwise only use the descriptor interfaces:
arch/arm/mach-pxa/pxa27x.c: reset_gpio = desc_to_gpio(gpiod);arch/arm/plat-orion/gpio.c: unsigned gpio = desc_to_gpio(desc);drivers/gpio/gpio-nomadik.c: mode = nmk_prcm_gpiocr_get_mode(pctldev, desc_to_gpio(desc));drivers/gpio/gpiolib-acpi-core.c: desc = gpio_to_desc(agpio->pin_table[pin_index]);drivers/gpio/gpiolib-cdev.c: hte_init_line_attr(hdesc, desc_to_gpio(line->desc), flags, NULL,drivers/gpio/gpiolib-sysfs.c: desc = gpio_to_desc(gpio);drivers/gpio/gpiolib-sysfs.c: desc_to_gpio(desc));drivers/gpio/gpiolib.c: trace_gpio_direction(desc_to_gpio(desc), 1, ret);drivers/input/misc/soc_button_array.c: *gpio_ret = desc_to_gpio(desc);drivers/pinctrl/core.c: gdev = gpiod_to_gpio_device(gpio_to_desc(gpio_num));drivers/platform/x86/x86-android-tablets/core.c: * 2. Calling desc_to_gpio() to get an old style GPIO number for gpio-keysdrivers/soc/fsl/qe/gpio.c: gpio_num = desc_to_gpio(gpiod);
--- drivers/bluetooth/hci_intel.c | 4 ++-- drivers/extcon/extcon-rtk-type-c.c | 4 ++-- drivers/gpio/gpio-aggregator.c | 4 ++-- drivers/gpio/gpiolib.c | 13 +++++++++++++ drivers/gpu/drm/bridge/analogix/anx7625.c | 6 +++--- drivers/i2c/busses/i2c-gpio.c | 4 ++-- drivers/iio/accel/mma9551.c | 4 ++-- drivers/iio/humidity/dht11.c | 2 +- drivers/input/touchscreen/edt-ft5x06.c | 6 +++--- drivers/input/touchscreen/hycon-hy46xx.c | 5 ++--- drivers/mmc/host/atmel-mci.c | 8 ++++---- drivers/power/supply/bq24257_charger.c | 2 +- drivers/usb/gadget/udc/at91_udc.c | 4 ++-- include/linux/gpio/consumer.h | 8 ++++++++ 14 files changed, 47 insertions(+), 27 deletions(-)
drivers/bluetooth/hci_intel.c +2 -2
@@ -1176,8 +1176,8 @@ static int intel_probe(struct platform_device *pdev)list_add_tail (&idev->list, &intel_device_list);mutex_unlock (&intel_device_list_lock); -dev_info (&pdev->dev,"registered, gpio(%d)/irq(%d).\n" , -desc_to_gpio (idev->reset), idev->irq); +dev_info (&pdev->dev,"registered, gpio(%s)/irq(%d).\n" , +gpiod_name (idev->reset), idev->irq);return 0 ; }
drivers/extcon/extcon-rtk-type-c.c +2 -2
@@ -1356,8 +1356,8 @@ static int extcon_rtk_type_c_probe(struct platform_device *pdev) (int)PTR_ERR(gpio)); }else { type_c->rd_ctrl_gpio_desc = gpio; -dev_dbg (dev,"%s get rd-ctrl-gpios (id=%d) OK\n" , - __func__,desc_to_gpio (gpio)); +dev_dbg (dev,"%s get rd-ctrl-gpios (id=%s) OK\n" , + __func__,gpiod_name (gpio)); } }
drivers/gpio/gpio-aggregator.c +2 -2
@@ -758,8 +758,8 @@ int gpiochip_fwd_desc_add(struct gpiochip_fwd *fwd, struct gpio_desc *desc, fwd->descs[offset] = desc; -dev_dbg (chip->parent,"%u => gpio %d irq %d\n" , offset, -desc_to_gpio (desc),gpiod_to_irq (desc)); +dev_dbg (chip->parent,"%u => gpio %s irq %d\n" , offset, +gpiod_name (desc),gpiod_to_irq (desc));return 0 ; }
drivers/gpio/gpiolib.c +13 -0
@@ -4122,6 +4122,19 @@ int gpiod_set_consumer_name(struct gpio_desc *desc, const char *name) }EXPORT_SYMBOL_GPL (gpiod_set_consumer_name); +/** +* gpiod_name() - get a name to print for a gpio descriptor +* @desc: gpio or NULL pointer to query +* +* Returns: +* The desc->name field or a dummy string for unknown GPIOs. +*/ +const char *gpiod_name (const struct gpio_desc *desc) +{ +return desc ? desc->name :"(no gpio)" ; +} +EXPORT_SYMBOL_GPL (gpiod_name); +/** * gpiod_is_shared() - check if this GPIO can be shared by multiple consumers * @desc: GPIO to inspect
drivers/gpu/drm/bridge/analogix/anx7625.c +3 -3
@@ -1448,9 +1448,9 @@ static void anx7625_init_gpio(struct anx7625_data *platform)if (platform->pdata.gpio_p_on && platform->pdata.gpio_reset) { platform->pdata.low_power_mode =1 ; -DRM_DEV_DEBUG_DRIVER (dev,"low power mode, pon %d, reset %d.\n" , -desc_to_gpio (platform->pdata.gpio_p_on), -desc_to_gpio (platform->pdata.gpio_reset)); +DRM_DEV_DEBUG_DRIVER (dev,"low power mode, pon %s, reset %s.\n" , +gpiod_name (platform->pdata.gpio_p_on), +gpiod_name (platform->pdata.gpio_reset)); }else { platform->pdata.low_power_mode =0 ;DRM_DEV_DEBUG_DRIVER (dev,"not low power mode.\n" );
drivers/i2c/busses/i2c-gpio.c +2 -2
@@ -440,8 +440,8 @@ static int i2c_gpio_probe(struct platform_device *pdev)* get accessors to get the actual name of the GPIO line, * from the descriptor, then provide that instead. */ -dev_info (dev,"using lines %u (SDA) and %u (SCL%s)\n" , -desc_to_gpio (priv->sda),desc_to_gpio (priv->scl), +dev_info (dev,"using lines %s (SDA) and %s (SCL%s)\n" , +gpiod_name (priv->sda),gpiod_name (priv->scl), pdata->scl_is_output_only ?", no clock stretching" :"" );
drivers/iio/accel/mma9551.c +2 -2
@@ -426,8 +426,8 @@ static int mma9551_gpio_probe(struct iio_dev *indio_dev)return ret; } -dev_dbg (dev,"gpio resource, no:%d irq:%d\n" , -desc_to_gpio (gpio), data->irqs[i]); +dev_dbg (dev,"gpio resource, no:%s irq:%d\n" , +gpiod_name (gpio), data->irqs[i]); }return 0 ;
drivers/iio/humidity/dht11.c +1 -1
@@ -305,7 +305,7 @@ static int dht11_probe(struct platform_device *pdev) dht11->irq =gpiod_to_irq (dht11->gpiod);if (dht11->irq <0 ) { -dev_err (dev,"GPIO %d has no interrupt\n" ,desc_to_gpio (dht11->gpiod)); +dev_err (dev,"GPIO %s has no interrupt\n" ,gpiod_name (dht11->gpiod));return -EINVAL ; }
drivers/input/touchscreen/edt-ft5x06.c +3 -3
@@ -1326,10 +1326,10 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client)edt_ft5x06_ts_prepare_debugfs (tsdata);dev_dbg (&client->dev, -"EDT FT5x06 initialized: IRQ %d, WAKE pin %d, Reset pin %d.\n" , +"EDT FT5x06 initialized: IRQ %d, WAKE pin %s, Reset pin %s.\n" , client->irq, - tsdata->wake_gpio ?desc_to_gpio (tsdata->wake_gpio) :-1 , - tsdata->reset_gpio ?desc_to_gpio (tsdata->reset_gpio) :-1 ); +gpiod_name (tsdata->wake_gpio), +gpiod_name (tsdata->reset_gpio));return 0 ; }
drivers/input/touchscreen/hycon-hy46xx.c +2 -3
@@ -528,9 +528,8 @@ static int hycon_hy46xx_probe(struct i2c_client *client)return error;dev_dbg (&client->dev, -"HYCON HY46XX initialized: IRQ %d, Reset pin %d.\n" , - client->irq, - tsdata->reset_gpio ?desc_to_gpio (tsdata->reset_gpio) :-1 ); +"HYCON HY46XX initialized: IRQ %d, Reset pin %s.\n" , + client->irq,gpiod_name (tsdata->reset_gpio));return 0 ; }
drivers/mmc/host/atmel-mci.c +4 -4
@@ -2255,11 +2255,11 @@ static int atmci_init_slot(struct atmel_mci *host, slot->sdio_irq = sdio_irq;dev_dbg (&mmc->class_dev, -"slot[%u]: bus_width=%u, detect_pin=%d, " -"detect_is_active_high=%s, wp_pin=%d\n" , - id, slot_data->bus_width,desc_to_gpio (slot_data->detect_pin), +"slot[%u]: bus_width=%u, detect_pin=%s, " +"detect_is_active_high=%s, wp_pin=%s\n" , + id, slot_data->bus_width,gpiod_name (slot_data->detect_pin),str_true_false (!gpiod_is_active_low (slot_data->detect_pin)), -desc_to_gpio (slot_data->wp_pin)); +gpiod_name (slot_data->wp_pin)); mmc->ops = &atmci_ops; mmc->f_min =DIV_ROUND_UP (host->bus_hz,512 );
drivers/power/supply/bq24257_charger.c +1 -1
@@ -868,7 +868,7 @@ static void bq24257_pg_gpio_probe(struct bq24257_device *bq) }if (bq->pg) -dev_dbg (bq->dev,"probed PG pin = %d\n" ,desc_to_gpio (bq->pg)); +dev_dbg (bq->dev,"probed PG pin = %s\n" ,gpiod_name (bq->pg)); }static int bq24257_fw_probe (struct bq24257_device *bq)
drivers/usb/gadget/udc/at91_udc.c +2 -2
@@ -1896,8 +1896,8 @@ static int at91udc_probe(struct platform_device *pdev)gpiod_to_irq (udc->board.vbus_pin), at91_vbus_irq, 0, driver_name, udc);if (retval) { -DBG ("request vbus irq %d failed\n" , -desc_to_gpio (udc->board.vbus_pin)); +DBG ("request vbus irq %s failed\n" , +gpiod_name (udc->board.vbus_pin)); goto err_unprepare_iclk; } }
include/linux/gpio/consumer.h +8 -0
@@ -172,6 +172,8 @@ int gpiod_set_consumer_name(struct gpio_desc *desc, const char *name);bool gpiod_is_shared (const struct gpio_desc *desc); +const char *gpiod_name (const struct gpio_desc *desc); +/* Convert between the old gpio_ and new gpiod_ interfaces */ struct gpio_desc *gpio_to_desc (unsigned gpio);int desc_to_gpio (const struct gpio_desc *desc);
@@ -538,6 +540,12 @@ static inline bool gpiod_is_shared(const struct gpio_desc *desc)return false; } +static inline const char *gpiod_name (const struct gpio_desc *desc) +{ +WARN_ON (desc); +return "(no gpio)" ; +} +static inline struct gpio_desc *gpio_to_desc (unsigned gpio) {return NULL ;
Signature · 1 line
2.39.5
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Pre-existing issues:
- [High] Uncanceled timer in the probe error path leads to a Use-After-Free when the timer fires.
- [High] Uncanceled delayed work in the probe error path and early IRQ request lead to Use-After-Free.
- [High] The return value of extcon_rtk_type_c_edev_register() is assigned but never checked, leading to silent failures. --
commit fd9fdd473dd5d54a8f94bae5e74133accbec590a
Author: Arnd Bergmann <[email protected]>
gpiolib: introduce gpio_name() helper
Most remaining users of desc_to_gpio() only call it for printing debug information.
Replace this with a new gpiod_name() helper that returns the gpio_desc->name string after checking the gpio_desc pointer.
Quoted 5 lines
drivers/extcon/extcon-rtk-type-c.c +0
-0
drivers/extcon/extcon-rtk-type-c.c static int extcon_rtk_type_c_probe(struct platform_device *pdev) · line 1362
Quoted 9 lines
drivers/extcon/extcon-rtk-type-c.c +2
-2@@ -1356,8 +1356,8 @@ static int extcon_rtk_type_c_probe(struct platform_device *pdev) (int)PTR_ERR(gpio)); }else { type_c->rd_ctrl_gpio_desc = gpio; -dev_dbg (dev,"%s get rd-ctrl-gpios (id=%d) OK\n" , - __func__,desc_to_gpio (gpio)); +dev_dbg (dev,"%s get rd-ctrl-gpios (id=%s) OK\n" , + __func__,gpiod_name (gpio)); } }
[Severity: High]
This is a pre-existing issue, but I noticed a potential use-after-free if extcon_rtk_type_c_init() fails.
In extcon_rtk_type_c_probe(), the code requests an IRQ before the delayed work is initialized:
ret = devm_request_irq(dev, type_c->irq, type_c_detect_irq, ...);
...
INIT_DELAYED_WORK(&type_c->delayed_work, host_device_switch);
ret = extcon_rtk_type_c_init(type_c);
if (ret) {
dev_err(dev, "%s failed to init type_c\n", __func__);
goto err;
}Could an early interrupt schedule the uninitialized work?
Also, if extcon_rtk_type_c_init() fails, the code jumps to the err label and returns without canceling the delayed work. Since the structure is freed by devres, will this cause a use-after-free when the work executes?
[Severity: High]
This is also a pre-existing issue, but further down in the same function, the return value of extcon_rtk_type_c_edev_register() is assigned to ret but is not checked:
ret = extcon_rtk_type_c_edev_register(type_c); create_debug_files(type_c); return 0;
Could this mask a registration failure, since the function unconditionally returns 0?
[ ... ]
Quoted 5 lines
drivers/usb/gadget/udc/at91_udc.c +0
-0
drivers/usb/gadget/udc/at91_udc.c static int at91udc_probe(struct platform_device *pdev) · line 1903
Quoted 10 lines
drivers/usb/gadget/udc/at91_udc.c +2
-2@@ -1896,8 +1896,8 @@ static int at91udc_probe(struct platform_device *pdev)gpiod_to_irq (udc->board.vbus_pin), at91_vbus_irq, 0, driver_name, udc);if (retval) { -DBG ("request vbus irq %d failed\n" , -desc_to_gpio (udc->board.vbus_pin)); +DBG ("request vbus irq %s failed\n" , +gpiod_name (udc->board.vbus_pin)); goto err_unprepare_iclk; } }
[Severity: High]
This is a pre-existing issue, but there appears to be a missing timer cleanup in the probe error path.
In at91udc_probe(), when vbus_polled is true, a timer is armed:
if (udc->board.vbus_polled) {
INIT_WORK(&udc->vbus_timer_work, at91_vbus_timer_work);
timer_setup(&udc->vbus_timer, at91_vbus_timer, 0);
mod_timer(&udc->vbus_timer,
jiffies + VBUS_POLL_TIMEOUT);
}If usb_add_gadget_udc() fails later, the code jumps to err_unprepare_iclk and returns without deleting the timer:
retval = usb_add_gadget_udc(dev, &udc->gadget); if (retval) goto err_unprepare_iclk; ... err_unprepare_iclk: clk_unprepare(udc->iclk); err_unprepare_fclk: clk_unprepare(udc->fclk); return retval;
If the probe fails, devres will free the udc structure. Does this mean the timer can still fire and access the freed udc memory, causing a use-after-free?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 5 lines · Arnd Bergmann
Most remaining users of
desc_to_gpio()only call it for printing debug information.Replace this with a new
gpiod_name()helper that returns thegpio_desc->namestring after checking thegpio_descpointer.
Oh, that's nice!
...
drivers/gpio/gpiolib.c int gpiod_set_consumer_name(struct gpio_desc *desc, const char *name) · line 4134
Quoted 10 lines
drivers/gpio/gpiolib.c +10
-0+/** +* gpiod_name() - get a name to print for a gpio descriptor +* @desc: gpio or NULL pointer to query +* +* Returns: +* The desc->name field or a dummy string for unknown GPIOs. +*/ +const char *gpiod_name (const struct gpio_desc *desc) +{ +return desc ? desc->name :"(no gpio)" ;
Can we get into here with wrong (error pointer descriptor)? Shouldn't you call one of validate_desc() / VALIDATE_DESC()?
Also not sure if "(no gpio)" is a good choice. "not requested"? "not provided"?
Quoted 1 line
+}
...
include/linux/gpio/consumer.h static inline bool gpiod_is_shared(const struct gpio_desc *desc) · line 546
Quoted 4 lines
include/linux/gpio/consumer.h +4
-0+static inline const char *gpiod_name (const struct gpio_desc *desc) +{ +WARN_ON (desc); +return "(no gpio)" ;
Hmm... This will be a second copy with a slight potential of going apart from the other case. Perhaps a #define? (Yes, yes, I understand that there are pros and cons, in particular readability with define is questionable.)
Quoted 1 line
+}
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 7 lines · Andy Shevchenko
drivers/gpio/gpiolib.c int gpiod_set_consumer_name(struct gpio_desc *desc, const char *name) · line 4134
Quoted 3 lines · Arnd Bergmann
drivers/gpio/gpiolib.c +3
-0+const char *gpiod_name (const struct gpio_desc *desc) +{ +return desc ? desc->name :"(no gpio)" ;Can we get into here with wrong (error pointer descriptor)? Shouldn't you call one of
validate_desc()/VALIDATE_DESC()?
Since all the callers previously call desc_to_gpio and that does not even check desc at all, it would be a preexisting bug if any caller passed an error pointer.
I added the NULL pointer check since many callers had that part originally, like
tsdata->wake_gpio ? desc_to_gpio(tsdata->wake_gpio) : -1,
Quoted 1 line
Also not sure if "(no gpio)" is a good choice. "not requested"? "not provided"?
Any of those seem fine to me, not sure.
Quoted 8 lines
include/linux/gpio/consumer.h static inline bool gpiod_is_shared(const struct gpio_desc *desc) · line 546
Quoted 4 lines
include/linux/gpio/consumer.h +4
-0+static inline const char *gpiod_name (const struct gpio_desc *desc) +{ +WARN_ON (desc); +return "(no gpio)" ;Hmm... This will be a second copy with a slight potential of going apart from the other case. Perhaps a #define? (Yes, yes, I understand that there are pros and cons, in particular readability with define is questionable.)
I was mostly trying to optimize for consistency with the other stub functions here. Since it should not actually be used at all without gpiolib, returning NULL or an empty string here would also work.
Arnd
Hi Arnd,
Quoted 9 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Most remaining users of
desc_to_gpio()only call it for printing debug information.Replace this with a new
gpiod_name()helper that returns thegpio_desc->namestring after checking thegpio_descpointer.Signed-off-by Arnd Bergmann <[email protected]>
Thanks for your patch!
Quoted 11 lines
Not sure if this the way we want to take this, or if the gpio name is an appropriate replacement in debug printk.
Since most of the callers of
desc_to_gpio()andgpio_to_desc()are otherwise in drivers that already depend onCONFIG_GPIOLIB_LEGACYand includelinux/gpio/legacy.h, only a handful of instances remain that are otherwise in files that otherwise only use the descriptor interfaces:
drivers/gpio/gpio-aggregator.c int gpiochip_fwd_desc_add(struct gpiochip_fwd *fwd, struct gpio_desc *desc, · line 765
Quoted 10 lines
drivers/gpio/gpio-aggregator.c +2
-2@@ -758,8 +758,8 @@ int gpiochip_fwd_desc_add(struct gpiochip_fwd *fwd, struct gpio_desc *desc, fwd->descs[offset] = desc; -dev_dbg (chip->parent,"%u => gpio %d irq %d\n" , offset, -desc_to_gpio (desc),gpiod_to_irq (desc)); +dev_dbg (chip->parent,"%u => gpio %s irq %d\n" , offset, +gpiod_name (desc),gpiod_to_irq (desc));return 0 ; }
Before, this printed:
gpio-aggregator gpio-aggregator.1: 0 => gpio 589 irq 188 gpio-aggregator gpio-aggregator.1: 1 => gpio 590 irq 189
After, this prints:
gpio-aggregator gpio-aggregator.1: 0 => gpio (null) irq 188 gpio-aggregator gpio-aggregator.1: 1 => gpio (null) irq 189
Same results for instantiation using sysfs or configfs[1], although the latter does have optional support for specifying the name.
[1] Documentation/admin-guide/gpio/gpio-aggregator.rst
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Quoted 6 lines · Geert Uytterhoeven
Quoted 5 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Most remaining users of
desc_to_gpio()only call it for printing debug information.
Quoted 6 lines
Quoted 4 lines
Replace this with a new
gpiod_name()helper that returns thegpio_desc->namestring after checking thegpio_descpointer.Signed-off-by Arnd Bergmann <[email protected]>Thanks for your patch!
Thanks for testing!
Quoted 19 lines
drivers/gpio/gpio-aggregator.c int gpiochip_fwd_desc_add(struct gpiochip_fwd *fwd, struct gpio_desc *desc, · line 765
Quoted 13 lines
drivers/gpio/gpio-aggregator.c +2
-2@@ -758,8 +758,8 @@ int gpiochip_fwd_desc_add(struct gpiochip_fwd *fwd, struct gpio_desc *desc, fwd->descs[offset] = desc; -dev_dbg (chip->parent,"%u => gpio %d irq %d\n" , offset, -desc_to_gpio (desc),gpiod_to_irq (desc)); +dev_dbg (chip->parent,"%u => gpio %s irq %d\n" , offset, +gpiod_name (desc),gpiod_to_irq (desc));return 0 ; }Before, this printed:
gpio-aggregator gpio-aggregator.1: 0 => gpio 589 irq 188 gpio-aggregator gpio-aggregator.1: 1 => gpio 590 irq 189
Quoted 7 lines
After, this prints:
gpio-aggregator gpio-aggregator.1: 0 => gpio (null) irq 188 gpio-aggregator gpio-aggregator.1: 1 => gpio (null) irq 189
Same results for instantiation using sysfs or configfs[1], although the latter does have optional support for specifying the name.
I wonder how many of the other instances have the same problem then. Would it be appropriate for gpiochip_fwd_desc_add() to set a name itself to address this one?
Arnd
Hi Arnd,
Quoted 36 lines · Arnd Bergmann
Quoted 35 lines · Geert Uytterhoeven
Quoted 13 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Most remaining users of
desc_to_gpio()only call it for printing debug information.Replace this with a new
gpiod_name()helper that returns thegpio_desc->namestring after checking thegpio_descpointer.Signed-off-by Arnd Bergmann <[email protected]>drivers/gpio/gpio-aggregator.c int gpiochip_fwd_desc_add(struct gpiochip_fwd *fwd, struct gpio_desc *desc, · line 765
Quoted 10 lines
drivers/gpio/gpio-aggregator.c +2
-2@@ -758,8 +758,8 @@ int gpiochip_fwd_desc_add(struct gpiochip_fwd *fwd, struct gpio_desc *desc, fwd->descs[offset] = desc; -dev_dbg (chip->parent,"%u => gpio %d irq %d\n" , offset, -desc_to_gpio (desc),gpiod_to_irq (desc)); +dev_dbg (chip->parent,"%u => gpio %s irq %d\n" , offset, +gpiod_name (desc),gpiod_to_irq (desc));return 0 ; }Before, this printed:
gpio-aggregator gpio-aggregator.1: 0 => gpio 589 irq 188 gpio-aggregator gpio-aggregator.1: 1 => gpio 590 irq 189
After, this prints:
gpio-aggregator gpio-aggregator.1: 0 => gpio (null) irq 188 gpio-aggregator gpio-aggregator.1: 1 => gpio (null) irq 189
Quoted 6 lines
Quoted 2 lines
Same results for instantiation using sysfs or configfs[1], although the latter does have optional support for specifying the name.
I wonder how many of the other instances have the same problem then. Would it be appropriate for
gpiochip_fwd_desc_add()to set a name itself to address this one?
I don't think it would be appropriate for the GPIO aggregator to set that name. What we want to print here (for debugging) is the physical GPIO that an aggregator's GPIO is mapped to, not some consumer or line name (which is not guaranteed to be unique).
E.g. "<chip-name>.<offset>" would be fine. As gpiod_name() can only return a fixed string or an existing string, it can't return such a formatted string, though. And consumers don't have access to chip info?
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Quoted 6 lines · Geert Uytterhoeven
Quoted 5 lines · Arnd Bergmann
Quoted 2 lines · Geert Uytterhoeven
Same results for instantiation using sysfs or configfs[1], although the latter does have optional support for specifying the name.
Quoted 8 lines
Quoted 3 lines
I wonder how many of the other instances have the same problem then. Would it be appropriate for
gpiochip_fwd_desc_add()to set a name itself to address this one?I don't think it would be appropriate for the GPIO aggregator to set that name. What we want to print here (for debugging) is the physical GPIO that an aggregator's GPIO is mapped to, not some consumer or line name (which is not guaranteed to be unique).
Ok.
Quoted 3 lines
E.g. "<chip-name>.<offset>" would be fine. As
gpiod_name()can only return a fixed string or an existing string, it can't return such a formatted string, though. And consumers don't have access to chip info?
The gpiod_hwgpio() function is exported to consumers, so they can already print that instead of desc_to_gpio() if the local number is sufficient. If we really care about the <chip-name> portion for any of the debug prints, we could export another function that returns maybe gpiod_to_chip(gpiod)->label or dev_name(&gpiod_to_gpio_device(gpiod)->dev), which are both constant strings we can print.
It looks like we can also replace most of the remaining callers of desc_to_gpio() with gpiod_hwgpio().
Arnd
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1118320
---Test result---
Test Summary:
CheckPatch FAIL 3.84 seconds VerifyFixes PASS 0.22 seconds VerifySignedoff PASS 0.20 seconds GitLint FAIL 0.58 seconds SubjectPrefix FAIL 0.20 seconds BuildKernel PASS 26.40 seconds CheckAllWarning PASS 35.60 seconds CheckSparse PASS 28.00 seconds BuildKernel32 PASS 25.79 seconds CheckKernelLLVM SKIP 0.00 seconds TestRunnerSetup PASS 490.36 seconds TestRunner_l2cap-tester FAIL 57.02 seconds TestRunner_iso-tester PASS 78.67 seconds TestRunner_bnep-tester PASS 18.84 seconds TestRunner_mgmt-tester FAIL 204.92 seconds TestRunner_rfcomm-tester PASS 30.24 seconds TestRunner_sco-tester PASS 31.85 seconds TestRunner_ioctl-tester PASS 25.76 seconds TestRunner_mesh-tester FAIL 25.14 seconds TestRunner_smp-tester PASS 23.27 seconds TestRunner_userchan-tester PASS 20.56 seconds TestRunner_6lowpan-tester PASS 22.18 seconds IncrementalBuild PASS 25.31 seconds
Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[RFC] gpiolib: introduce gpio_name() helper
ERROR: code indent should use tabs where possible
#296: FILE: drivers/mmc/host/atmel-mci.c:2258:
+^I "slot[%u]: bus_width=%u, detect_pin=%s, "$
WARNING: quoted string split across lines
#297: FILE: drivers/mmc/host/atmel-mci.c:2259:
+ "slot[%u]: bus_width=%u, detect_pin=%s, "
+ "detect_is_active_high=%s, wp_pin=%s\n",
total: 1 errors, 1 warnings, 166 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
NOTE: Whitespace errors detected.
You may wish to use scripts/cleanpatch or scripts/cleanfile
/github/workspace/src/patch/14651677.patch has style problems, please review.
NOTE: Ignored message types: UNKNOWN_COMMIT_ID
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[RFC] gpiolib: introduce gpio_name() helper
22: B3 Line contains hard tab characters (\t): "arch/arm/mach-pxa/pxa27x.c: reset_gpio = desc_to_gpio(gpiod);"
23: B3 Line contains hard tab characters (\t): "arch/arm/plat-orion/gpio.c: unsigned gpio = desc_to_gpio(desc);"
24: B1 Line exceeds max length (91>80): "drivers/gpio/gpio-nomadik.c: mode = nmk_prcm_gpiocr_get_mode(pctldev, desc_to_gpio(desc));"
24: B3 Line contains hard tab characters (\t): "drivers/gpio/gpio-nomadik.c: mode = nmk_prcm_gpiocr_get_mode(pctldev, desc_to_gpio(desc));"
25: B1 Line exceeds max length (85>80): "drivers/gpio/gpiolib-acpi-core.c: desc = gpio_to_desc(agpio->pin_table[pin_index]);"
25: B3 Line contains hard tab characters (\t): "drivers/gpio/gpiolib-acpi-core.c: desc = gpio_to_desc(agpio->pin_table[pin_index]);"
26: B1 Line exceeds max length (93>80): "drivers/gpio/gpiolib-cdev.c: hte_init_line_attr(hdesc, desc_to_gpio(line->desc), flags, NULL,"
26: B3 Line contains hard tab characters (\t): "drivers/gpio/gpiolib-cdev.c: hte_init_line_attr(hdesc, desc_to_gpio(line->desc), flags, NULL,"
27: B3 Line contains hard tab characters (\t): "drivers/gpio/gpiolib-sysfs.c: desc = gpio_to_desc(gpio);"
28: B3 Line contains hard tab characters (\t): "drivers/gpio/gpiolib-sysfs.c: desc_to_gpio(desc));"
29: B3 Line contains hard tab characters (\t): "drivers/gpio/gpiolib.c: trace_gpio_direction(desc_to_gpio(desc), 1, ret);"
30: B3 Line contains hard tab characters (\t): "drivers/input/misc/soc_button_array.c: *gpio_ret = desc_to_gpio(desc);"
31: B3 Line contains hard tab characters (\t): "drivers/pinctrl/core.c: gdev = gpiod_to_gpio_device(gpio_to_desc(gpio_num));"
32: B1 Line exceeds max length (122>80): "drivers/platform/x86/x86-android-tablets/core.c: * 2. Calling desc_to_gpio() to get an old style GPIO number for gpio-keys"
33: B3 Line contains hard tab characters (\t): "drivers/soc/fsl/qe/gpio.c: gpio_num = desc_to_gpio(gpiod);"
##############################
Test: SubjectPrefix - FAIL
Desc: Check subject contains "Bluetooth" prefix
Output:
"Bluetooth: " prefix is not specified in the subject
##############################
Test: CheckKernelLLVM - SKIP
Desc: Build kernel with LLVM + context analysis
Output:
Clang not found
##############################
Test: TestRunner_l2cap-tester - FAIL
Desc: Run l2cap-tester with test-runner
Output:
Total: 96, Passed: 95 (99.0%), Failed: 1, Not Run: 0
Failed Test Cases
L2CAP BR/EDR Server - Set PHY 2M Failed 0.242 seconds
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner Output:
Total: 494, Passed: 489 (99.0%), Failed: 1, Not Run: 4
Failed Test Cases
Read Exp Feature - Success Failed 0.232 seconds
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0
Failed Test Cases
Mesh - Send cancel - 1 Timed out 1.862 seconds Mesh - Send cancel - 2 Timed out 1.987 seconds
https://github.com/bluez/bluetooth-next/pull/371
---
Regards,
Linux Bluetooth