summaryrefslogtreecommitdiff
path: root/drivers/staging/media
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2017-06-25 09:32:36 -0300
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2017-10-04 14:53:07 -0300
commitb15e39379fe8700fe0ec849a5c5ee2b44cd16381 (patch)
treeef7d8a0a058a048db765dd87af0bad28727dd39a /drivers/staging/media
parent13f96555d6faa6dc57fb5faedf728447a3188230 (diff)
[media] media: lirc_dev: merge struct irctl into struct lirc_dev
The use of two separate structs (lirc_dev aka lirc_driver and irctl) makes it much harder to follow the proper lifetime of the various structs and necessitates hacks such as keeping a copy of struct lirc_dev inside struct irctl. Merging the two structs means that lirc_dev can properly manage the lifetime of the resulting struct and simplifies the code at the same time. [mchehab@s-opensource.com: fix merge conflict] 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/staging/media')
-rw-r--r--drivers/staging/media/lirc/lirc_zilog.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/drivers/staging/media/lirc/lirc_zilog.c b/drivers/staging/media/lirc/lirc_zilog.c
index 00e8c8f224b7..6bd0717bf76e 100644
--- a/drivers/staging/media/lirc/lirc_zilog.c
+++ b/drivers/staging/media/lirc/lirc_zilog.c
@@ -184,10 +184,8 @@ static void release_ir_device(struct kref *ref)
* ir->open_count == 0 - happens on final close()
* ir_lock, tx_ref_lock, rx_ref_lock, all released
*/
- if (ir->l) {
+ if (ir->l)
lirc_unregister_device(ir->l);
- lirc_free_device(ir->l);
- }
if (kfifo_initialized(&ir->rbuf.fifo))
lirc_buffer_free(&ir->rbuf);
@@ -318,7 +316,7 @@ static int add_to_buf(struct IR *ir)
int ret;
int failures = 0;
unsigned char sendbuf[1] = { 0 };
- struct lirc_buffer *rbuf = ir->l->rbuf;
+ struct lirc_buffer *rbuf = ir->l->buf;
struct IR_rx *rx;
struct IR_tx *tx;
@@ -464,7 +462,7 @@ static int add_to_buf(struct IR *ir)
static int lirc_thread(void *arg)
{
struct IR *ir = arg;
- struct lirc_buffer *rbuf = ir->l->rbuf;
+ struct lirc_buffer *rbuf = ir->l->buf;
dev_dbg(ir->dev, "poll thread started\n");
@@ -885,7 +883,7 @@ static ssize_t read(struct file *filep, char __user *outbuf, size_t n,
{
struct IR *ir = lirc_get_pdata(filep);
struct IR_rx *rx;
- struct lirc_buffer *rbuf = ir->l->rbuf;
+ struct lirc_buffer *rbuf = ir->l->buf;
int ret = 0, written = 0, retries = 0;
unsigned int m;
DECLARE_WAITQUEUE(wait, current);
@@ -1203,7 +1201,7 @@ static unsigned int poll(struct file *filep, poll_table *wait)
{
struct IR *ir = lirc_get_pdata(filep);
struct IR_rx *rx;
- struct lirc_buffer *rbuf = ir->l->rbuf;
+ struct lirc_buffer *rbuf = ir->l->buf;
unsigned int ret;
dev_dbg(ir->dev, "%s called\n", __func__);
@@ -1449,6 +1447,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
ir->l->code_length = 13;
ir->l->fops = &lirc_fops;
ir->l->owner = THIS_MODULE;
+ ir->l->dev.parent = &adap->dev;
/*
* FIXME this is a pointer reference to us, but no refcount.
@@ -1456,13 +1455,12 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
* This OK for now, since lirc_dev currently won't touch this
* buffer as we provide our own lirc_fops.
*
- * Currently our own lirc_fops rely on this ir->l->rbuf pointer
+ * Currently our own lirc_fops rely on this ir->l->buf pointer
*/
- ir->l->rbuf = &ir->rbuf;
- ir->l->dev = &adap->dev;
+ ir->l->buf = &ir->rbuf;
/* This will be returned by lirc_get_pdata() */
ir->l->data = ir;
- ret = lirc_buffer_init(ir->l->rbuf, 2, BUFLEN / 2);
+ ret = lirc_buffer_init(ir->l->buf, 2, BUFLEN / 2);
if (ret) {
lirc_free_device(ir->l);
ir->l = NULL;