Skip to contentSkip to conversation

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

PATCH Superseded Andy Shevchenko 1 participant 1 message Dec 3, 2018 Driver core

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 drivers/base/platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/base/platform.c +2 -2
index 41b91af95afb..e1ba610482c0 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_remove_properties(&pdev->dev);
 		device_del(&pdev->dev);
 
Signature · 1 line
2.19.2