diff options
Diffstat (limited to 'drivers/media/cec/cec-api.c')
-rw-r--r-- | drivers/media/cec/cec-api.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/drivers/media/cec/cec-api.c b/drivers/media/cec/cec-api.c index 8950b6c9d6a9..0860fb458757 100644 --- a/drivers/media/cec/cec-api.c +++ b/drivers/media/cec/cec-api.c @@ -198,7 +198,11 @@ static long cec_transmit(struct cec_adapter *adap, struct cec_fh *fh, return -EINVAL; mutex_lock(&adap->lock); - if (!adap->is_configured) + if (adap->log_addrs.num_log_addrs == 0) + err = -EPERM; + else if (adap->is_configuring) + err = -ENONET; + else if (!adap->is_configured && msg.msg[0] != 0xf0) err = -ENONET; else if (cec_is_busy(adap, fh)) err = -EBUSY; @@ -515,9 +519,18 @@ static int cec_open(struct inode *inode, struct file *filp) return err; } + mutex_lock(&devnode->lock); + if (list_empty(&devnode->fhs) && + adap->phys_addr == CEC_PHYS_ADDR_INVALID) { + err = adap->ops->adap_enable(adap, true); + if (err) { + mutex_unlock(&devnode->lock); + kfree(fh); + return err; + } + } filp->private_data = fh; - mutex_lock(&devnode->lock); /* Queue up initial state events */ ev_state.state_change.phys_addr = adap->phys_addr; ev_state.state_change.log_addr_mask = adap->log_addrs.log_addr_mask; @@ -551,6 +564,10 @@ static int cec_release(struct inode *inode, struct file *filp) mutex_lock(&devnode->lock); list_del(&fh->list); + if (list_empty(&devnode->fhs) && + adap->phys_addr == CEC_PHYS_ADDR_INVALID) { + WARN_ON(adap->ops->adap_enable(adap, false)); + } mutex_unlock(&devnode->lock); /* Unhook pending transmits from this filehandle. */ |