Skip to contentSkip to conversation

Gracefully handle disabled ACPI and a lack of procfs.

PATCH New Matthew W. S. Bell 1 participant 1 message Feb 1, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Gracefully handle disabled ACPI and a lack of procfs.

For every ACPI module, explicitly check acpi_disabled on load and print an
appropriate error message if set.

Also, add conditional macros around procfs code in init functions.

---
 drivers/acpi/acpi_memhotplug.c |    6 ++++--
 drivers/acpi/acpi_pad.c        |    5 +++++
 drivers/acpi/button.c          |    9 +++++++++
 drivers/acpi/container.c       |    5 +++++
 drivers/acpi/fan.c             |    6 ++++++
 drivers/acpi/pci_slot.c        |    7 ++++++-
 drivers/acpi/sbshc.c           |    5 +++++
 drivers/acpi/thermal.c         |   10 ++++++++++
 drivers/acpi/video.c           |    9 +++++++++
 9 files changed, 59 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/drivers/acpi/acpi_memhotplug.c
index 28ccdbc..1477243 100644

drivers/acpi/acpi_memhotplug.c +4 -2
@@ -529,9 +529,12 @@ static int __init acpi_memory_device_init(void)
 	int result;
 	acpi_status status;
 
+	if (acpi_disabled) {
+		printk(KERN_ERR AE_INFO ": ACPI is disabled.\n");
+		return -ENODEV;
+	}
 
 	result = acpi_bus_register_driver(&acpi_memory_device_driver);
-
 	if (result < 0)
 		return -ENODEV;
 
@@ -539,7 +542,6 @@ static int __init acpi_memory_device_init(void)
 				     ACPI_UINT32_MAX,
 				     acpi_memory_register_notify_handler,
 				     NULL, NULL);
-
 	if (ACPI_FAILURE(status)) {
 		ACPI_EXCEPTION((AE_INFO, status, "walk_namespace failed"));
 		acpi_bus_unregister_driver(&acpi_memory_device_driver);
drivers/acpi/acpi_pad.c +5 -0
index 0d2cdb8..e53cb6b 100644
@@ -495,6 +495,11 @@ static struct acpi_driver acpi_pad_driver = {
 
 static int __init acpi_pad_init(void)
 {
+	if (acpi_disabled) {
+		printk(KERN_ERR AE_INFO ": ACPI is disabled.\n");
+		return -ENODEV;
+	}
+
 	power_saving_mwait_init();
 	if (power_saving_mwait_eax == 0)
 		return -EINVAL;
drivers/acpi/button.c +9 -0
index 8a95e83..a5a6f84 100644
@@ -456,13 +456,22 @@ static int __init acpi_button_init(void)
 {
 	int result;
 
+	if (acpi_disabled) {
+		printk(KERN_ERR AE_INFO ": ACPI is disabled.\n");
+		return -ENODEV;
+	}
+
+#ifdef CONFIG_ACPI_PROCFS
 	acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir);
 	if (!acpi_button_dir)
 		return -ENODEV;
+#endif
 
 	result = acpi_bus_register_driver(&acpi_button_driver);
 	if (result < 0) {
+#ifdef CONFIG_ACPI_PROCFS
 		remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
+#endif
 		return -ENODEV;
 	}
 
drivers/acpi/container.c +5 -0
index 642bb30..46ae7df 100644
@@ -249,6 +249,11 @@ static int __init acpi_container_init(void)
 	int result = 0;
 	int action = INSTALL_NOTIFY_HANDLER;
 
+	if (acpi_disabled) {
+		printk(KERN_ERR AE_INFO ": ACPI is disabled.\n");
+		return -ENODEV;
+	}
+
 	result = acpi_bus_register_driver(&acpi_container_driver);
 	if (result < 0) {
 		return (result);
drivers/acpi/fan.c +6 -0
index f419849..52f6419 100644
@@ -347,6 +347,10 @@ static int __init acpi_fan_init(void)
 {
 	int result = 0;
 
+	if (acpi_disabled) {
+		printk(KERN_ERR AE_INFO ": ACPI is disabled.\n");
+		return -ENODEV;
+	}
 
 #ifdef CONFIG_ACPI_PROCFS
 	acpi_fan_dir = proc_mkdir(ACPI_FAN_CLASS, acpi_root_dir);
@@ -356,7 +360,9 @@ static int __init acpi_fan_init(void)
 
 	result = acpi_bus_register_driver(&acpi_fan_driver);
 	if (result < 0) {
+#ifdef CONFIG_ACPI_PROCFS
 		remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir);
+#endif
 		return -ENODEV;
 	}
 
drivers/acpi/pci_slot.c +0 -0
index 45da2ba..91de70f 100644
@@ -355,7 +355,12 @@ static struct dmi_system_id

acpi_pci_slot_dmi_table[] __initdata = {

static int __init
acpi_pci_slot_init(void)
-{
+{
+ if (acpi_disabled) {
+ printk(KERN_ERR AE_INFO ": ACPI is disabled.\n");
+ return -ENODEV;
+ }
+
dmi_check_system(acpi_pci_slot_dmi_table); acpi_pci_register_driver(&acpi_pci_slot_driver); return 0;

drivers/acpi/sbshc.c +5 -0
index d933980..f00780e 100644
@@ -312,6 +312,11 @@ static int __init acpi_smb_hc_init(void)
 {
 	int result;
 
+	if (acpi_disabled) {
+		printk(KERN_ERR AE_INFO ": ACPI is disabled.\n");
+		return -ENODEV;
+	}
+
 	result = acpi_bus_register_driver(&acpi_smb_hc_driver);
 	if (result < 0)
 		return -ENODEV;
drivers/acpi/thermal.c +10 -0
index 65f6781..cdbb827 100644
@@ -1534,19 +1534,29 @@ static int __init acpi_thermal_init(void)
 {
 	int result = 0;
 
+	if (acpi_disabled) {
+		printk(KERN_ERR AE_INFO ": ACPI is disabled.\n");
+		return -ENODEV;
+	}
+
 	dmi_check_system(thermal_dmi_table);
 
 	if (off) {
 		printk(KERN_NOTICE "ACPI: thermal control disabled\n");
 		return -ENODEV;
 	}
+
+#ifdef CONFIG_ACPI_PROCFS
 	acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir);
 	if (!acpi_thermal_dir)
 		return -ENODEV;
+#endif
 
 	result = acpi_bus_register_driver(&acpi_thermal_driver);
 	if (result < 0) {
+#ifdef CONFIG_ACPI_PROCFS
 		remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
+#endif
 		return -ENODEV;
 	}
 
drivers/acpi/video.c +9 -0
index 05dff63..045e634 100644
@@ -2379,13 +2379,17 @@ int acpi_video_register(void)
 		return 0;
 	}
 
+#ifdef CONFIG_ACPI_PROCFS
 	acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir);
 	if (!acpi_video_dir)
 		return -ENODEV;
+#endif
 
 	result = acpi_bus_register_driver(&acpi_video_bus);
 	if (result < 0) {
+#ifdef CONFIG_ACPI_PROCFS
 		remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
+#endif
 		return -ENODEV;
 	}
 
@@ -2427,6 +2431,11 @@ EXPORT_SYMBOL(acpi_video_unregister);
 
 static int __init acpi_video_init(void)
 {
+	if (acpi_disabled) {
+		printk(KERN_ERR AE_INFO ": ACPI is disabled.\n");
+		return -ENODEV;
+	}
+
 	dmi_check_system(video_dmi_table);
 
 	if (intel_opregion_present())
Signature · 1 line
1.6.5