mirror of
https://github.com/wessel-novacustom/clevo-keyboard.git
synced 2024-11-15 03:34:01 +01:00
clevo_keyboard: Add mutex to interface operations
This commit is contained in:
parent
b7a0b23db1
commit
67fb677d88
|
@ -64,8 +64,12 @@ struct clevo_interface_t *active_clevo_interface;
|
||||||
void clevo_keyboard_write_state(void);
|
void clevo_keyboard_write_state(void);
|
||||||
void clevo_keyboard_event_callb(u32 event);
|
void clevo_keyboard_event_callb(u32 event);
|
||||||
|
|
||||||
|
static DEFINE_MUTEX(clevo_keyboard_interface_modification_lock);
|
||||||
|
|
||||||
u32 clevo_keyboard_add_interface(struct clevo_interface_t *new_interface)
|
u32 clevo_keyboard_add_interface(struct clevo_interface_t *new_interface)
|
||||||
{
|
{
|
||||||
|
mutex_lock(&clevo_keyboard_interface_modification_lock);
|
||||||
|
|
||||||
if (strcmp(new_interface->string_id, "clevo_wmi") == 0) {
|
if (strcmp(new_interface->string_id, "clevo_wmi") == 0) {
|
||||||
clevo_interfaces.wmi = new_interface;
|
clevo_interfaces.wmi = new_interface;
|
||||||
clevo_interfaces.wmi->event_callb = clevo_keyboard_event_callb;
|
clevo_interfaces.wmi->event_callb = clevo_keyboard_event_callb;
|
||||||
|
@ -88,28 +92,36 @@ u32 clevo_keyboard_add_interface(struct clevo_interface_t *new_interface)
|
||||||
} else {
|
} else {
|
||||||
// Not recognized interface
|
// Not recognized interface
|
||||||
pr_err("unrecognized interface\n");
|
pr_err("unrecognized interface\n");
|
||||||
|
mutex_unlock(&clevo_keyboard_interface_modification_lock);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
clevo_keyboard_write_state();
|
clevo_keyboard_write_state();
|
||||||
|
|
||||||
|
mutex_unlock(&clevo_keyboard_interface_modification_lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(clevo_keyboard_add_interface);
|
EXPORT_SYMBOL(clevo_keyboard_add_interface);
|
||||||
|
|
||||||
u32 clevo_keyboard_remove_interface(struct clevo_interface_t *interface)
|
u32 clevo_keyboard_remove_interface(struct clevo_interface_t *interface)
|
||||||
{
|
{
|
||||||
|
mutex_lock(&clevo_keyboard_interface_modification_lock);
|
||||||
|
|
||||||
if (strcmp(interface->string_id, "clevo_wmi") == 0) {
|
if (strcmp(interface->string_id, "clevo_wmi") == 0) {
|
||||||
clevo_interfaces.wmi = NULL;
|
clevo_interfaces.wmi = NULL;
|
||||||
} else if (strcmp(interface->string_id, "clevo_acpi") == 0) {
|
} else if (strcmp(interface->string_id, "clevo_acpi") == 0) {
|
||||||
clevo_interfaces.acpi = NULL;
|
clevo_interfaces.acpi = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
mutex_unlock(&clevo_keyboard_interface_modification_lock);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (active_clevo_interface == interface)
|
if (active_clevo_interface == interface)
|
||||||
active_clevo_interface = NULL;
|
active_clevo_interface = NULL;
|
||||||
|
|
||||||
|
mutex_unlock(&clevo_keyboard_interface_modification_lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(clevo_keyboard_remove_interface);
|
EXPORT_SYMBOL(clevo_keyboard_remove_interface);
|
||||||
|
|
Loading…
Reference in a new issue