Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

authored by

Heiner Kallweit and committed by
Mauro Carvalho Chehab
37e90a22 8a5d2ace

+4 -13
+4 -13
drivers/media/rc/rc-ir-raw.c
··· 26 26 /* Used to handle IR raw handler extensions */ 27 27 static DEFINE_MUTEX(ir_raw_handler_lock); 28 28 static LIST_HEAD(ir_raw_handler_list); 29 - static DEFINE_MUTEX(available_protocols_lock); 30 - static u64 available_protocols; 29 + static atomic64_t available_protocols = ATOMIC64_INIT(0); 31 30 32 31 static int ir_raw_event_thread(void *data) 33 32 { ··· 233 234 u64 234 235 ir_raw_get_allowed_protocols(void) 235 236 { 236 - u64 protocols; 237 - mutex_lock(&available_protocols_lock); 238 - protocols = available_protocols; 239 - mutex_unlock(&available_protocols_lock); 240 - return protocols; 237 + return atomic64_read(&available_protocols); 241 238 } 242 239 243 240 static int change_protocol(struct rc_dev *dev, u64 *rc_type) ··· 326 331 if (ir_raw_handler->raw_register) 327 332 list_for_each_entry(raw, &ir_raw_client_list, list) 328 333 ir_raw_handler->raw_register(raw->dev); 329 - mutex_lock(&available_protocols_lock); 330 - available_protocols |= ir_raw_handler->protocols; 331 - mutex_unlock(&available_protocols_lock); 334 + atomic64_or(ir_raw_handler->protocols, &available_protocols); 332 335 mutex_unlock(&ir_raw_handler_lock); 333 336 334 337 return 0; ··· 345 352 if (ir_raw_handler->raw_unregister) 346 353 ir_raw_handler->raw_unregister(raw->dev); 347 354 } 348 - mutex_lock(&available_protocols_lock); 349 - available_protocols &= ~protocols; 350 - mutex_unlock(&available_protocols_lock); 355 + atomic64_andnot(protocols, &available_protocols); 351 356 mutex_unlock(&ir_raw_handler_lock); 352 357 } 353 358 EXPORT_SYMBOL(ir_raw_handler_unregister);