Skip to contentSkip to conversation

ARM: drivers/amba: release the resource to allow for deferred probe

PATCH Superseded Dinh Nguyen 2 participants 2 messages Oct 2, 2019 Arm primecell bus support

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ARM: drivers/amba: release the resource to allow for deferred probe

With commit "79bdcb202a35 ARM: 8906/1: drivers/amba: add reset control to amba bus probe", the amba bus driver needs to be deferred probe because the reset driver is probed later. However with a deferred probe, the call to request_resource() in the driver returns -EBUSY. The reason is the driver has not released the resource from the previous probe attempt.

This patch fixes how we handle the condition of EPROBE_DEFER that is returned from getting the reset controls. For this condition, the patch will jump to err_release, which will release the resource.

Fixes 79bdcb202a35 ("ARM: 8906/1: drivers/amba: add reset control to

amba bus probe")

---
v2: release the resource when of_reset_control_array_get_optional_shared()
returns EPROBE_DEFER

---
 drivers/amba/bus.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/amba/bus.c +5 -2
index f39f075abff9..1109437815eb 100644
@@ -409,9 +409,12 @@ static int amba_device_try_add(struct amba_device *dev, struct resource *parent)
 		 */
 		rstc = of_reset_control_array_get_optional_shared(dev->dev.of_node);
 		if (IS_ERR(rstc)) {
-			if (PTR_ERR(rstc) != -EPROBE_DEFER)
+			ret = PTR_ERR(rstc);
+			if (ret == -EPROBE_DEFER)
+				goto err_release;
+			else
 				dev_err(&dev->dev, "Can't get amba reset!\n");
-			return PTR_ERR(rstc);
+			return ret;
 		}
 		reset_control_deassert(rstc);
 		reset_control_put(rstc);
Signature · 1 line
2.20.0
#1 lore raw
Quoted 26 lines · Dinh Nguyen

With commit "79bdcb202a35 ARM: 8906/1: drivers/amba: add reset control to amba bus probe", the amba bus driver needs to be deferred probe because the reset driver is probed later. However with a deferred probe, the call to request_resource() in the driver returns -EBUSY. The reason is the driver has not released the resource from the previous probe attempt.

This patch fixes how we handle the condition of EPROBE_DEFER that is returned from getting the reset controls. For this condition, the patch will jump to err_release, which will release the resource.

Fixes 79bdcb202a35 ("ARM: 8906/1: drivers/amba: add reset control to

amba bus probe")

---
v2: release the resource when of_reset_control_array_get_optional_shared()
returns EPROBE_DEFER

---
 drivers/amba/bus.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/amba/bus.c +0 -0
index f39f075abff9..1109437815eb 100644
@@ -409,9 +409,12 @@ static int amba_device_try_add(struct amba_device *dev, struct resource *parent)
 		 */

drivers/amba/bus.c static int amba_device_try_add(struct amba_device *dev, struct resource *parent) · line 417

Quoted 10 lines
drivers/amba/bus.c +5 -2
 		rstc = of_reset_control_array_get_optional_shared(dev->dev.of_node);
 		if (IS_ERR(rstc)) {
-			if (PTR_ERR(rstc) != -EPROBE_DEFER)
+			ret = PTR_ERR(rstc);
+			if (ret == -EPROBE_DEFER)
+				goto err_release;
+			else
 				dev_err(&dev->dev, "Can't get amba reset!\n");
-			return PTR_ERR(rstc);
+			return ret;

Still a negative.

Remember in the comments to the previous patch I talked about ioremap().

Please read the code that you are modifying and carefully consider what needs to happen at this site to properly clean up on failure.

Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up