diff options
Diffstat (limited to 'drivers/acpi/video.c')
-rw-r--r-- | drivers/acpi/video.c | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 1bdfb37377e3..a63566ba230b 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -76,6 +76,7 @@ MODULE_LICENSE("GPL"); | |||
76 | static int brightness_switch_enabled = 1; | 76 | static int brightness_switch_enabled = 1; |
77 | module_param(brightness_switch_enabled, bool, 0644); | 77 | module_param(brightness_switch_enabled, bool, 0644); |
78 | 78 | ||
79 | static int register_count = 0; | ||
79 | static int acpi_video_bus_add(struct acpi_device *device); | 80 | static int acpi_video_bus_add(struct acpi_device *device); |
80 | static int acpi_video_bus_remove(struct acpi_device *device, int type); | 81 | static int acpi_video_bus_remove(struct acpi_device *device, int type); |
81 | static int acpi_video_resume(struct acpi_device *device); | 82 | static int acpi_video_resume(struct acpi_device *device); |
@@ -2318,6 +2319,13 @@ static int __init intel_opregion_present(void) | |||
2318 | int acpi_video_register(void) | 2319 | int acpi_video_register(void) |
2319 | { | 2320 | { |
2320 | int result = 0; | 2321 | int result = 0; |
2322 | if (register_count) { | ||
2323 | /* | ||
2324 | * if the function of acpi_video_register is already called, | ||
2325 | * don't register the acpi_vide_bus again and return no error. | ||
2326 | */ | ||
2327 | return 0; | ||
2328 | } | ||
2321 | 2329 | ||
2322 | acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir); | 2330 | acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir); |
2323 | if (!acpi_video_dir) | 2331 | if (!acpi_video_dir) |
@@ -2329,10 +2337,35 @@ int acpi_video_register(void) | |||
2329 | return -ENODEV; | 2337 | return -ENODEV; |
2330 | } | 2338 | } |
2331 | 2339 | ||
2340 | /* | ||
2341 | * When the acpi_video_bus is loaded successfully, increase | ||
2342 | * the counter reference. | ||
2343 | */ | ||
2344 | register_count = 1; | ||
2345 | |||
2332 | return 0; | 2346 | return 0; |
2333 | } | 2347 | } |
2334 | EXPORT_SYMBOL(acpi_video_register); | 2348 | EXPORT_SYMBOL(acpi_video_register); |
2335 | 2349 | ||
2350 | void acpi_video_unregister(void) | ||
2351 | { | ||
2352 | if (!register_count) { | ||
2353 | /* | ||
2354 | * If the acpi video bus is already unloaded, don't | ||
2355 | * unload it again and return directly. | ||
2356 | */ | ||
2357 | return; | ||
2358 | } | ||
2359 | acpi_bus_unregister_driver(&acpi_video_bus); | ||
2360 | |||
2361 | remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir); | ||
2362 | |||
2363 | register_count = 0; | ||
2364 | |||
2365 | return; | ||
2366 | } | ||
2367 | EXPORT_SYMBOL(acpi_video_unregister); | ||
2368 | |||
2336 | /* | 2369 | /* |
2337 | * This is kind of nasty. Hardware using Intel chipsets may require | 2370 | * This is kind of nasty. Hardware using Intel chipsets may require |
2338 | * the video opregion code to be run first in order to initialise | 2371 | * the video opregion code to be run first in order to initialise |
@@ -2350,16 +2383,12 @@ static int __init acpi_video_init(void) | |||
2350 | return acpi_video_register(); | 2383 | return acpi_video_register(); |
2351 | } | 2384 | } |
2352 | 2385 | ||
2353 | void acpi_video_exit(void) | 2386 | static void __exit acpi_video_exit(void) |
2354 | { | 2387 | { |
2355 | 2388 | acpi_video_unregister(); | |
2356 | acpi_bus_unregister_driver(&acpi_video_bus); | ||
2357 | |||
2358 | remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir); | ||
2359 | 2389 | ||
2360 | return; | 2390 | return; |
2361 | } | 2391 | } |
2362 | EXPORT_SYMBOL(acpi_video_exit); | ||
2363 | 2392 | ||
2364 | module_init(acpi_video_init); | 2393 | module_init(acpi_video_init); |
2365 | module_exit(acpi_video_exit); | 2394 | module_exit(acpi_video_exit); |