Skip to content

Commit a6927d8

Browse files
seanyoungmchehab
authored andcommitted
media: rc: i2c: only poll if the rc device is opened
The lirc_zilog driver only polls the device if the lirc chardev is opened; do the same with the rc-core driver. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
1 parent 50a762b commit a6927d8

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

drivers/media/i2c/ir-kbd-i2c.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,22 @@ static void ir_work(struct work_struct *work)
298298
schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling_interval));
299299
}
300300

301+
static int ir_open(struct rc_dev *dev)
302+
{
303+
struct IR_i2c *ir = dev->priv;
304+
305+
schedule_delayed_work(&ir->work, 0);
306+
307+
return 0;
308+
}
309+
310+
static void ir_close(struct rc_dev *dev)
311+
{
312+
struct IR_i2c *ir = dev->priv;
313+
314+
cancel_delayed_work_sync(&ir->work);
315+
}
316+
301317
/* ----------------------------------------------------------------------- */
302318

303319
static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
@@ -441,6 +457,9 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
441457
rc->input_phys = ir->phys;
442458
rc->device_name = name;
443459
rc->dev.parent = &client->dev;
460+
rc->priv = ir;
461+
rc->open = ir_open;
462+
rc->close = ir_close;
444463

445464
/*
446465
* Initialize the other fields of rc_dev
@@ -450,14 +469,12 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
450469
if (!rc->driver_name)
451470
rc->driver_name = KBUILD_MODNAME;
452471

472+
INIT_DELAYED_WORK(&ir->work, ir_work);
473+
453474
err = rc_register_device(rc);
454475
if (err)
455476
goto err_out_free;
456477

457-
/* start polling via eventd */
458-
INIT_DELAYED_WORK(&ir->work, ir_work);
459-
schedule_delayed_work(&ir->work, 0);
460-
461478
return 0;
462479

463480
err_out_free:

0 commit comments

Comments
 (0)