static bool only_lcd = false;
module_param(only_lcd, bool, 0444);
-static int register_count;
-static DEFINE_MUTEX(register_count_mutex);
+static DECLARE_COMPLETION(register_done);
+static DEFINE_MUTEX(register_done_mutex);
static struct mutex video_list_lock;
static struct list_head video_bus_head;
static int acpi_video_bus_add(struct acpi_device *device);
{
int ret = 0;
- mutex_lock(®ister_count_mutex);
- if (register_count) {
+ mutex_lock(®ister_done_mutex);
+ if (completion_done(®ister_done)) {
/*
* if the function of acpi_video_register is already called,
* don't register the acpi_vide_bus again and return no error.
* When the acpi_video_bus is loaded successfully, increase
* the counter reference.
*/
- register_count = 1;
+ complete(®ister_done);
leave:
- mutex_unlock(®ister_count_mutex);
+ mutex_unlock(®ister_done_mutex);
return ret;
}
EXPORT_SYMBOL(acpi_video_register);
void acpi_video_unregister(void)
{
- mutex_lock(®ister_count_mutex);
- if (register_count) {
+ mutex_lock(®ister_done_mutex);
+ if (completion_done(®ister_done)) {
acpi_bus_unregister_driver(&acpi_video_bus);
- register_count = 0;
+ reinit_completion(®ister_done);
}
- mutex_unlock(®ister_count_mutex);
+ mutex_unlock(®ister_done_mutex);
}
EXPORT_SYMBOL(acpi_video_unregister);
{
struct acpi_video_bus *video;
- mutex_lock(®ister_count_mutex);
- if (register_count) {
+ mutex_lock(®ister_done_mutex);
+ if (completion_done(®ister_done)) {
mutex_lock(&video_list_lock);
list_for_each_entry(video, &video_bus_head, entry)
acpi_video_bus_unregister_backlight(video);
mutex_unlock(&video_list_lock);
}
- mutex_unlock(®ister_count_mutex);
+ mutex_unlock(®ister_done_mutex);
}
bool acpi_video_handles_brightness_key_presses(void)
{
bool have_video_busses;
+ wait_for_completion(®ister_done);
mutex_lock(&video_list_lock);
have_video_busses = !list_empty(&video_bus_head);
mutex_unlock(&video_list_lock);