ALSA: hda - Use queue_delayed_work()
[linux-2.6/linux-2.6-openrd.git] / drivers / leds / leds-hp-disk.c
blobd786adc8c5e3616ecb8131f2b1d58d68d19a30c8
1 /*
2 * leds-hp-disk.c - driver for HP "hard disk protection" LED
4 * Copyright (C) 2008 Pavel Machek
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <linux/kernel.h>
22 #include <linux/init.h>
23 #include <linux/dmi.h>
24 #include <linux/module.h>
25 #include <linux/types.h>
26 #include <linux/platform_device.h>
27 #include <linux/interrupt.h>
28 #include <linux/input.h>
29 #include <linux/kthread.h>
30 #include <linux/leds.h>
31 #include <acpi/acpi_drivers.h>
33 #define DRIVER_NAME "leds-hp-disk"
34 #define ACPI_MDPS_CLASS "led"
36 /* For automatic insertion of the module */
37 static struct acpi_device_id hpled_device_ids[] = {
38 {"HPQ0004", 0}, /* HP Mobile Data Protection System PNP */
39 {"", 0},
41 MODULE_DEVICE_TABLE(acpi, hpled_device_ids);
43 struct acpi_hpled {
44 struct acpi_device *device; /* The ACPI device */
47 static struct acpi_hpled adev;
49 static acpi_status hpled_acpi_write(acpi_handle handle, int reg)
51 unsigned long long ret; /* Not used when writing */
52 union acpi_object in_obj[1];
53 struct acpi_object_list args = { 1, in_obj };
55 in_obj[0].type = ACPI_TYPE_INTEGER;
56 in_obj[0].integer.value = reg;
58 return acpi_evaluate_integer(handle, "ALED", &args, &ret);
61 static void hpled_set(struct led_classdev *led_cdev,
62 enum led_brightness value)
64 hpled_acpi_write(adev.device->handle, !!value);
67 static struct led_classdev hpled_led = {
68 .name = "hp:red:hddprotection",
69 .default_trigger = "heartbeat",
70 .brightness_set = hpled_set,
71 .flags = LED_CORE_SUSPENDRESUME,
74 static int hpled_add(struct acpi_device *device)
76 int ret;
78 if (!device)
79 return -EINVAL;
81 adev.device = device;
82 strcpy(acpi_device_name(device), DRIVER_NAME);
83 strcpy(acpi_device_class(device), ACPI_MDPS_CLASS);
84 device->driver_data = &adev;
86 ret = led_classdev_register(NULL, &hpled_led);
87 return ret;
90 static int hpled_remove(struct acpi_device *device, int type)
92 if (!device)
93 return -EINVAL;
95 led_classdev_unregister(&hpled_led);
96 return 0;
101 static struct acpi_driver leds_hp_driver = {
102 .name = DRIVER_NAME,
103 .class = ACPI_MDPS_CLASS,
104 .ids = hpled_device_ids,
105 .ops = {
106 .add = hpled_add,
107 .remove = hpled_remove,
111 static int __init hpled_init_module(void)
113 int ret;
115 if (acpi_disabled)
116 return -ENODEV;
118 ret = acpi_bus_register_driver(&leds_hp_driver);
119 if (ret < 0)
120 return ret;
122 printk(KERN_INFO DRIVER_NAME " driver loaded.\n");
124 return 0;
127 static void __exit hpled_exit_module(void)
129 acpi_bus_unregister_driver(&leds_hp_driver);
132 MODULE_DESCRIPTION("Driver for HP disk protection LED");
133 MODULE_AUTHOR("Pavel Machek <pavel@suse.cz>");
134 MODULE_LICENSE("GPL");
136 module_init(hpled_init_module);
137 module_exit(hpled_exit_module);