driver core: platform: Propagate error from insert_resource()
PATCH 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.
--- drivers/base/platform.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/base/platform.c +1 -2
@@ -438,9 +438,8 @@ int platform_device_add(struct platform_device *pdev) p = &ioport_resource; } -if (p &&insert_resource (p, r)) { +if (p && (ret =insert_resource (p, r))) {dev_err (&pdev->dev,"failed to claim resource %d: %pR\n" , i, r); - ret = -EBUSY ; goto failed; } }
Signature · 1 line
2.20.1
Rafael J. Wysocki
maintainerQuoted 14 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.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/base/platform.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/base/platform.c +0
-0
drivers/base/platform.c int platform_device_add(struct platform_device *pdev) · line 441
Quoted 5 lines
drivers/base/platform.c +1
-1@@ -438,9 +438,8 @@ int platform_device_add(struct platform_device *pdev) p = &ioport_resource; } -if (p &&insert_resource (p, r)) { +if (p && (ret =insert_resource (p, r))) {
I would put the assignment here.
Quoted 8 lines
drivers/base/platform.c +0
-2dev_err (&pdev->dev,"failed to claim resource %d: %pR\n" , i, r); - ret = -EBUSY ; goto failed; } } --2.20.1
Quoted 15 lines · Rafael J. Wysocki
Review
Quoted 6 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 diff) +1
-1- if (p && insert_resource(p, r)) { + if (p && (ret = insert_resource(p, r))) {I would put the assignment here.
Quoted 4 lines
dev_err(&pdev->dev, "failed to claim resource %d: %pR\n", i, r); - ret = -EBUSY; goto failed; }
Something like this?
drivers/base/platform.c +6 -4
@@ -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 · 2 lines
With Best Regards, Andy Shevchenko
Rafael J. Wysocki
maintainerQuoted 11 lines · Andy Shevchenko
Quoted 9 lines · Rafael J. Wysocki
Quoted 6 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 diff) +1
-1- if (p && insert_resource(p, r)) { + if (p && (ret = insert_resource(p, r))) {
Quoted 8 lines
Quoted 6 lines
I would put the assignment here.
Quoted 4 lines
dev_err(&pdev->dev, "failed to claim resource %d: %pR\n", i, r); - ret = -EBUSY; goto failed; }Something like this?
Yes.
Quoted 27 lines
drivers/base/platform.c +6
-5@@ -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; + } } } --With Best Regards,
Andy Shevchenko