mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@turbolabs.com>
To: andrew.grover@intel.com, linux-kernel@vger.kernel.org
Subject: [PATCH] ACPI cleanup
Date: Thu, 29 Nov 2001 02:23:18 -0700	[thread overview]
Message-ID: <20011129022318.A29249@lynx.no> (raw)

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/


                 reply	other threads:[~2001-11-29  9:23 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=20011129022318.A29249@lynx.no \
    --to=adilger@turbolabs.com \
    --cc=andrew.grover@intel.com \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®