[PATCH] of: platform: early exit on error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This introduces no functional change, but aligns us with the coding
style, where early exits are preferred and the final return is the
successful one.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 drivers/of/platform.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 918607a51883..7e086e9488e6 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -231,15 +231,16 @@ struct device *of_platform_device_create(struct device_node *np,
 	np->dev = dev;
 
 	ret = platform_device_register(dev);
-	if (!ret)
-		return dev;
+	if (ret) {
+		np->dev = NULL;
+		free_device(dev);
+		if (num_reg)
+			free(res);
+		return NULL;
+	}
 
-	np->dev = NULL;
 
-	free_device(dev);
-	if (num_reg)
-		free(res);
-	return NULL;
+	return dev;
 }
 
 struct driver dummy_driver = {
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux