Skip to contentSkip to conversation

driver core: platform: Propagate error from insert_resource()

PATCH In review Andy Shevchenko 2 participants 2 messages Apr 4, 2019 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 driver core: platform: Propagate error from insert_resource()

Since insert_resource() might return an error we don't need to shadow its error code and would safely propagate to the user.

---
- move an assignment to the separate line inside first branch (Rafael)

 drivers/base/platform.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/base/platform.c +6 -4
index dab0a5abc391..9cf9e2af9efd 100644
@@ -438,10 +438,12 @@ int platform_device_add(struct platform_device *pdev)
 				p = &ioport_resource;
 		}
 
-		if (p && insert_resource(p, r)) {
-			dev_err(&pdev->dev, "failed to claim resource %d: %pR\n", i, r);
-			ret = -EBUSY;
-			goto failed;
+		if (p) {
+			ret = insert_resource(p, r);
+			if (ret) {
+				dev_err(&pdev->dev, "failed to claim resource %d: %pR\n", i, r);
+				goto failed;
+			}
 		}
 	}
 
Signature · 1 line
2.20.1
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 5 lines · Andy Shevchenko

Since insert_resource() might return an error we don't need to shadow its error code and would safely propagate to the user.

Quoted 30 lines

---
- move an assignment to the separate line inside first branch (Rafael)

 drivers/base/platform.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/base/platform.c +6 -5
index dab0a5abc391..9cf9e2af9efd 100644
@@ -438,10 +438,12 @@ int platform_device_add(struct platform_device *pdev)
                                p = &ioport_resource;
                }
 
-               if (p && insert_resource(p, r)) {
-                       dev_err(&pdev->dev, "failed to claim resource %d: %pR\n", i, r);
-                       ret = -EBUSY;
-                       goto failed;
+               if (p) {
+                       ret = insert_resource(p, r);
+                       if (ret) {
+                               dev_err(&pdev->dev, "failed to claim resource %d: %pR\n", i, r);
+                               goto failed;
+                       }
                }
        }
 
--

2.20.1