aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/hp_accel.c
diff options
context:
space:
mode:
authorPavel Machek <pavel@suse.cz>2009-02-18 17:48:23 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-02-18 18:37:54 -0500
commitef2cfc790bf5f0ff189b01eabc0f4feb5e8524df (patch)
tree1e1a4999a6615f66f56ffe19c883e065aa8d3020 /drivers/hwmon/hp_accel.c
parent3a5093ee6728c8cbe9c039e685fc1fca8f965048 (diff)
hp accelerometer: add freefall detection
This adds freefall handling to hp_accel driver. According to HP, it should just work, without us having to set the chip up by hand. hpfall.c is example .c program that parks the disk when accelerometer detects free fall. It should work; for now, it uses fixed 20seconds protection period. Signed-off-by: Pavel Machek <pavel@suse.cz> Cc: Thomas Renninger <trenn@suse.de> Cc: Éric Piel <eric.piel@tremplin-utc.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/hwmon/hp_accel.c')
-rw-r--r--drivers/hwmon/hp_accel.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/hwmon/hp_accel.c b/drivers/hwmon/hp_accel.c
index abf4dfc8ec22..dcefe1d2adbd 100644
--- a/drivers/hwmon/hp_accel.c
+++ b/drivers/hwmon/hp_accel.c
@@ -213,6 +213,30 @@ static struct delayed_led_classdev hpled_led = {
213 .set_brightness = hpled_set, 213 .set_brightness = hpled_set,
214}; 214};
215 215
216static acpi_status
217lis3lv02d_get_resource(struct acpi_resource *resource, void *context)
218{
219 if (resource->type == ACPI_RESOURCE_TYPE_EXTENDED_IRQ) {
220 struct acpi_resource_extended_irq *irq;
221 u32 *device_irq = context;
222
223 irq = &resource->data.extended_irq;
224 *device_irq = irq->interrupts[0];
225 }
226
227 return AE_OK;
228}
229
230static void lis3lv02d_enum_resources(struct acpi_device *device)
231{
232 acpi_status status;
233
234 status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
235 lis3lv02d_get_resource, &adev.irq);
236 if (ACPI_FAILURE(status))
237 printk(KERN_DEBUG DRIVER_NAME ": Error getting resources\n");
238}
239
216static int lis3lv02d_add(struct acpi_device *device) 240static int lis3lv02d_add(struct acpi_device *device)
217{ 241{
218 u8 val; 242 u8 val;
@@ -247,6 +271,9 @@ static int lis3lv02d_add(struct acpi_device *device)
247 if (ret) 271 if (ret)
248 return ret; 272 return ret;
249 273
274 /* obtain IRQ number of our device from ACPI */
275 lis3lv02d_enum_resources(adev.device);
276
250 ret = lis3lv02d_init_device(&adev); 277 ret = lis3lv02d_init_device(&adev);
251 if (ret) { 278 if (ret) {
252 flush_work(&hpled_led.work); 279 flush_work(&hpled_led.work);