public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bjorn.helgaas@hp.com>
To: Len Brown <lenb@kernel.org>
Cc: Tony Vroon <tony@linx.net>, Alex Chiang <achiang@hp.com>,
	linux-acpi@vger.kernel.org,
	Carlos Corbacho <carlos@strangeworlds.co.uk>,
	Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
	Jonathan Woithe <jwoithe@physics.adelaide.edu.au>,
	Zhao Yakui <yakui.zhao@intel.com>,
	Mattia Dongili <malattia@linux.it>,
	Harald Welte <laforge@gnumonks.org>,
	Venki Pallipadi <venkatesh.pallipadi@intel.com>,
	Alexey Starikovskiy <alexey.y.starikovskiy@linux.intel.com>,
	Zhang Rui <rui.zhang@intel.com>, Matthew Garrett <mjg@redhat.com>
Subject: [PATCH 09/10] sony-laptop: use .notify method instead of installing handler directly
Date: Mon, 30 Mar 2009 11:48:54 -0600	[thread overview]
Message-ID: <20090330174854.20905.68935.stgit@bob.kio> (raw)
In-Reply-To: <20090330174646.20905.18465.stgit@bob.kio>

This patch adds a .notify() method.  The presence of .notify() causes
Linux/ACPI to manage event handlers and notify handlers on our behalf,
so we don't have to install and remove them ourselves.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
CC: Mattia Dongili <malattia@linux.it>
---
 drivers/platform/x86/sony-laptop.c |   32 +++++---------------------------
 1 files changed, 5 insertions(+), 27 deletions(-)

diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index bc8996c..be98b1f 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -895,7 +895,7 @@ static const struct dmi_system_id sony_nc_ids[] = {
 /*
  * ACPI callbacks
  */
-static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)
+static void sony_nc_notify(struct acpi_device *device, u32 event)
 {
 	struct sony_nc_event *evmap;
 	u32 ev = event;
@@ -913,8 +913,8 @@ static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)
 		 * TODO: we may want to do the same for the older GHKE -need
 		 *       dmi list- so this snippet may become one more callback.
 		 */
-		if (acpi_callsetfunc(handle, "SN07", 0x0202, &result) < 0)
-			dprintk("sony_acpi_notify, unable to decode event 0x%.2x\n", ev);
+		if (acpi_callsetfunc(sony_nc_acpi_handle, "SN07", 0x0202, &result) < 0)
+			dprintk("sony_nc_notify, unable to decode event 0x%.2x\n", ev);
 		else
 			ev = result & 0xFF;
 	}
@@ -927,7 +927,7 @@ static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)
 			}
 		}
 
-	dprintk("sony_acpi_notify, event: 0x%.2x\n", ev);
+	dprintk("sony_nc_notify, event: 0x%.2x\n", ev);
 	sony_laptop_report_input_event(ev);
 	acpi_bus_generate_proc_event(sony_nc_acpi_device, 1, ev);
 }
@@ -1032,15 +1032,6 @@ static int sony_nc_add(struct acpi_device *device)
 		goto outwalk;
 	}
 
