Commit 37e90a22 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Mauro Carvalho Chehab

[media] rc: ir-raw: change type of available_protocols to atomic64_t

Changing available_protocols to atomic64_t allows to get rid of the
mutex protecting access to the variable. This helps to simplify
the code.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 8a5d2ace
...@@ -26,8 +26,7 @@ static LIST_HEAD(ir_raw_client_list); ...@@ -26,8 +26,7 @@ static LIST_HEAD(ir_raw_client_list);
/* Used to handle IR raw handler extensions */ /* Used to handle IR raw handler extensions */
static DEFINE_MUTEX(ir_raw_handler_lock); static DEFINE_MUTEX(ir_raw_handler_lock);
static LIST_HEAD(ir_raw_handler_list); static LIST_HEAD(ir_raw_handler_list);
static DEFINE_MUTEX(available_protocols_lock); static atomic64_t available_protocols = ATOMIC64_INIT(0);
static u64 available_protocols;
static int ir_raw_event_thread(void *data) static int ir_raw_event_thread(void *data)
{ {
...@@ -234,11 +233,7 @@ EXPORT_SYMBOL_GPL(ir_raw_event_handle); ...@@ -234,11 +233,7 @@ EXPORT_SYMBOL_GPL(ir_raw_event_handle);
u64 u64
ir_raw_get_allowed_protocols(void) ir_raw_get_allowed_protocols(void)
{ {
u64 protocols; return atomic64_read(&available_protocols);
mutex_lock(&available_protocols_lock);
protocols = available_protocols;
mutex_unlock(&available_protocols_lock);
return protocols;
} }
static int change_protocol(struct rc_dev *dev, u64 *rc_type) static int change_protocol(struct rc_dev *dev, u64 *rc_type)
...@@ -331,9 +326,7 @@ int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler) ...@@ -331,9 +326,7 @@ int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler)
if (ir_raw_handler->raw_register) if (ir_raw_handler->raw_register)
list_for_each_entry(raw, &ir_raw_client_list, list) list_for_each_entry(raw, &ir_raw_client_list, list)
ir_raw_handler->raw_register(raw->dev); ir_raw_handler->raw_register(raw->dev);
mutex_lock(&available_protocols_lock); atomic64_or(ir_raw_handler->protocols, &available_protocols);
available_protocols |= ir_raw_handler->protocols;
mutex_unlock(&available_protocols_lock);
mutex_unlock(&ir_raw_handler_lock); mutex_unlock(&ir_raw_handler_lock);
return 0; return 0;
...@@ -352,9 +345,7 @@ void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler) ...@@ -352,9 +345,7 @@ void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler)
if (ir_raw_handler->raw_unregister) if (ir_raw_handler->raw_unregister)
ir_raw_handler->raw_unregister(raw->dev); ir_raw_handler->raw_unregister(raw->dev);
} }
mutex_lock(&available_protocols_lock); atomic64_andnot(protocols, &available_protocols);
available_protocols &= ~protocols;
mutex_unlock(&available_protocols_lock);
mutex_unlock(&ir_raw_handler_lock); mutex_unlock(&ir_raw_handler_lock);
} }
EXPORT_SYMBOL(ir_raw_handler_unregister); EXPORT_SYMBOL(ir_raw_handler_unregister);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment