Skip to contentSkip to conversation

ACPI: SBS: Simplify the driver init code

PATCH New Hanjun Guo 1 participant 2 messages Nov 13, 2020 ACPI

lore
Share & tools
lore

Hanjun Guo

author
#0 lore raw

PATCH 1/2 ACPI: SBS: Simplify the driver init code

acpi_bus_register_driver() will check acpi_disable and return -ENODEV, so the acpi_disable check outside the acpi_bus_register_driver() is duplicated, can be removed.

Also we can just return from acpi_bus_register_driver() then we can simplify the code further.

---
 drivers/acpi/sbs.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/acpi/sbs.c +1 -10
index e6d9f4d..cbd1af7 100644
@@ -714,16 +714,7 @@ static int acpi_sbs_resume(struct device *dev)
 
 static int __init acpi_sbs_init(void)
 {
-	int result = 0;
-
-	if (acpi_disabled)
-		return -ENODEV;
-
-	result = acpi_bus_register_driver(&acpi_sbs_driver);
-	if (result < 0)
-		return -ENODEV;
-
-	return 0;
+	return acpi_bus_register_driver(&acpi_sbs_driver);
 }
 
 static void __exit acpi_sbs_exit(void)
Signature · 1 line
1.7.12.4
author
#1 lore raw

PATCH 2/2 ACPI: SBS: Simplify the code using module_acpi_driver()

Using the module_acpi_driver() to simplify the code.

---
 drivers/acpi/sbs.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/acpi/sbs.c +1 -14
index cbd1af7..3b0b6dd 100644
@@ -711,17 +711,4 @@ static int acpi_sbs_resume(struct device *dev)
 		},
 	.drv.pm = &acpi_sbs_pm,
 };
-
-static int __init acpi_sbs_init(void)
-{
-	return acpi_bus_register_driver(&acpi_sbs_driver);
-}
-
-static void __exit acpi_sbs_exit(void)
-{
-	acpi_bus_unregister_driver(&acpi_sbs_driver);
-	return;
-}
-
-module_init(acpi_sbs_init);
-module_exit(acpi_sbs_exit);
+module_acpi_driver(acpi_sbs_driver);
Signature · 1 line
1.7.12.4