powerpc: Fix missing 'blr' in _tlbia()
[deliverable/linux.git] / drivers / leds / leds-hp-disk.c
CommitLineData
9c78ff6e
PM
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>
9c78ff6e
PM
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{
438f8de4 51 unsigned long long ret; /* Not used when writing */
9c78ff6e
PM
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};
72
73#ifdef CONFIG_PM
74static int hpled_suspend(struct acpi_device *dev, pm_message_t state)
75{
76 led_classdev_suspend(&hpled_led);
77 return 0;
78}
79
80static int hpled_resume(struct acpi_device *dev)
81{
82 led_classdev_resume(&hpled_led);
83 return 0;
84}
85#else
86#define hpled_suspend NULL
87#define hpled_resume NULL
88#endif
89
90static int hpled_add(struct acpi_device *device)
91{
92 int ret;
93
94 if (!device)
95 return -EINVAL;
96
97 adev.device = device;
98 strcpy(acpi_device_name(device), DRIVER_NAME);
99 strcpy(acpi_device_class(device), ACPI_MDPS_CLASS);
601a1b92 100 device->driver_data = &adev;
9c78ff6e
PM
101
102 ret = led_classdev_register(NULL, &hpled_led);
103 return ret;
104}
105
106static int hpled_remove(struct acpi_device *device, int type)
107{
108 if (!device)
109 return -EINVAL;
110
111 led_classdev_unregister(&hpled_led);
112 return 0;
113}
114
115
116
117static struct acpi_driver leds_hp_driver = {
118 .name = DRIVER_NAME,
119 .class = ACPI_MDPS_CLASS,
120 .ids = hpled_device_ids,
121 .ops = {
122 .add = hpled_add,
123 .remove = hpled_remove,
124 .suspend = hpled_suspend,
125 .resume = hpled_resume,
126 }
127};
128
129static int __init hpled_init_module(void)
130{
131 int ret;
132
133 if (acpi_disabled)
134 return -ENODEV;
135
136 ret = acpi_bus_register_driver(&leds_hp_driver);
137 if (ret < 0)
138 return ret;
139
140 printk(KERN_INFO DRIVER_NAME " driver loaded.\n");
141
142 return 0;
143}
144
145static void __exit hpled_exit_module(void)
146{
147 acpi_bus_unregister_driver(&leds_hp_driver);
148}
149
150MODULE_DESCRIPTION("Driver for HP disk protection LED");
151MODULE_AUTHOR("Pavel Machek <pavel@suse.cz>");
152MODULE_LICENSE("GPL");
153
154module_init(hpled_init_module);
155module_exit(hpled_exit_module);
This page took 0.035929 seconds and 5 git commands to generate.