aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/video.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/video.c')
-rw-r--r--drivers/acpi/video.c61
1 files changed, 52 insertions, 9 deletions
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 1bdfb37377e3..8851315ce858 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -76,6 +76,7 @@ MODULE_LICENSE("GPL");
76static int brightness_switch_enabled = 1; 76static int brightness_switch_enabled = 1;
77module_param(brightness_switch_enabled, bool, 0644); 77module_param(brightness_switch_enabled, bool, 0644);
78 78
79static int register_count = 0;
79static int acpi_video_bus_add(struct acpi_device *device); 80static int acpi_video_bus_add(struct acpi_device *device);
80static int acpi_video_bus_remove(struct acpi_device *device, int type); 81static int acpi_video_bus_remove(struct acpi_device *device, int type);
81static int acpi_video_resume(struct acpi_device *device); 82static int acpi_video_resume(struct acpi_device *device);
@@ -586,6 +587,14 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
586 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5315"), 587 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5315"),
587 }, 588 },
588 }, 589 },
590 {
591 .callback = video_set_bqc_offset,
592 .ident = "Acer Aspire 7720",
593 .matches = {
594 DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
595 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 7720"),
596 },
597 },
589 {} 598 {}
590}; 599};
591 600
@@ -976,6 +985,11 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
976 device->backlight->props.max_brightness = device->brightness->count-3; 985 device->backlight->props.max_brightness = device->brightness->count-3;
977 kfree(name); 986 kfree(name);
978 987
988 result = sysfs_create_link(&device->backlight->dev.kobj,
989 &device->dev->dev.kobj, "device");
990 if (result)
991 printk(KERN_ERR PREFIX "Create sysfs link\n");
992
979 device->cdev = thermal_cooling_device_register("LCD", 993 device->cdev = thermal_cooling_device_register("LCD",
980 device->dev, &video_cooling_ops); 994 device->dev, &video_cooling_ops);
981 if (IS_ERR(device->cdev)) 995 if (IS_ERR(device->cdev))
@@ -1054,15 +1068,15 @@ static void acpi_video_bus_find_cap(struct acpi_video_bus *video)
1054static int acpi_video_bus_check(struct acpi_video_bus *video) 1068static int acpi_video_bus_check(struct acpi_video_bus *video)
1055{ 1069{
1056 acpi_status status = -ENOENT; 1070 acpi_status status = -ENOENT;
1057 struct device *dev; 1071 struct pci_dev *dev;
1058 1072
1059 if (!video) 1073 if (!video)
1060 return -EINVAL; 1074 return -EINVAL;
1061 1075
1062 dev = acpi_get_physical_pci_device(video->device->handle); 1076 dev = acpi_get_pci_dev(video->device->handle);
1063 if (!dev) 1077 if (!dev)
1064 return -ENODEV; 1078 return -ENODEV;
1065 put_device(dev); 1079 pci_dev_put(dev);
1066 1080
1067 /* Since there is no HID, CID and so on for VGA driver, we have 1081 /* Since there is no HID, CID and so on for VGA driver, we have
1068 * to check well known required nodes. 1082 * to check well known required nodes.
@@ -1990,6 +2004,7 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device)
1990 status = acpi_remove_notify_handler(device->dev->handle, 2004 status = acpi_remove_notify_handler(device->dev->handle,
1991 ACPI_DEVICE_NOTIFY, 2005 ACPI_DEVICE_NOTIFY,
1992 acpi_video_device_notify); 2006 acpi_video_device_notify);
2007 sysfs_remove_link(&device->backlight->dev.kobj, "device");
1993 backlight_device_unregister(device->backlight); 2008 backlight_device_unregister(device->backlight);
1994 if (device->cdev) { 2009 if (device->cdev) {
1995 sysfs_remove_link(&device->dev->dev.kobj, 2010 sysfs_remove_link(&device->dev->dev.kobj,
@@ -2318,6 +2333,13 @@ static int __init intel_opregion_present(void)
2318int acpi_video_register(void) 2333int acpi_video_register(void)
2319{ 2334{
2320 int result = 0; 2335 int result = 0;
2336 if (register_count) {
2337 /*
2338 * if the function of acpi_video_register is already called,
2339 * don't register the acpi_vide_bus again and return no error.
2340 */
2341 return 0;
2342 }
2321 2343
2322 acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir); 2344 acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir);
2323 if (!acpi_video_dir) 2345 if (!acpi_video_dir)
@@ -2329,10 +2351,35 @@ int acpi_video_register(void)
2329 return -ENODEV; 2351 return -ENODEV;
2330 } 2352 }
2331 2353
2354 /*
2355 * When the acpi_video_bus is loaded successfully, increase
2356 * the counter reference.
2357 */
2358 register_count = 1;
2359
2332 return 0; 2360 return 0;
2333} 2361}
2334EXPORT_SYMBOL(acpi_video_register); 2362EXPORT_SYMBOL(acpi_video_register);
2335 2363
2364void acpi_video_unregister(void)
2365{
2366 if (!register_count) {
2367 /*
2368 * If the acpi video bus is already unloaded, don't
2369 * unload it again and return directly.
2370 */
2371 return;
2372 }
2373 acpi_bus_unregister_driver(&acpi_video_bus);
2374
2375 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
2376
2377 register_count = 0;
2378
2379 return;
2380}
2381EXPORT_SYMBOL(acpi_video_unregister);
2382
2336/* 2383/*
2337 * This is kind of nasty. Hardware using Intel chipsets may require 2384 * This is kind of nasty. Hardware using Intel chipsets may require
2338 * the video opregion code to be run first in order to initialise 2385 * the video opregion code to be run first in order to initialise
@@ -2350,16 +2397,12 @@ static int __init acpi_video_init(void)
2350 return acpi_video_register(); 2397 return acpi_video_register();
2351} 2398}
2352 2399
2353void acpi_video_exit(void) 2400static void __exit acpi_video_exit(void)
2354{ 2401{
2355 2402 acpi_video_unregister();
2356 acpi_bus_unregister_driver(&acpi_video_bus);
2357
2358 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
2359 2403
2360 return; 2404 return;
2361} 2405}
2362EXPORT_SYMBOL(acpi_video_exit);
2363 2406
2364module_init(acpi_video_init); 2407module_init(acpi_video_init);
2365module_exit(acpi_video_exit); 2408module_exit(acpi_video_exit);