* [PATCH] of: platform: early exit on error
@ 2024-07-01 7:38 Ahmad Fatoum
2024-07-01 9:31 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2024-07-01 7:38 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
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@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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] of: platform: early exit on error
2024-07-01 7:38 [PATCH] of: platform: early exit on error Ahmad Fatoum
@ 2024-07-01 9:31 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-07-01 9:31 UTC (permalink / raw)
To: barebox, Ahmad Fatoum
On Mon, 01 Jul 2024 09:38:22 +0200, Ahmad Fatoum wrote:
> 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.
>
>
Applied, thanks!
[1/1] of: platform: early exit on error
https://git.pengutronix.de/cgit/barebox/commit/?id=8318bef6bf1b (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-01 9:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-01 7:38 [PATCH] of: platform: early exit on error Ahmad Fatoum
2024-07-01 9:31 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox