public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: "Matthew W. S. Bell" <matthew@bells23.org.uk>
To: linux-acpi@vger.kernel.org
Subject: [PATCH 1/2] Gracefully handle disabled ACPI and a lack of procfs.
Date: Mon, 01 Feb 2010 21:16:09 +0000	[thread overview]
Message-ID: <1265058969.3824.10.camel@ibis.bells> (raw)

[-- Attachment #1: Type: text/plain, Size: 6536 bytes --]

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(-)

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())
-- 
1.6.5


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

                 reply	other threads:[~2010-02-01 21:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1265058969.3824.10.camel@ibis.bells \
    --to=matthew@bells23.org.uk \
    --cc=linux-acpi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox