From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH v2025.09.y 08/58] drivers: don't propagate of_alias_get_id's -ENODEV out of probe
Date: Fri, 13 Mar 2026 14:24:52 +0100 [thread overview]
Message-ID: <20260313132631.2257573-9-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20260313132631.2257573-1-a.fatoum@pengutronix.de>
of_alias_get_id() returns -ENODEV on failure and propagating it gives
the user nothing to hint at there being a problem, so let's improve upon
that by either falling back to dynamic ID selections if possible or
returning a more fitting error code instead.
(cherry picked from commit e688d63a116a3288500b1f6324d26282f1ed4238)
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20251113075904.990058-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/gpio/gpio-clps711x.c | 2 +-
drivers/gpio/gpio-imx.c | 5 ++---
drivers/gpio/gpio-mxs.c | 2 +-
drivers/gpio/gpio-omap.c | 5 ++---
drivers/gpio/gpio-orion.c | 5 ++---
drivers/gpio/gpio-vf610.c | 14 ++++----------
drivers/spi/imx_spi.c | 5 +----
drivers/usb/imx/imx-usb-phy.c | 2 +-
drivers/usb/musb/phy-am335x.c | 3 +--
9 files changed, 15 insertions(+), 28 deletions(-)
diff --git a/drivers/gpio/gpio-clps711x.c b/drivers/gpio/gpio-clps711x.c
index a59bdd212a9c..8b8e91b825c5 100644
--- a/drivers/gpio/gpio-clps711x.c
+++ b/drivers/gpio/gpio-clps711x.c
@@ -15,7 +15,7 @@ static int clps711x_gpio_probe(struct device *dev)
struct bgpio_chip *bgc;
if (id < 0 || id > 4)
- return -ENODEV;
+ return -EINVAL;
iores = dev_request_mem_resource(dev, 0);
if (IS_ERR(iores))
diff --git a/drivers/gpio/gpio-imx.c b/drivers/gpio/gpio-imx.c
index d9499c66cdae..31c62a251bee 100644
--- a/drivers/gpio/gpio-imx.c
+++ b/drivers/gpio/gpio-imx.c
@@ -135,9 +135,8 @@ static int imx_gpio_probe(struct device *dev)
imxgpio->chip.ops = &imx_gpio_ops;
if (dev->id < 0) {
imxgpio->chip.base = of_alias_get_id(dev->of_node, "gpio");
- if (imxgpio->chip.base < 0)
- return imxgpio->chip.base;
- imxgpio->chip.base *= 32;
+ if (imxgpio->chip.base >= 0)
+ imxgpio->chip.base *= 32;
} else {
imxgpio->chip.base = dev->id * 32;
}
diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
index df698eb19167..00a9b72dfc86 100644
--- a/drivers/gpio/gpio-mxs.c
+++ b/drivers/gpio/gpio-mxs.c
@@ -112,7 +112,7 @@ static int mxs_gpio_probe(struct device *dev)
if (dev->id < 0) {
id = of_alias_get_id(dev->of_node, "gpio");
if (id < 0)
- return id;
+ return -ENOENT;
mxsgpio->base = dev_get_mem_region(dev->parent, 0);
mxsgpio->chip.base = id * 32;
} else {
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index ed043286b7ff..f5abd63a90f8 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -135,9 +135,8 @@ static int omap_gpio_probe(struct device *dev)
omapgpio->chip.ops = &omap_gpio_ops;
if (dev->id < 0) {
omapgpio->chip.base = of_alias_get_id(dev->of_node, "gpio");
- if (omapgpio->chip.base < 0)
- return omapgpio->chip.base;
- omapgpio->chip.base *= 32;
+ if (omapgpio->chip.base >= 0)
+ omapgpio->chip.base *= 32;
} else {
omapgpio->chip.base = dev->id * 32;
}
diff --git a/drivers/gpio/gpio-orion.c b/drivers/gpio/gpio-orion.c
index 0a1b50069b98..0760205c2610 100644
--- a/drivers/gpio/gpio-orion.c
+++ b/drivers/gpio/gpio-orion.c
@@ -95,10 +95,9 @@ static int orion_gpio_probe(struct device *dev)
gpio->chip.ops = &orion_gpio_ops;
id = of_alias_get_id(dev->of_node, "gpio");
- if (id < 0)
- return id;
+ if (id >= 0)
+ gpio->chip.base = id * 32;
- gpio->chip.base = id * 32;
gpio->chip.ngpio = 32;
of_property_read_u32(dev->of_node, "ngpios", &gpio->chip.ngpio);
diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c
index eefbaa70230f..5ce508469eb2 100644
--- a/drivers/gpio/gpio-vf610.c
+++ b/drivers/gpio/gpio-vf610.c
@@ -198,22 +198,16 @@ static int vf610_gpio_probe(struct device *dev)
port->gpio_base = IOMEM(iores->start);
}
+ port->chip.dev = dev;
port->chip.ops = &vf610_gpio_ops;
if (dev->id < 0) {
port->chip.base = of_alias_get_id(dev->of_node, "gpio");
- if (port->chip.base < 0) {
- ret = port->chip.base;
- dev_dbg(dev, "Failed to get GPIO alias\n");
- goto free_port;
- }
+ if (port->chip.base >= 0)
+ port->chip.base *= VF610_GPIO_PER_PORT;
} else {
- port->chip.base = dev->id;
+ port->chip.base = dev->id * VF610_GPIO_PER_PORT;
}
-
- port->chip.base *= VF610_GPIO_PER_PORT;
- port->chip.dev = dev;
-
return gpiochip_add(&port->chip);
free_port:
diff --git a/drivers/spi/imx_spi.c b/drivers/spi/imx_spi.c
index bfb4b413ebab..941a164b7631 100644
--- a/drivers/spi/imx_spi.c
+++ b/drivers/spi/imx_spi.c
@@ -603,10 +603,7 @@ static int imx_spi_probe(struct device *dev)
master->num_chipselect = pdata->num_chipselect;
imx->cs_array = pdata->chipselect;
} else if (IS_ENABLED(CONFIG_OFDEVICE)) {
- ret = of_alias_get_id(dev->of_node, "spi");
- if (ret < 0)
- goto err_free;
- master->bus_num = ret;
+ master->bus_num = of_alias_get_id(dev->of_node, "spi");;
imx_spi_dt_probe(imx);
}
diff --git a/drivers/usb/imx/imx-usb-phy.c b/drivers/usb/imx/imx-usb-phy.c
index 3dcaa1e1f438..7f9f5bebdee0 100644
--- a/drivers/usb/imx/imx-usb-phy.c
+++ b/drivers/usb/imx/imx-usb-phy.c
@@ -154,7 +154,7 @@ static int imx_usbphy_probe(struct device *dev)
ret = of_alias_get_id(np, "usbphy");
if (ret < 0) {
- dev_dbg(dev, "failed to get alias id, errno %d\n", ret);
+ ret = dev_err_probe(dev, -ENOENT, "failed to get alias id\n");
goto err_free;
}
imxphy->port_id = ret;
diff --git a/drivers/usb/musb/phy-am335x.c b/drivers/usb/musb/phy-am335x.c
index f2a12182e021..d3ebbef302a1 100644
--- a/drivers/usb/musb/phy-am335x.c
+++ b/drivers/usb/musb/phy-am335x.c
@@ -45,8 +45,7 @@ static int am335x_phy_probe(struct device *dev)
am_usbphy->id = of_alias_get_id(dev->of_node, "phy");
if (am_usbphy->id < 0) {
- dev_err(dev, "Missing PHY id: %d\n", am_usbphy->id);
- ret = am_usbphy->id;
+ ret = dev_err_probe(dev, -ENOENT, "Missing PHY id\n");
goto err_release;
}
--
2.47.3
next prev parent reply other threads:[~2026-03-13 13:28 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-13 13:24 [PATCH v2025.09.y 00/58] Backports for v2025.09.1 Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 01/58] clk: clkdev: fix format security Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 02/58] scripts: imx: fix string in further auth block Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 03/58] scripts: imx-image: support DCD_WRITE on closed dev Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 04/58] mci: am654-sdhci: Wait for transfer complete interrupt with MMC_RSP_BUSY cmd Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 05/58] video: simplefb-client: switch to dev_get_resource Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 06/58] MIPS: qemu-malta_defconfig: Use largest possible relocation table Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 07/58] firmware: handle firmware files being links correctly Ahmad Fatoum
2026-03-13 13:24 ` Ahmad Fatoum [this message]
2026-03-13 13:24 ` [PATCH v2025.09.y 09/58] ARM: socfpga: arria10-reset-manager: release UART0 Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 10/58] bug: add support for CONFIG_DEBUG_BUGVERBOSE Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 11/58] driver: implement get_free_deviceid_from() Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 12/58] sandbox: fix make dependency for sandbox Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 13/58] gpio: Fix GPIOD_ASIS flag Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 14/58] i.MX: HAB: fix field return unlock fuse uid Ahmad Fatoum
2026-03-13 13:24 ` [PATCH v2025.09.y 15/58] ARM: cpu: common: skip R_ARM_NONE relocations Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 16/58] mmc: resolve conflict between MMC_CAP_NONREMOVABLE and MMC_CAP_1_8V_DDR Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 17/58] virtio: ring: fix stale data in queue after reset Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 18/58] scripts: Makefile.lib: suppress graph_port warnings for overlays Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 19/58] ARM: Rockchip: rk3576-prtpuk: suppress video graph warning Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 20/58] kbuild: fold rmdirs into rmfiles Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 21/58] mtd: nand: mxc_nand: use clk_get_optional for clock handling Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 22/58] FIT: fix double free issue with >1 reference count Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 23/58] net: phy: mdio_bus: fix freeing of cdev name before devfs_remove Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 24/58] bootm: fix bootm override saving/restoring Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 25/58] common: tlv: Correct eth address list fixup Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 26/58] common: tlv: fix link error when CONFIG_NET is disabled Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 27/58] include: array_size.h: make header self-contained Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 28/58] RISC-V: dts: fix generation of dtbs-list Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 29/58] of: overlay: propagate error unflattening DTBO Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 30/58] efi: fix potential NULL dereference Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 31/58] FIT: fix potential underflow of stack array Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 32/58] of: fdt: fix double free in fdt_ensure_space Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 33/58] of: overlay: initialize ret to fix garbage return value Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 34/58] firmware: xilinx-fpga: fix double free in probe error path Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 35/58] driver: fix missing va_end in dev_add_alias " Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 36/58] net: eth: avoid overlapping memcpy in eth_set_ethaddr Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 37/58] pmdomain: fix dereference before NULL check in genpd_get_from_provider Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 38/58] net: phy: add NULL check for phy driver in page accessors Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 39/58] open: add missing mode argument to O_CREAT calls Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 40/58] hush: add NULL check for gl_pathv after do_glob_in_argv Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 41/58] i2c: rk3x: fix NULL pointer dereference on repeated NACK Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 42/58] mci: imx-esdhc: remove misleading NULL check for cmd pointer Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 43/58] mci: spi: initialize r1 to fix garbage return value Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 44/58] virtio: fix variable shadowing in virtqueue_add_sgs input scatter loop Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 45/58] video: mode-helpers: preserve sync polarity in fb_videomode conversion Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 46/58] ARM: rockchip: dmc: use define instead of hardcoded value Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 47/58] ARM: rockchip: atf: Fix memend Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 48/58] regulator: fix handling of off_on_delay Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 49/58] regulator: fixed: handle startup-delay-us property Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 50/58] scripts: include: break dependency of list.h on kernel.h Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 51/58] Makefile: include scripts/ in compile_commands.json Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 52/58] jwt: fix buffer overflow and double-free in jwt_part_parse Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 53/58] of: fdt: fix heap-buffer-overflow in fdt_machine_is_compatible Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 54/58] powerpc: fix initjmp storing function pointer at wrong offset Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 55/58] net: r8169: drain RX descriptor ring Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 56/58] of: fdt: refuse / in property and node names Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 57/58] FIT: reconstruct hashed-nodes property during verification Ahmad Fatoum
2026-03-13 13:25 ` [PATCH v2025.09.y 58/58] scripts: fix build failure with glibc 2.43 Ahmad Fatoum
2026-03-13 14:56 ` [PATCH v2025.09.y 00/58] Backports for v2025.09.1 Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260313132631.2257573-9-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox