[PATCH] of: platform: early exit on error
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Jul 1 00:38:22 PDT 2024
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 at pengutronix.de>
---
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
More information about the barebox
mailing list