aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/rc
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2017-06-25 09:31:45 -0300
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2017-10-04 13:53:32 -0300
commitb145ef94f63e02c2615ffde61a376b53f3367bc6 (patch)
tree259deba6c2ad61c67adf9ca78253e967c56ae55d /drivers/media/rc
parent615cd3fe6cccb950b46728120009a1805cce908e (diff)
[media] media: lirc_dev: make chunk_size and buffer_size mandatory
Make setting chunk_size and buffer_size mandatory for drivers which expect lirc_dev to allocate the lirc_buffer (i.e. ir-lirc-codec) and don't set them in lirc-zilog (which creates its own buffer). Also remove an unnecessary copy of chunk_size in struct irctl (the same information is already available from struct lirc_buffer). Signed-off-by: David Härdeman <david@hardeman.nu> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/rc')
-rw-r--r--drivers/media/rc/lirc_dev.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
index ffa203eb2045..1915ffc52955 100644
--- a/drivers/media/rc/lirc_dev.c
+++ b/drivers/media/rc/lirc_dev.c
@@ -41,7 +41,6 @@ struct irctl {
struct mutex irctl_lock;
struct lirc_buffer *buf;
bool buf_internal;
- unsigned int chunk_size;
struct device dev;
struct cdev cdev;
@@ -74,16 +73,8 @@ static void lirc_release(struct device *ld)
static int lirc_allocate_buffer(struct irctl *ir)
{
int err = 0;
- int bytes_in_key;
- unsigned int chunk_size;
- unsigned int buffer_size;
struct lirc_driver *d = &ir->d;
- bytes_in_key = BITS_TO_LONGS(d->code_length) +
- (d->code_length % 8 ? 1 : 0);
- buffer_size = d->buffer_size ? d->buffer_size : BUFLEN / bytes_in_key;
- chunk_size = d->chunk_size ? d->chunk_size : bytes_in_key;
-
if (d->rbuf) {
ir->buf = d->rbuf;
ir->buf_internal = false;
@@ -94,7 +85,7 @@ static int lirc_allocate_buffer(struct irctl *ir)
goto out;
}
- err = lirc_buffer_init(ir->buf, chunk_size, buffer_size);
+ err = lirc_buffer_init(ir->buf, d->chunk_size, d->buffer_size);
if (err) {
kfree(ir->buf);
ir->buf = NULL;
@@ -104,7 +95,6 @@ static int lirc_allocate_buffer(struct irctl *ir)
ir->buf_internal = true;
d->rbuf = ir->buf;
}
- ir->chunk_size = ir->buf->chunk_size;
out:
return err;
@@ -131,6 +121,16 @@ int lirc_register_driver(struct lirc_driver *d)
return -EINVAL;
}
+ if (!d->rbuf && d->chunk_size < 1) {
+ pr_err("chunk_size must be set!\n");
+ return -EINVAL;
+ }
+
+ if (!d->rbuf && d->buffer_size < 1) {
+ pr_err("buffer_size must be set!\n");
+ return -EINVAL;
+ }
+
if (d->code_length < 1 || d->code_length > (BUFLEN * 8)) {
dev_err(d->dev, "code length must be less than %d bits\n",
BUFLEN * 8);
@@ -407,7 +407,7 @@ ssize_t lirc_dev_fop_read(struct file *file,
dev_dbg(ir->d.dev, LOGHEAD "read called\n", ir->d.name, ir->d.minor);
- buf = kzalloc(ir->chunk_size, GFP_KERNEL);
+ buf = kzalloc(ir->buf->chunk_size, GFP_KERNEL);
if (!buf)
return -ENOMEM;
@@ -420,7 +420,7 @@ ssize_t lirc_dev_fop_read(struct file *file,
goto out_locked;
}
- if (length % ir->chunk_size) {
+ if (length % ir->buf->chunk_size) {
ret = -EINVAL;
goto out_locked;
}

Privacy Policy