aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/rc/ir-lirc-codec.c
diff options
context:
space:
mode:
authorSean Young <sean@mess.org>2017-09-26 07:44:20 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-12-14 09:58:35 -0500
commit9fbf8338be703bebbbbda7680495d14bb5517910 (patch)
tree597ce3f9397f2ba83531ad1ae65e7328b0a1ef12 /drivers/media/rc/ir-lirc-codec.c
parent8078af58f7994e389ea83afad54d666da401d13b (diff)
media: lirc: create rc-core open and close lirc functions
Replace the generic kernel lirc api with ones which use rc-core, further reducing the lirc_dev members. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/rc/ir-lirc-codec.c')
-rw-r--r--drivers/media/rc/ir-lirc-codec.c59
1 files changed, 57 insertions, 2 deletions
diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c
index ff74a5d7a0f3..1e921e4f8839 100644
--- a/drivers/media/rc/ir-lirc-codec.c
+++ b/drivers/media/rc/ir-lirc-codec.c
@@ -88,6 +88,61 @@ void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev)
wake_up_poll(&dev->wait_poll, POLLIN | POLLRDNORM);
}
+static int ir_lirc_open(struct inode *inode, struct file *file)
+{
+ struct lirc_dev *d = container_of(inode->i_cdev, struct lirc_dev, cdev);
+ struct rc_dev *dev = d->rdev;
+ int retval;
+
+ retval = rc_open(dev);
+ if (retval)
+ return retval;
+
+ retval = mutex_lock_interruptible(&dev->lock);
+ if (retval)
+ goto out_rc;
+
+ if (!dev->registered) {
+ retval = -ENODEV;
+ goto out_unlock;
+ }
+
+ if (dev->lirc_open) {
+ retval = -EBUSY;
+ goto out_unlock;
+ }
+
+ if (dev->driver_type == RC_DRIVER_IR_RAW)
+ kfifo_reset_out(&dev->rawir);
+
+ dev->lirc_open++;
+ file->private_data = dev;
+
+ nonseekable_open(inode, file);
+ mutex_unlock(&dev->lock);
+
+ return 0;
+
+out_unlock:
+ mutex_unlock(&dev->lock);
+out_rc:
+ rc_close(dev);
+ return retval;
+}
+
+static int ir_lirc_close(struct inode *inode, struct file *file)
+{
+ struct rc_dev *dev = file->private_data;
+
+ mutex_lock(&dev->lock);
+ dev->lirc_open--;
+ mutex_unlock(&dev->lock);
+
+ rc_close(dev);
+
+ return 0;
+}
+
static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf,
size_t n, loff_t *ppos)
{
@@ -477,8 +532,8 @@ static const struct file_operations lirc_fops = {
#endif
.read = ir_lirc_read,
.poll = ir_lirc_poll,
- .open = lirc_dev_fop_open,
- .release = lirc_dev_fop_close,
+ .open = ir_lirc_open,
+ .release = ir_lirc_close,
.llseek = no_llseek,
};

Privacy Policy