Skip to content

Commit fe4526d

Browse files
Hans Verkuilmchehab
authored andcommitted
media: cec: core: disable adapter in cec_devnode_unregister
Explicitly disable the CEC adapter in cec_devnode_unregister() Usually this does not really do anything important, but for drivers that use the CEC pin framework this is needed to properly stop the hrtimer. Without this a crash would happen when such a driver is unloaded with rmmod. Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent ed17f89 commit fe4526d

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

drivers/media/cec/core/cec-adap.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1585,7 +1585,7 @@ static void cec_claim_log_addrs(struct cec_adapter *adap, bool block)
15851585
*
15861586
* This function is called with adap->lock held.
15871587
*/
1588-
static int cec_adap_enable(struct cec_adapter *adap)
1588+
int cec_adap_enable(struct cec_adapter *adap)
15891589
{
15901590
bool enable;
15911591
int ret = 0;
@@ -1595,6 +1595,9 @@ static int cec_adap_enable(struct cec_adapter *adap)
15951595
if (adap->needs_hpd)
15961596
enable = enable && adap->phys_addr != CEC_PHYS_ADDR_INVALID;
15971597

1598+
if (adap->devnode.unregistered)
1599+
enable = false;
1600+
15981601
if (enable == adap->is_enabled)
15991602
return 0;
16001603

drivers/media/cec/core/cec-core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ static void cec_devnode_unregister(struct cec_adapter *adap)
191191
mutex_lock(&adap->lock);
192192
__cec_s_phys_addr(adap, CEC_PHYS_ADDR_INVALID, false);
193193
__cec_s_log_addrs(adap, NULL, false);
194+
// Disable the adapter (since adap->devnode.unregistered is true)
195+
cec_adap_enable(adap);
194196
mutex_unlock(&adap->lock);
195197

196198
cdev_device_del(&devnode->cdev, &devnode->dev);

drivers/media/cec/core/cec-priv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ int cec_monitor_pin_cnt_inc(struct cec_adapter *adap);
4747
void cec_monitor_pin_cnt_dec(struct cec_adapter *adap);
4848
int cec_adap_status(struct seq_file *file, void *priv);
4949
int cec_thread_func(void *_adap);
50+
int cec_adap_enable(struct cec_adapter *adap);
5051
void __cec_s_phys_addr(struct cec_adapter *adap, u16 phys_addr, bool block);
5152
int __cec_s_log_addrs(struct cec_adapter *adap,
5253
struct cec_log_addrs *log_addrs, bool block);

0 commit comments

Comments
 (0)