-	status = acpi_install_notify_handler(sony_nc_acpi_handle,
-					     ACPI_DEVICE_NOTIFY,
-					     sony_acpi_notify, NULL);
-	if (ACPI_FAILURE(status)) {
-		printk(KERN_WARNING DRV_PFX "unable to install notify handler (%u)\n", status);
-		result = -ENODEV;
-		goto outinput;
-	}
-
 	if (acpi_video_backlight_support()) {
 		printk(KERN_INFO DRV_PFX "brightness ignored, must be "
 		       "controlled by ACPI video driver\n");
@@ -1121,13 +1112,6 @@ static int sony_nc_add(struct acpi_device *device)
 	if (sony_backlight_device)
 		backlight_device_unregister(sony_backlight_device);
 
-	status = acpi_remove_notify_handler(sony_nc_acpi_handle,
-					    ACPI_DEVICE_NOTIFY,
-					    sony_acpi_notify);
-	if (ACPI_FAILURE(status))
-		printk(KERN_WARNING DRV_PFX "unable to remove notify handler\n");
-
-      outinput:
 	sony_laptop_remove_input();
 
       outwalk:
@@ -1136,7 +1120,6 @@ static int sony_nc_add(struct acpi_device *device)
 
 static int sony_nc_remove(struct acpi_device *device, int type)
 {
-	acpi_status status;
 	struct sony_nc_value *item;
 
 	if (sony_backlight_device)
@@ -1144,12 +1127,6 @@ static int sony_nc_remove(struct acpi_device *device, int type)
 
 	sony_nc_acpi_device = NULL;
 
-	status = acpi_remove_notify_handler(sony_nc_acpi_handle,
-					    ACPI_DEVICE_NOTIFY,
-					    sony_acpi_notify);
-	if (ACPI_FAILURE(status))
-		printk(KERN_WARNING DRV_PFX "unable to remove notify handler\n");
-
 	for (item = sony_nc_values; item->name; ++item) {
 		device_remove_file(&sony_pf_device->dev, &item->devattr);
 	}
@@ -1182,6 +1159,7 @@ static struct acpi_driver sony_nc_driver = {
 		.add = sony_nc_add,
 		.remove = sony_nc_remove,
 		.resume = sony_nc_resume,
+		.notify = sony_nc_notify,
 		},
 };
 


  parent reply	other threads:[~2009-03-30 17:48 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-30 17:48 [PATCH 00/10] ACPI: add device .notify methods Bjorn Helgaas
2009-03-30 17:48 ` [PATCH 01/10] ACPI: support acpi_device_ops " Bjorn Helgaas
2009-04-02 13:56   ` Thomas Renninger
2009-04-02 15:03     ` Bjorn Helgaas
2009-04-03  0:23       ` Yasunori Goto
2009-04-03  9:08         ` Thomas Renninger
2009-04-03 15:09         ` Bjorn Helgaas
2009-04-03 22:43           ` Yasunori Goto
2009-04-03 13:14       ` Thomas Renninger
2009-03-30 17:48 ` [PATCH 02/10] ACPI: button: use .notify method instead of installing handler directly Bjorn Helgaas
2009-03-30 17:48 ` [PATCH 03/10] ACPI: processor: " Bjorn Helgaas
2009-03-30 17:48 ` [PATCH 04/10] ACPI: thermal: " Bjorn Helgaas
2009-03-30 17:48 ` [PATCH 05/10] ACPI: video: " Bjorn Helgaas
2009-03-30 17:48 ` [PATCH 06/10] fujitsu-laptop: " Bjorn Helgaas
2009-03-31  6:45   ` [PATCH 06/10] fujitsu-laptop: use .notify method instead of Jonathan Woithe
2009-03-31 21:38   ` [PATCH 06/10] fujitsu-laptop: use .notify method instead of installing handler directly Tony Vroon
2009-03-31 22:09     ` Bjorn Helgaas
2009-03-31 22:09       ` Tony Vroon
2009-03-31 22:29   ` Jonathan Woithe
2009-03-30 17:48 ` [PATCH 07/10] fujitsu-laptop: use .notify method instead of installing hotkey " Bjorn Helgaas
2009-03-31 21:39   ` Tony Vroon
2009-03-31 22:30   ` [PATCH 07/10] fujitsu-laptop: use .notify method instead of installing " Jonathan Woithe
2009-03-30 17:48 ` [PATCH 08/10] panasonic-laptop: " Bjorn Helgaas
2009-03-30 17:48 ` Bjorn Helgaas [this message]
2009-03-31 13:46   ` [PATCH 09/10] sony-laptop: " Mattia Dongili
2009-03-31 22:58     ` Mattia Dongili
2009-03-30 17:48 ` [PATCH 10/10] ACPI: WMI: " Bjorn Helgaas

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=20090330174854.20905.68935.stgit@bob.kio \
    --to=bjorn.helgaas@hp.com \
    --cc=achiang@hp.com \
    --cc=alexey.y.starikovskiy@linux.intel.com \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=carlos@strangeworlds.co.uk \
    --cc=jwoithe@physics.adelaide.edu.au \
    --cc=laforge@gnumonks.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=malattia@linux.it \
    --cc=mjg@redhat.com \
    --cc=rui.zhang@intel.com \
    --cc=tony@linx.net \
    --cc=venkatesh.pallipadi@intel.com \
    --cc=yakui.zhao@intel.com \
    /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