Skip to contentSkip to conversation

pinctrl: rockchip: Check the error of the pmu syscon lookup

PATCH In review Anton Protopopov 2 participants 2 messages Dec 1

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pinctrl: rockchip: Check the error of the pmu syscon lookup

The syscon_regmap_lookup_by_phandle_optional() function returns NULL only when the property is missing (-ENODEV). On other errors it returns an error pointer. Before commit dbd2317d7b9f ("pinctrl:
rockchip: Add rk3506 pinctrl support") the probe returned the error of the "rockchip,pmu" lookup. Now it stores the error pointer in info->regmap_pmu. The pin configuration code then uses an error pointer as a regmap, which leads to an oops.

The lookup may fail with a correct device tree too: it returns -EPROBE_DEFER when the hwspinlock of the syscon or the driver which registers its regmap is not probed yet. Return the error from the probe, so that it is retried.

Fixes dbd2317d7b9f ("pinctrl: rockchip: Add rk3506 pinctrl support")

---

It's one of three related changes, but for different trees.
See https://lore.kernel.org/linux-pci/[email protected]/

This is based on the for-next branch of
git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git
and applies to its fixes branch too.

 drivers/pinctrl/pinctrl-rockchip.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/pinctrl/pinctrl-rockchip.c +3 -0
index cad602fa41ae..76e6ce2d52bc 100644
@@ -5022,6 +5022,9 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev)
 
 	/* try to find the optional reference to the pmu syscon */
 	info->regmap_pmu = syscon_regmap_lookup_by_phandle_optional(np, "rockchip,pmu");
+	if (IS_ERR(info->regmap_pmu))
+		return dev_err_probe(dev, PTR_ERR(info->regmap_pmu),
+				     "failed to look up pmu syscon\n");
 
 	if (ctrl->type == RK3308) {
 		ret = rk3308_soc_data_init(info);

base-commit: 948b743d6ce070e3d6a31806b8aab4f151e69178

maintainer Reviewed-by on v1 1/1
#1 lore raw

Am Dienstag, 1. Dezember 2026, 12:33:49 Mitteleuropäische Normalzeit schrieb Anton Protopopov:

Quoted 8 lines

The syscon_regmap_lookup_by_phandle_optional() function returns NULL only when the property is missing (-ENODEV). On other errors it returns an error pointer. Before commit dbd2317d7b9f ("pinctrl:
rockchip: Add rk3506 pinctrl support") the probe returned the error of the "rockchip,pmu" lookup. Now it stores the error pointer in info->regmap_pmu. The pin configuration code then uses an error pointer as a regmap, which leads to an oops.

Quoted 8 lines

The lookup may fail with a correct device tree too: it returns -EPROBE_DEFER when the hwspinlock of the syscon or the driver which registers its regmap is not probed yet. Return the error from the probe, so that it is retried.

Fixes dbd2317d7b9f ("pinctrl: rockchip: Add rk3506 pinctrl support")

Looked up the behaviour of syscon_regmap_lookup_by_phandle_optional(), so for the change itself:

(had a bit of fun, remembering that the 2nd syscon handling was removed by commit 9884c330dd80 ("pinctrl: rockchip: Fix RK3506 pinctrl support") )

Thanks
Heiko