[PATCH 04/14] drivers/firmware/sdei: Rework sdei_init()
Gavin Shan
gshan at redhat.com
Mon Jul 6 01:47:22 EDT 2020
This reworks sdei_init()
* The function follows the steps in sequence: check ACPI existence,
register platform device, register platform driver.
* The corresponding error numbers are returned in failing paths.
* The platform device is deleted if the driver can't be registered.
Signed-off-by: Gavin Shan <gshan at redhat.com>
---
drivers/firmware/arm_sdei.c | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c
index 35a319e7e1e6..7e7b26b1f91b 100644
--- a/drivers/firmware/arm_sdei.c
+++ b/drivers/firmware/arm_sdei.c
@@ -1058,7 +1058,7 @@ static bool __init sdei_present_acpi(void)
acpi_status status;
struct acpi_table_header *sdei_table_header;
- if (acpi_disabled)
+ if (!IS_ENABLED(CONFIG_ACPI) || acpi_disabled)
return false;
status = acpi_get_table(ACPI_SIG_SDEI, 0, &sdei_table_header);
@@ -1077,19 +1077,27 @@ static bool __init sdei_present_acpi(void)
static int __init sdei_init(void)
{
- int ret = platform_driver_register(&sdei_driver);
+ struct platform_device *pdev;
+ int ret;
- if (!ret && sdei_present_acpi()) {
- struct platform_device *pdev;
+ if (!sdei_present_acpi())
+ return -EPERM;
- 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));
+ 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 -ENOMEM;
}
- return ret;
+ ret = platform_driver_register(&sdei_driver);
+ if (ret) {
+ platform_device_del(pdev);
+ return ret;
+ }
+
+ return 0;
}
/*
--
2.23.0
More information about the linux-arm-kernel
mailing list