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

media: cec: core: add adap_unconfigured() callback

The adap_configured() callback was called with the adap->lock mutex
held if the 'configured' argument was false, and without the adap->lock
mutex held if that argument was true.

That was very confusing, and so split this up in a adap_unconfigured()
callback and a high-level configured() callback.

This also makes it easier to understand when the mutex is held: all
low-level adap_* callbacks are called with the mutex held. All other
callbacks are called without that mutex held.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Fixes: f1b57164305d ("media: cec: add optional adap_configured callback")
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
948a77aa da53c36d

+5 -4
+2 -2
drivers/media/cec/core/cec-adap.c
··· 1348 1348 cec_flush(adap); 1349 1349 wake_up_interruptible(&adap->kthread_waitq); 1350 1350 cec_post_state_event(adap); 1351 - call_void_op(adap, adap_configured, false); 1351 + call_void_op(adap, adap_unconfigured); 1352 1352 } 1353 1353 1354 1354 /* ··· 1539 1539 adap->kthread_config = NULL; 1540 1540 complete(&adap->config_completion); 1541 1541 mutex_unlock(&adap->lock); 1542 - call_void_op(adap, adap_configured, true); 1542 + call_void_op(adap, configured); 1543 1543 return 0; 1544 1544 1545 1545 unconfigure:
+3 -2
include/media/cec.h
··· 113 113 #define CEC_FREE_TIME_TO_USEC(ft) ((ft) * 2400) 114 114 115 115 struct cec_adap_ops { 116 - /* Low-level callbacks */ 116 + /* Low-level callbacks, called with adap->lock held */ 117 117 int (*adap_enable)(struct cec_adapter *adap, bool enable); 118 118 int (*adap_monitor_all_enable)(struct cec_adapter *adap, bool enable); 119 119 int (*adap_monitor_pin_enable)(struct cec_adapter *adap, bool enable); 120 120 int (*adap_log_addr)(struct cec_adapter *adap, u8 logical_addr); 121 - void (*adap_configured)(struct cec_adapter *adap, bool configured); 121 + void (*adap_unconfigured)(struct cec_adapter *adap); 122 122 int (*adap_transmit)(struct cec_adapter *adap, u8 attempts, 123 123 u32 signal_free_time, struct cec_msg *msg); 124 124 void (*adap_nb_transmit_canceled)(struct cec_adapter *adap, ··· 131 131 bool (*error_inj_parse_line)(struct cec_adapter *adap, char *line); 132 132 133 133 /* High-level CEC message callback, called without adap->lock held */ 134 + void (*configured)(struct cec_adapter *adap); 134 135 int (*received)(struct cec_adapter *adap, struct cec_msg *msg); 135 136 }; 136 137