aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorEric Piel <eric.piel@tremplin-utc.net>2009-01-15 16:51:23 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-15 19:39:40 -0500
commit9e0c79782143a816ba7d7f0f6e195091a97053f6 (patch)
tree109a347061a1e2d1e08aa3908b893e2ee55f9732 /drivers
parent5b019e99016f3a692ba45bf68fba73a402d7c01a (diff)
lis3lv02d: merge with leds hp disk
Move the second part of the HP laptop disk protection functionality (a red led) to the same driver. From a purely Linux developer's point of view, the led and the accelerometer have nothing related. However, they correspond to the same ACPI functionality, and so will always be used together, moreover as they share the same ACPI PNP alias, there is no other simple to allow to have same loaded at the same time if they are not in the same module. Also make it requires the led class to compile and update the Kconfig text. Signed-off-by: Pavel Machek <pavel@suse.cz> Signed-off-by: Eric 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')
-rw-r--r--drivers/hwmon/Kconfig14
-rw-r--r--drivers/hwmon/hp_accel.c43
-rw-r--r--drivers/leds/Kconfig7
-rw-r--r--drivers/leds/Makefile1
-rw-r--r--drivers/leds/leds-hp-disk.c137
5 files changed, 52 insertions, 150 deletions
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 4b33bc82cc24..54b43bea5e47 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -861,6 +861,8 @@ config SENSORS_HDAPS
861config SENSORS_LIS3LV02D 861config SENSORS_LIS3LV02D
862 tristate "STMicroeletronics LIS3LV02Dx three-axis digital accelerometer" 862 tristate "STMicroeletronics LIS3LV02Dx three-axis digital accelerometer"
863 depends on ACPI && INPUT 863 depends on ACPI && INPUT
864 select NEW_LEDS
865 select LEDS_CLASS
864 default n 866 default n
865 help 867 help
866 This driver provides support for the LIS3LV02Dx accelerometer. In 868 This driver provides support for the LIS3LV02Dx accelerometer. In
@@ -872,10 +874,16 @@ config SENSORS_LIS3LV02D
872 /sys/devices/platform/lis3lv02d. 874 /sys/devices/platform/lis3lv02d.
873 875
874 This driver also provides an absolute input class device, allowing 876 This driver also provides an absolute input class device, allowing
875 the laptop to act as a pinball machine-esque joystick. 877 the laptop to act as a pinball machine-esque joystick. On HP laptops,
878 if the led infrastructure is activated, support for a led indicating
879 disk protection will be provided as hp:red:hddprotection.
876 880
877 This driver can also be built as a module. If so, the module 881 This driver can also be built as modules. If so, the core module
878 will be called lis3lv02d. 882 will be called lis3lv02d and a specific module for HP laptops will be
883 called hp_accel.
884
885 Say Y here if you have an applicable laptop and want to experience
886 the awesome power of lis3lv02d.
879 887
880config SENSORS_APPLESMC 888config SENSORS_APPLESMC
881 tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)" 889 tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)"
diff --git a/drivers/hwmon/hp_accel.c b/drivers/hwmon/hp_accel.c
index bf8d40580577..86a0f51d99d6 100644
--- a/drivers/hwmon/hp_accel.c
+++ b/drivers/hwmon/hp_accel.c
@@ -36,6 +36,7 @@
36#include <linux/freezer.h> 36#include <linux/freezer.h>
37#include <linux/version.h> 37#include <linux/version.h>
38#include <linux/uaccess.h> 38#include <linux/uaccess.h>
39#include <linux/leds.h>
39#include <acpi/acpi_drivers.h> 40#include <acpi/acpi_drivers.h>
40#include <asm/atomic.h> 41#include <asm/atomic.h>
41#include "lis3lv02d.h" 42#include "lis3lv02d.h"
@@ -154,10 +155,34 @@ static struct dmi_system_id lis3lv02d_dmi_ids[] = {
154 */ 155 */
155}; 156};
156 157
158static acpi_status hpled_acpi_write(acpi_handle handle, int reg)
159{
160 unsigned long long ret; /* Not used when writing */
161 union acpi_object in_obj[1];
162 struct acpi_object_list args = { 1, in_obj };
163
164 in_obj[0].type = ACPI_TYPE_INTEGER;
165 in_obj[0].integer.value = reg;
166
167 return acpi_evaluate_integer(handle, "ALED", &args, &ret);
168}
169
170static void hpled_set(struct led_classdev *led_cdev,
171 enum led_brightness value)
172{
173 hpled_acpi_write(adev.device->handle, !!value);
174}
175
176static struct led_classdev hpled_led = {
177 .name = "hp:red:hddprotection",
178 .default_trigger = "none",
179 .brightness_set = hpled_set,
180};
157 181
158static int lis3lv02d_add(struct acpi_device *device) 182static int lis3lv02d_add(struct acpi_device *device)
159{ 183{
160 u8 val; 184 u8 val;
185 int ret;
161 186
162 if (!device) 187 if (!device)
163 return -EINVAL; 188 return -EINVAL;
@@ -183,7 +208,17 @@ static int lis3lv02d_add(struct acpi_device *device)
183 adev.ac = lis3lv02d_axis_normal; 208 adev.ac = lis3lv02d_axis_normal;
184 } 209 }
185 210
186 return lis3lv02d_init_device(&adev); 211 ret = led_classdev_register(NULL, &hpled_led);
212 if (ret)
213 return ret;
214
215 ret = lis3lv02d_init_device(&adev);
216 if (ret) {
217 led_classdev_unregister(&hpled_led);
218 return ret;
219 }
220
221 return ret;
187} 222}
188 223
189static int lis3lv02d_remove(struct acpi_device *device, int type) 224static int lis3lv02d_remove(struct acpi_device *device, int type)
@@ -194,6 +229,8 @@ static int lis3lv02d_remove(struct acpi_device *device, int type)
194 lis3lv02d_joystick_disable(); 229 lis3lv02d_joystick_disable();
195 lis3lv02d_poweroff(device->handle); 230 lis3lv02d_poweroff(device->handle);
196 231
232 led_classdev_unregister(&hpled_led);
233
197 return lis3lv02d_remove_fs(); 234 return lis3lv02d_remove_fs();
198} 235}
199 236
@@ -203,6 +240,7 @@ static int lis3lv02d_suspend(struct acpi_device *device, pm_message_t state)
203{ 240{
204 /* make sure the device is off when we suspend */ 241 /* make sure the device is off when we suspend */
205 lis3lv02d_poweroff(device->handle); 242 lis3lv02d_poweroff(device->handle);
243 led_classdev_suspend(&hpled_led);
206 return 0; 244 return 0;
207} 245}
208 246
@@ -215,6 +253,7 @@ static int lis3lv02d_resume(struct acpi_device *device)
215 else 253 else
216 lis3lv02d_poweroff(device->handle); 254 lis3lv02d_poweroff(device->handle);
217 mutex_unlock(&adev.lock); 255 mutex_unlock(&adev.lock);
256 led_classdev_resume(&hpled_led);
218 return 0; 257 return 0;
219} 258}
220#else 259#else
@@ -256,7 +295,7 @@ static void __exit lis3lv02d_exit_module(void)
256 acpi_bus_unregister_driver(&lis3lv02d_driver); 295 acpi_bus_unregister_driver(&lis3lv02d_driver);
257} 296}
258 297
259MODULE_DESCRIPTION("Glue between LIS3LV02Dx and HP ACPI BIOS"); 298MODULE_DESCRIPTION("Glue between LIS3LV02Dx and HP ACPI BIOS and support for disk protection LED.");
260MODULE_AUTHOR("Yan Burman, Eric Piel, Pavel Machek"); 299MODULE_AUTHOR("Yan Burman, Eric Piel, Pavel Machek");
261MODULE_LICENSE("GPL"); 300MODULE_LICENSE("GPL");
262 301
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index a4a1ae214630..742713611bc5 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -119,13 +119,6 @@ config LEDS_GPIO
119 outputs. To be useful the particular board must have LEDs 119 outputs. To be useful the particular board must have LEDs
120 and they must be connected to the GPIO lines. 120 and they must be connected to the GPIO lines.
121 121
122config LEDS_HP_DISK
123 tristate "LED Support for disk protection LED on HP notebooks"
124 depends on LEDS_CLASS && ACPI
125 help
126 This option enable support for disk protection LED, found on
127 newer HP notebooks.
128
129config LEDS_CLEVO_MAIL 122config LEDS_CLEVO_MAIL
130 tristate "Mail LED on Clevo notebook (EXPERIMENTAL)" 123 tristate "Mail LED on Clevo notebook (EXPERIMENTAL)"
131 depends on LEDS_CLASS && X86 && SERIO_I8042 && DMI && EXPERIMENTAL 124 depends on LEDS_CLASS && X86 && SERIO_I8042 && DMI && EXPERIMENTAL
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index bc247cb02e82..9d76f0f160a4 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -23,7 +23,6 @@ obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o
23obj-$(CONFIG_LEDS_FSG) += leds-fsg.o 23obj-$(CONFIG_LEDS_FSG) += leds-fsg.o
24obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o 24obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o
25obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o 25obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o
26obj-$(CONFIG_LEDS_HP_DISK) += leds-hp-disk.o
27obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o 26obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o
28 27
29# LED Triggers 28# LED Triggers
diff --git a/drivers/leds/leds-hp-disk.c b/drivers/leds/leds-hp-disk.c
deleted file mode 100644
index d786adc8c5e3..000000000000
--- a/drivers/leds/leds-hp-disk.c
+++ /dev/null
@@ -1,137 +0,0 @@
1/*
2 * leds-hp-disk.c - driver for HP "hard disk protection" LED
3 *
4 * Copyright (C) 2008 Pavel Machek
5 *
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.
10 *
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.
15 *
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
19 */
20
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>
32
33#define DRIVER_NAME "leds-hp-disk"
34#define ACPI_MDPS_CLASS "led"
35
36/* For automatic insertion of the module */
37static struct acpi_device_id hpled_device_ids[] = {
38 {"HPQ0004", 0}, /* HP Mobile Data Protection System PNP */
39 {"", 0},
40};
41MODULE_DEVICE_TABLE(acpi, hpled_device_ids);
42
43struct acpi_hpled {
44 struct acpi_device *device; /* The ACPI device */
45};
46
47static struct acpi_hpled adev;
48
49static acpi_status hpled_acpi_write(acpi_handle handle, int reg)
50{
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 };
54
55 in_obj[0].type = ACPI_TYPE_INTEGER;
56 in_obj[0].integer.value = reg;
57
58 return acpi_evaluate_integer(handle, "ALED", &args, &ret);
59}
60
61static void hpled_set(struct led_classdev *led_cdev,
62 enum led_brightness value)
63{
64 hpled_acpi_write(adev.device->handle, !!value);
65}
66
67static struct led_classdev hpled_led = {
68 .name = "hp:red:hddprotection",
69 .default_trigger = "heartbeat",
70 .brightness_set = hpled_set,
71 .flags = LED_CORE_SUSPENDRESUME,
72};
73
74static int hpled_add(struct acpi_device *device)
75{
76 int ret;
77
78 if (!device)
79 return -EINVAL;
80
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;
85
86 ret = led_classdev_register(NULL, &hpled_led);
87 return ret;
88}
89
90static int hpled_remove(struct acpi_device *device, int type)
91{
92 if (!device)
93 return -EINVAL;
94
95 led_classdev_unregister(&hpled_led);
96 return 0;
97}
98
99
100
101static 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,
108 }
109};
110
111static int __init hpled_init_module(void)
112{
113 int ret;
114
115 if (acpi_disabled)
116 return -ENODEV;
117
118 ret = acpi_bus_register_driver(&leds_hp_driver);
119 if (ret < 0)
120 return ret;
121
122 printk(KERN_INFO DRIVER_NAME " driver loaded.\n");
123
124 return 0;
125}
126
127static void __exit hpled_exit_module(void)
128{
129 acpi_bus_unregister_driver(&leds_hp_driver);
130}
131
132MODULE_DESCRIPTION("Driver for HP disk protection LED");
133MODULE_AUTHOR("Pavel Machek <pavel@suse.cz>");
134MODULE_LICENSE("GPL");
135
136module_init(hpled_init_module);
137module_exit(hpled_exit_module);