Skip to contentSkip to conversation

driver core: platform: Respect return code of platform_device_register_full()

PATCH In review Andy Shevchenko 3 participants 3 messages Dec 3, 2018 – Dec 6, 2018 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 driver core: platform: Respect return code of platform_device_register_full()

The platform_device_register_full() might return an error pointer. If we instantiate platform device which is optional we may simplify the routine at removal stage by simply calling platform_device_unregister(). For now it requires to check parameter for being an error pointer in each caller.

To make users' life easier, check for an error pointer inside driver core.

---
- rebase on top of linux-next since the conflicting patch has been applied there

 drivers/base/platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/base/platform.c +2 -2
index 0fb5f140f1b0..2c36bf490944 100644
@@ -234,7 +234,7 @@ struct platform_object {
  */
 void platform_device_put(struct platform_device *pdev)
 {
-	if (pdev)
+	if (!IS_ERR_OR_NULL(pdev))
 		put_device(&pdev->dev);
 }
 EXPORT_SYMBOL_GPL(platform_device_put);
@@ -447,7 +447,7 @@ void platform_device_del(struct platform_device *pdev)
 {
 	int i;
 
-	if (pdev) {
+	if (!IS_ERR_OR_NULL(pdev)) {
 		device_del(&pdev->dev);
 
 		if (pdev->id_auto) {
Signature · 1 line
2.19.2
#1 lore raw
Quoted 11 lines · Andy Shevchenko

The platform_device_register_full() might return an error pointer. If we instantiate platform device which is optional we may simplify the routine at removal stage by simply calling platform_device_unregister(). For now it requires to check parameter for being an error pointer in each caller.

To make users' life easier, check for an error pointer inside driver core.

---
- rebase on top of linux-next since the conflicting patch has been applied there

What conflicting patch? This now doesn't apply to my tree.

Let me fix it up by hand...

#2 lore raw
Quoted 7 lines · Greg Kroah-Hartman
Quoted 5 lines · Andy Shevchenko

The platform_device_register_full() might return an error pointer. If we instantiate platform device which is optional we may simplify the routine at removal stage by simply calling platform_device_unregister(). For now it requires to check parameter for being an error pointer in each caller.

Quoted 8 lines
Quoted 6 lines

To make users' life easier, check for an error pointer inside driver core.

---
- rebase on top of linux-next since the conflicting patch has been applied there

What conflicting patch? This now doesn't apply to my tree.

One patch from Heikki had been applied earlier, I rebased and sent v2 at the same day as this one.

Quoted 3 lines

Let me fix it up by hand...

Signature · 2 lines
With Best Regards,
Andy Shevchenko