aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Young <sean@mess.org>2017-10-17 16:31:20 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-12-14 09:58:19 -0500
commita6927d81c0073c89a468ff558212f230941a941f (patch)
tree596e02cc2b4a6099b046b59cbda15ba135cad942
parent50a762b413ad7ed137e75b79b1aa50cf4b1e2b73 (diff)
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>
-rw-r--r--drivers/media/i2c/ir-kbd-i2c.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index 1b8cd1b75bfb..22f32717638a 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -298,6 +298,22 @@ static void ir_work(struct work_struct *work)
schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling_interval));
}
+static int ir_open(struct rc_dev *dev)
+{
+ struct IR_i2c *ir = dev->priv;
+
+ schedule_delayed_work(&ir->work, 0);
+
+ return 0;
+}
+
+static void ir_close(struct rc_dev *dev)
+{
+ struct IR_i2c *ir = dev->priv;
+
+ cancel_delayed_work_sync(&ir->work);
+}
+
/* ----------------------------------------------------------------------- */
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)
rc->input_phys = ir->phys;
rc->device_name = name;
rc->dev.parent = &client->dev;
+ rc->priv = ir;
+ rc->open = ir_open;
+ rc->close = ir_close;
/*
* 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)
if (!rc->driver_name)
rc->driver_name = KBUILD_MODNAME;
+ INIT_DELAYED_WORK(&ir->work, ir_work);
+
err = rc_register_device(rc);
if (err)
goto err_out_free;
- /* start polling via eventd */
- INIT_DELAYED_WORK(&ir->work, ir_work);
- schedule_delayed_work(&ir->work, 0);
-
return 0;
err_out_free:

Privacy Policy