mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ACPI cleanup
@ 2001-11-29  9:23 Andreas Dilger
  0 siblings, 0 replies; only message in thread
From: Andreas Dilger @ 2001-11-29  9:23 UTC (permalink / raw)
  To: andrew.grover, linux-kernel

Hello,
the following patch fixes the ACPI busmgr code to not leave straggling
files in /proc/acpi if it fails to initialize properly in bm_osl_init().

This was a problem I noticed with the 2.4.9 kernel that causes an oops,
which was "glossed over" by calling the acpi_subsystem_status() function
in later kernels.  This will see if the ACPI subsystem even exists,
but doesn't really solve the underlying problem - bm_initialize() can
fail, and if it does it doesn't remove the files it created in /proc.

A couple of other minor cleanups:
1) don't return AE_ERROR instead of a valid error return code to userspace.
2) call bm_terminate() after removing the /proc entries, so that it is not
   possible to open one of these files after the ACPI code has shut down
   (I don't know if this is actually a problem, but just to be safe).

It should apply cleanly to all current kernels.

Cheers, Andreas
======================= acpi-2.4.15-busmgr.diff ============================
diff -ru linux-2.4.15.orig/drivers/acpi/ospm/busmgr/bm_osl.c linux-2.4.15-aed/drivers/acpi/ospm/busmgr/bm_osl.c
--- linux-2.4.15.orig/drivers/acpi/ospm/busmgr/bm_osl.c	Thu Nov 15 13:07:16 2001
+++ linux-2.4.15-aed/drivers/acpi/ospm/busmgr/bm_osl.c	Thu Nov 29 00:03:26 2001
@@ -297,7 +297,7 @@
 int
 bm_osl_init(void)
 {
-	acpi_status		status = AE_OK;
+	acpi_status		status;
 
 	status = acpi_subsystem_status();
 	if (ACPI_FAILURE(status))
@@ -305,7 +305,14 @@
 
 	bm_proc_root = proc_mkdir(BM_PROC_ROOT, NULL);
 	if (!bm_proc_root) {
-		return(AE_ERROR);
+		return(-ENOMEM);
+	}
+
+	status = bm_initialize();
+	if (ACPI_FAILURE(status)) {
+		remove_proc_entry(BM_PROC_ROOT, NULL);
+		bm_proc_root = NULL;
+		return(-ENODEV);
 	}
 
 	bm_proc_event = create_proc_entry(BM_PROC_EVENT, S_IRUSR, bm_proc_root);
@@ -313,9 +320,7 @@
 		bm_proc_event->proc_fops = &proc_event_operations;
 	}
 
-	status = bm_initialize();
-
-	return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
+	return 0;
 }
 
 
@@ -328,8 +333,6 @@
 void
 bm_osl_cleanup(void)
 {
-	bm_terminate();
-
 	if (bm_proc_event) {
 		remove_proc_entry(BM_PROC_EVENT, bm_proc_root);
 		bm_proc_event = NULL;
@@ -339,6 +342,8 @@
 		remove_proc_entry(BM_PROC_ROOT, NULL);
 		bm_proc_root = NULL;
 	}
+
+	bm_terminate();
 
 	return;
 }
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-11-29  9:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-29  9:23 [PATCH] ACPI cleanup Andreas Dilger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®