Loading drivers/media/cec/core/cec-api.c +2 −2 Original line number Diff line number Diff line Loading @@ -580,7 +580,7 @@ static int cec_open(struct inode *inode, struct file *filp) fh->mode_initiator = CEC_MODE_INITIATOR; fh->adap = adap; err = cec_get_device(devnode); err = cec_get_device(adap); if (err) { kfree(fh); return err; Loading Loading @@ -686,7 +686,7 @@ static int cec_release(struct inode *inode, struct file *filp) mutex_unlock(&fh->lock); kfree(fh); cec_put_device(devnode); cec_put_device(adap); filp->private_data = NULL; return 0; } Loading drivers/media/cec/core/cec-core.c +0 −29 Original line number Diff line number Diff line Loading @@ -51,35 +51,6 @@ static struct dentry *top_cec_dir; /* dev to cec_devnode */ #define to_cec_devnode(cd) container_of(cd, struct cec_devnode, dev) int cec_get_device(struct cec_devnode *devnode) { /* * Check if the cec device is available. This needs to be done with * the devnode->lock held to prevent an open/unregister race: * without the lock, the device could be unregistered and freed between * the devnode->registered check and get_device() calls, leading to * a crash. */ mutex_lock(&devnode->lock); /* * return ENODEV if the cec device has been removed * already or if it is not registered anymore. */ if (!devnode->registered) { mutex_unlock(&devnode->lock); return -ENODEV; } /* and increase the device refcount */ get_device(&devnode->dev); mutex_unlock(&devnode->lock); return 0; } void cec_put_device(struct cec_devnode *devnode) { put_device(&devnode->dev); } /* Called when the last user of the cec device exits. */ static void cec_devnode_release(struct device *cd) { Loading drivers/media/cec/core/cec-priv.h +0 −2 Original line number Diff line number Diff line Loading @@ -37,8 +37,6 @@ static inline bool msg_is_raw(const struct cec_msg *msg) /* cec-core.c */ extern int cec_debug; int cec_get_device(struct cec_devnode *devnode); void cec_put_device(struct cec_devnode *devnode); /* cec-adap.c */ int cec_monitor_all_cnt_inc(struct cec_adapter *adap); Loading include/media/cec.h +31 −0 Original line number Diff line number Diff line Loading @@ -298,6 +298,37 @@ struct cec_adapter { char input_phys[40]; }; static inline int cec_get_device(struct cec_adapter *adap) { struct cec_devnode *devnode = &adap->devnode; /* * Check if the cec device is available. This needs to be done with * the devnode->lock held to prevent an open/unregister race: * without the lock, the device could be unregistered and freed between * the devnode->registered check and get_device() calls, leading to * a crash. */ mutex_lock(&devnode->lock); /* * return ENODEV if the cec device has been removed * already or if it is not registered anymore. */ if (!devnode->registered) { mutex_unlock(&devnode->lock); return -ENODEV; } /* and increase the device refcount */ get_device(&devnode->dev); mutex_unlock(&devnode->lock); return 0; } static inline void cec_put_device(struct cec_adapter *adap) { put_device(&adap->devnode.dev); } static inline void *cec_get_drvdata(const struct cec_adapter *adap) { return adap->priv; Loading Loading
drivers/media/cec/core/cec-api.c +2 −2 Original line number Diff line number Diff line Loading @@ -580,7 +580,7 @@ static int cec_open(struct inode *inode, struct file *filp) fh->mode_initiator = CEC_MODE_INITIATOR; fh->adap = adap; err = cec_get_device(devnode); err = cec_get_device(adap); if (err) { kfree(fh); return err; Loading Loading @@ -686,7 +686,7 @@ static int cec_release(struct inode *inode, struct file *filp) mutex_unlock(&fh->lock); kfree(fh); cec_put_device(devnode); cec_put_device(adap); filp->private_data = NULL; return 0; } Loading
drivers/media/cec/core/cec-core.c +0 −29 Original line number Diff line number Diff line Loading @@ -51,35 +51,6 @@ static struct dentry *top_cec_dir; /* dev to cec_devnode */ #define to_cec_devnode(cd) container_of(cd, struct cec_devnode, dev) int cec_get_device(struct cec_devnode *devnode) { /* * Check if the cec device is available. This needs to be done with * the devnode->lock held to prevent an open/unregister race: * without the lock, the device could be unregistered and freed between * the devnode->registered check and get_device() calls, leading to * a crash. */ mutex_lock(&devnode->lock); /* * return ENODEV if the cec device has been removed * already or if it is not registered anymore. */ if (!devnode->registered) { mutex_unlock(&devnode->lock); return -ENODEV; } /* and increase the device refcount */ get_device(&devnode->dev); mutex_unlock(&devnode->lock); return 0; } void cec_put_device(struct cec_devnode *devnode) { put_device(&devnode->dev); } /* Called when the last user of the cec device exits. */ static void cec_devnode_release(struct device *cd) { Loading
drivers/media/cec/core/cec-priv.h +0 −2 Original line number Diff line number Diff line Loading @@ -37,8 +37,6 @@ static inline bool msg_is_raw(const struct cec_msg *msg) /* cec-core.c */ extern int cec_debug; int cec_get_device(struct cec_devnode *devnode); void cec_put_device(struct cec_devnode *devnode); /* cec-adap.c */ int cec_monitor_all_cnt_inc(struct cec_adapter *adap); Loading
include/media/cec.h +31 −0 Original line number Diff line number Diff line Loading @@ -298,6 +298,37 @@ struct cec_adapter { char input_phys[40]; }; static inline int cec_get_device(struct cec_adapter *adap) { struct cec_devnode *devnode = &adap->devnode; /* * Check if the cec device is available. This needs to be done with * the devnode->lock held to prevent an open/unregister race: * without the lock, the device could be unregistered and freed between * the devnode->registered check and get_device() calls, leading to * a crash. */ mutex_lock(&devnode->lock); /* * return ENODEV if the cec device has been removed * already or if it is not registered anymore. */ if (!devnode->registered) { mutex_unlock(&devnode->lock); return -ENODEV; } /* and increase the device refcount */ get_device(&devnode->dev); mutex_unlock(&devnode->lock); return 0; } static inline void cec_put_device(struct cec_adapter *adap) { put_device(&adap->devnode.dev); } static inline void *cec_get_drvdata(const struct cec_adapter *adap) { return adap->priv; Loading