V4L/DVB: ir-core: Add callbacks for input/evdev open/close on IR core
Especially when IR needs to do polling, it generates lots of wakeups per
second. This makes no sense, if the input event device is closed.
Adds a callback handler to the IR hardware driver, to allow registering
an open/close ops.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
diff --git a/drivers/media/IR/ir-keytable.c b/drivers/media/IR/ir-keytable.c
index fcb0f0c..99cad82 100644
--- a/drivers/media/IR/ir-keytable.c
+++ b/drivers/media/IR/ir-keytable.c
@@ -446,6 +446,19 @@
}
EXPORT_SYMBOL_GPL(ir_keydown);
+static int ir_open(struct input_dev *input_dev)
+{
+ struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
+
+ return ir_dev->props->open(ir_dev->props->priv);
+}
+
+static void ir_close(struct input_dev *input_dev)
+{
+ struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
+
+ ir_dev->props->close(ir_dev->props->priv);
+}
/**
* ir_input_register() - sets the IR keycode table and add the handlers
@@ -495,6 +508,10 @@
ir_copy_table(&ir_dev->rc_tab, rc_tab);
ir_dev->props = props;
+ if (props && props->open)
+ input_dev->open = ir_open;
+ if (props && props->close)
+ input_dev->close = ir_close;
/* set the bits for the keys */
IR_dprintk(1, "key map size: %d\n", rc_tab->size);