diff mbox series

[v4,04/15] drivers/firmware/sdei: Avoid nested statements in sdei_init()

Message ID 20200730014531.310465-5-gshan@redhat.com (mailing list archive)
State New, archived
Headers show
Series Refactor SDEI client driver | expand

Commit Message

Gavin Shan July 30, 2020, 1:45 a.m. UTC
In sdei_init(), the nested statements can be avoided by bailing
on error from platform_driver_register() or absent ACPI SDEI table.
With it, the code looks a bit more readable.

Signed-off-by: Gavin Shan <gshan@redhat.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/firmware/arm_sdei.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

Comments

James Morse Sept. 18, 2020, 4:11 p.m. UTC | #1
Hi Gavin,

On 30/07/2020 02:45, Gavin Shan wrote:
> In sdei_init(), the nested statements can be avoided by bailing
> on error from platform_driver_register() or absent ACPI SDEI table.
> With it, the code looks a bit more readable.

This is how the code ended up after the DT pattern was fixed out of existence.

Thanks for the cleanup.
Reviewed-by: James Morse <james.morse@arm.com>


Thanks,

James
diff mbox series

Patch

diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c
index 86ab878d1198..c9f2bedfb6b5 100644
--- a/drivers/firmware/arm_sdei.c
+++ b/drivers/firmware/arm_sdei.c
@@ -1081,17 +1081,18 @@  static bool __init sdei_present_acpi(void)
 
 static int __init sdei_init(void)
 {
-	int ret = platform_driver_register(&sdei_driver);
-
-	if (!ret && sdei_present_acpi()) {
-		struct platform_device *pdev;
-
-		pdev = platform_device_register_simple(sdei_driver.driver.name,
-						       0, NULL, 0);
-		if (IS_ERR(pdev))
-			pr_info("Failed to register ACPI:SDEI platform device %ld\n",
-				PTR_ERR(pdev));
-	}
+	struct platform_device *pdev;
+	int ret;
+
+	ret = platform_driver_register(&sdei_driver);
+	if (ret || !sdei_present_acpi())
+		return ret;
+
+	pdev = platform_device_register_simple(sdei_driver.driver.name,
+					       0, NULL, 0);
+	if (IS_ERR(pdev))
+		pr_info("Failed to register ACPI:SDEI platform device %ld\n",
+			PTR_ERR(pdev));
 
 	return ret;
 }