aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/video.c
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2009-04-07 11:37:11 -0400
committerLen Brown <len.brown@intel.com>2009-04-07 16:26:57 -0400
commit7015558fca5ee82fc17227b61d88ddaa02d82242 (patch)
tree253519cdfbcc62f1e8ffae6353ceb7d801f4322b /drivers/acpi/video.c
parent342d550db1bc0b879007a8cdb38645558e839680 (diff)
ACPI: video: use .notify method instead of installing handler directly
This patch adds a .notify() method. The presence of .notify() causes Linux/ACPI to manage event handlers and notify handlers on our behalf, so we don't have to install and remove them ourselves. Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> CC: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/video.c')
-rw-r--r--drivers/acpi/video.c30
1 files changed, 5 insertions, 25 deletions
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index ab06143672bc..cd4fb7543a90 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -79,6 +79,7 @@ module_param(brightness_switch_enabled, bool, 0644);
79static int acpi_video_bus_add(struct acpi_device *device); 79static int acpi_video_bus_add(struct acpi_device *device);
80static int acpi_video_bus_remove(struct acpi_device *device, int type); 80static int acpi_video_bus_remove(struct acpi_device *device, int type);
81static int acpi_video_resume(struct acpi_device *device); 81static int acpi_video_resume(struct acpi_device *device);
82static void acpi_video_bus_notify(struct acpi_device *device, u32 event);
82 83
83static const struct acpi_device_id video_device_ids[] = { 84static const struct acpi_device_id video_device_ids[] = {
84 {ACPI_VIDEO_HID, 0}, 85 {ACPI_VIDEO_HID, 0},
@@ -94,6 +95,7 @@ static struct acpi_driver acpi_video_bus = {
94 .add = acpi_video_bus_add, 95 .add = acpi_video_bus_add,
95 .remove = acpi_video_bus_remove, 96 .remove = acpi_video_bus_remove,
96 .resume = acpi_video_resume, 97 .resume = acpi_video_resume,
98 .notify = acpi_video_bus_notify,
97 }, 99 },
98}; 100};
99 101
@@ -1986,17 +1988,15 @@ static int acpi_video_bus_stop_devices(struct acpi_video_bus *video)
1986 return acpi_video_bus_DOS(video, 0, 1); 1988 return acpi_video_bus_DOS(video, 0, 1);
1987} 1989}
1988 1990
1989static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) 1991static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
1990{ 1992{
1991 struct acpi_video_bus *video = data; 1993 struct acpi_video_bus *video = acpi_driver_data(device);
1992 struct acpi_device *device = NULL;
1993 struct input_dev *input; 1994 struct input_dev *input;
1994 int keycode; 1995 int keycode;
1995 1996
1996 if (!video) 1997 if (!video)
1997 return; 1998 return;
1998 1999
1999 device = video->device;
2000 input = video->input; 2000 input = video->input;
2001 2001
2002 switch (event) { 2002 switch (event) {
@@ -2127,7 +2127,6 @@ static int acpi_video_resume(struct acpi_device *device)
2127 2127
2128static int acpi_video_bus_add(struct acpi_device *device) 2128static int acpi_video_bus_add(struct acpi_device *device)
2129{ 2129{
2130 acpi_status status;
2131 struct acpi_video_bus *video; 2130 struct acpi_video_bus *video;
2132 struct input_dev *input; 2131 struct input_dev *input;
2133 int error; 2132 int error;
@@ -2169,20 +2168,10 @@ static int acpi_video_bus_add(struct acpi_device *device)
2169 acpi_video_bus_get_devices(video, device); 2168 acpi_video_bus_get_devices(video, device);
2170 acpi_video_bus_start_devices(video); 2169 acpi_video_bus_start_devices(video);
2171 2170
2172 status = acpi_install_notify_handler(device->handle,
2173 ACPI_DEVICE_NOTIFY,
2174 acpi_video_bus_notify, video);
2175 if (ACPI_FAILURE(status)) {
2176 printk(KERN_ERR PREFIX
2177 "Error installing notify handler\n");
2178 error = -ENODEV;
2179 goto err_stop_video;
2180 }
2181
2182 video->input = input = input_allocate_device(); 2171 video->input = input = input_allocate_device();
2183 if (!input) { 2172 if (!input) {
2184 error = -ENOMEM; 2173 error = -ENOMEM;
2185 goto err_uninstall_notify; 2174 goto err_stop_video;
2186 } 2175 }
2187 2176
2188 snprintf(video->phys, sizeof(video->phys), 2177 snprintf(video->phys, sizeof(video->phys),
@@ -2218,9 +2207,6 @@ static int acpi_video_bus_add(struct acpi_device *device)
2218 2207
2219 err_free_input_dev: 2208 err_free_input_dev:
2220 input_free_device(input); 2209 input_free_device(input);
2221 err_uninstall_notify:
2222 acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
2223 acpi_video_bus_notify);
2224 err_stop_video: 2210 err_stop_video:
2225 acpi_video_bus_stop_devices(video); 2211 acpi_video_bus_stop_devices(video);
2226 acpi_video_bus_put_devices(video); 2212 acpi_video_bus_put_devices(video);
@@ -2235,7 +2221,6 @@ static int acpi_video_bus_add(struct acpi_device *device)
2235 2221
2236static int acpi_video_bus_remove(struct acpi_device *device, int type) 2222static int acpi_video_bus_remove(struct acpi_device *device, int type)
2237{ 2223{
2238 acpi_status status = 0;
2239 struct acpi_video_bus *video = NULL; 2224 struct acpi_video_bus *video = NULL;
2240 2225
2241 2226
@@ -2245,11 +2230,6 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)
2245 video = acpi_driver_data(device); 2230 video = acpi_driver_data(device);
2246 2231
2247 acpi_video_bus_stop_devices(video); 2232 acpi_video_bus_stop_devices(video);
2248
2249 status = acpi_remove_notify_handler(video->device->handle,
2250 ACPI_DEVICE_NOTIFY,
2251 acpi_video_bus_notify);
2252
2253 acpi_video_bus_put_devices(video); 2233 acpi_video_bus_put_devices(video);
2254 acpi_video_bus_remove_fs(device); 2234 acpi_video_bus_remove_fs(device);
2255 2235