X86 platform drivers
 help / color / mirror / Atom feed
From: Andy Ross <andy.ross@windriver.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Corentin Chary <corentincj@iksaif.net>,
	linux-input@vger.kernel.org,
	acpi4asus-user@lists.sourceforge.net,
	platform-driver-x86@vger.kernel.org
Subject: [PATCH 3/4] asus-laptop: Support pega_accel accelerometer driver
Date: Mon, 24 Jan 2011 14:48:07 -0800	[thread overview]
Message-ID: <1295909288-32650-4-git-send-email-andy.ross@windriver.com> (raw)
In-Reply-To: <1295909288-32650-1-git-send-email-andy.ross@windriver.com>

Add device detecton for the ACPI accelerometer interface on Pegatron
Lucid tablets.

Signed-off-by: Andy Ross <andy.ross@windriver.com>
---
 drivers/platform/x86/asus-laptop.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index b397a4c..75c84f8 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -261,6 +261,7 @@ struct asus_laptop {
 	bool have_rsts;
 	bool have_pega_lucid;
 	int lcd_state;
+	struct platform_device *pega_accel;
 
 	struct rfkill *gps_rfkill;
 
@@ -1631,6 +1632,19 @@ static int __devinit asus_acpi_init(struct asus_laptop *asus)
 	return result;
 }
 
+static void __devinit asus_pega_accel_init(struct asus_laptop *asus)
+{
+	/* Pegatron Lucid tablets expose their accelerometer through ACPI.
+	 * Check for XLR{X,Y,Z} methods */
+	if (acpi_check_handle(asus->handle, "XLRX", NULL) ||
+	    acpi_check_handle(asus->handle, "XLRY", NULL) ||
+	    acpi_check_handle(asus->handle, "XLRZ", NULL))
+		return;
+
+	asus->pega_accel = platform_device_register_simple("pega_accel", -1,
+							   NULL, 0);
+}
+
 static bool asus_device_present;
 
 static int __devinit asus_acpi_add(struct acpi_device *device)
@@ -1681,6 +1695,8 @@ static int __devinit asus_acpi_add(struct acpi_device *device)
 		goto fail_rfkill;
 
 	asus->have_pega_lucid = asus_check_pega_lucid(asus);
+	if (asus->have_pega_lucid)
+		asus_pega_accel_init(asus);
 
 	asus_device_present = true;
 	return 0;
@@ -1704,6 +1720,9 @@ static int asus_acpi_remove(struct acpi_device *device, int type)
 {
 	struct asus_laptop *asus = acpi_driver_data(device);
 
+	if (asus->pega_accel)
+		platform_device_unregister(asus->pega_accel);
+
 	asus_backlight_exit(asus);
 	asus_rfkill_exit(asus);
 	asus_led_exit(asus);
-- 
1.7.1

  parent reply	other threads:[~2011-01-24 22:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-24 22:48 [PATCH 0/4] Pegatron Lucid tablet acceleromter/ALS Andy Ross
2011-01-24 22:48 ` [PATCH 2/4] asus-laptop: Pegatron Lucid ALS support Andy Ross
2011-01-24 22:48 ` Andy Ross [this message]
2011-01-24 22:48 ` [PATCH 4/4] input: Pegatron Lucid accelerometer Andy Ross
     [not found] ` <1295909288-32650-1-git-send-email-andy.ross-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
2011-01-24 22:48   ` [PATCH 1/4] asus-laptop: Device detection for Pegatron Lucid tablets Andy Ross
2011-01-24 23:05   ` [PATCH 0/4] Pegatron Lucid tablet acceleromter/ALS Dmitry Torokhov
2011-01-25  7:30     ` Corentin Chary
2011-01-25 16:43       ` Andy Ross
2011-01-25 17:05         ` Corentin Chary
     [not found]           ` <AANLkTi=tQpQ0wjfx-Cp13FuCSQNFitN7XAg-V2AcSHz2-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-01-25 17:09             ` Andy Ross
     [not found]               ` <4D3F03B0.7030607-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
2011-01-25 17:10                 ` Corentin Chary
2011-01-25 17:12           ` Dmitry Torokhov

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=1295909288-32650-4-git-send-email-andy.ross@windriver.com \
    --to=andy.ross@windriver.com \
    --cc=acpi4asus-user@lists.sourceforge.net \
    --cc=corentincj@iksaif.net \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=platform-driver-x86@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