diff mbox

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

Message ID 1265058969.3824.10.camel@ibis.bells (mailing list archive)
State New, archived
Headers show

Commit Message

Matthew W. S. Bell Feb. 1, 2010, 9:16 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/acpi/acpi_memhotplug.c
b/drivers/acpi/acpi_memhotplug.c
index 28ccdbc..1477243 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -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);
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index 0d2cdb8..e53cb6b 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -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;
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 8a95e83..a5a6f84 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -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;
 	}
 
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index 642bb30..46ae7df 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -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);
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index f419849..52f6419 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -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;
 	}
 
diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c
index 45da2ba..91de70f 100644
--- a/drivers/acpi/pci_slot.c
+++ b/drivers/acpi/pci_slot.c
@@ -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;
diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c
index d933980..f00780e 100644
--- a/drivers/acpi/sbshc.c
+++ b/drivers/acpi/sbshc.c
@@ -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;
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 65f6781..cdbb827 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -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;
 	}
 
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 05dff63..045e634 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -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())