Skip to contentSkip to conversation

media: rc: Pospone ir raw decoders loading until really needed

PATCH Superseded Ezequiel Garcia 3 participants 4 messages Mar 15, 2012

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: rc: Pospone ir raw decoders loading until really needed

This changes rc_core to not load the IR decoders at load time, postponing it to load only if a RC_DRIVER_IR_RAW device is registered via rc_register_device.

---
 drivers/media/rc/rc-main.c |    8 ++++++--
 include/media/rc-core.h    |    2 ++
 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/media/rc/rc-main.c +6 -2
index f6a930b..adf4a99 100644
@@ -1103,6 +1103,12 @@ int rc_register_device(struct rc_dev *dev)
 	kfree(path);
 
 	if (dev->driver_type == RC_DRIVER_IR_RAW) {
+		/* Load raw decoders, if they aren't already */
+		if (dev->raw_init) {
+			IR_dprintk(1, "Loading raw decoders\n");
+			ir_raw_init();
+			dev->raw_init = true;
+		}
 		rc = ir_raw_event_register(dev);
 		if (rc < 0)
 			goto out_input;
@@ -1176,8 +1182,6 @@ static int __init rc_core_init(void)
 		return rc;
 	}
 
-	/* Initialize/load the decoders/keymap code that will be used */
-	ir_raw_init();
 	rc_map_register(&empty_map);
 
 	return 0;
include/media/rc-core.h +2 -0
index b0c494a..71c99c1 100644
@@ -47,6 +47,7 @@ enum rc_driver_type {
  *	anyone can call show_protocols or store_protocols
  * @devno: unique remote control device number
  * @raw: additional data for raw pulse/space devices
+ * @raw_init: used to load raw decoders modules if needed
  * @input_dev: the input child device used to communicate events to userspace
  * @driver_type: specifies if protocol decoding is done in hardware or software
  * @idle: used to keep track of RX state
@@ -95,6 +96,7 @@ struct rc_dev {
 	struct mutex			lock;
 	unsigned long			devno;
 	struct ir_raw_event_ctrl	*raw;
+	bool				raw_init;
 	struct input_dev		*input_dev;
 	enum rc_driver_type		driver_type;
 	bool				idle;
Signature · 1 line
1.7.3.4
#1 lore raw

Em 15-03-2012 16:39, Ezequiel Garcia escreveu:

Quoted 15 lines

This changes rc_core to not load the IR decoders at load time, postponing it to load only if a RC_DRIVER_IR_RAW device is registered via rc_register_device.

---
 drivers/media/rc/rc-main.c |    8 ++++++--
 include/media/rc-core.h    |    2 ++
 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/media/rc/rc-main.c +0 -0
index f6a930b..adf4a99 100644

drivers/media/rc/rc-main.c int rc_register_device(struct rc_dev *dev) · line 1107

Quoted 5 lines
drivers/media/rc/rc-main.c +2 -0
@@ -1103,6 +1103,12 @@ int rc_register_device(struct rc_dev *dev)
 	kfree(path);
 
 	if (dev->driver_type == RC_DRIVER_IR_RAW) {
+		/* Load raw decoders, if they aren't already */
+		if (dev->raw_init) {

The logic here seems to be inverted. it should be, instead !dev->raw_init.

Quoted 36 lines
drivers/media/rc/rc-main.c +4 -2
+			IR_dprintk(1, "Loading raw decoders\n");
+			ir_raw_init();
+			dev->raw_init = true;
+		}
 		rc = ir_raw_event_register(dev);
 		if (rc < 0)
 			goto out_input;
@@ -1176,8 +1182,6 @@ static int __init rc_core_init(void)
 		return rc;
 	}
 
-	/* Initialize/load the decoders/keymap code that will be used */
-	ir_raw_init();
 	rc_map_register(&empty_map);
 
 	return 0;
include/media/rc-core.h +2 -0
index b0c494a..71c99c1 100644
@@ -47,6 +47,7 @@ enum rc_driver_type {
  *	anyone can call show_protocols or store_protocols
  * @devno: unique remote control device number
  * @raw: additional data for raw pulse/space devices
+ * @raw_init: used to load raw decoders modules if needed
  * @input_dev: the input child device used to communicate events to userspace
  * @driver_type: specifies if protocol decoding is done in hardware or software
  * @idle: used to keep track of RX state
@@ -95,6 +96,7 @@ struct rc_dev {
 	struct mutex			lock;
 	unsigned long			devno;
 	struct ir_raw_event_ctrl	*raw;
+	bool				raw_init;
 	struct input_dev		*input_dev;
 	enum rc_driver_type		driver_type;
 	bool				idle;
#3 lore raw
In reply to Ezequiel Garcia
Quoted 28 lines · Ezequiel Garcia

This changes rc_core to not load the IR decoders at load time, postponing it to load only if a RC_DRIVER_IR_RAW device is registered via rc_register_device.

---
 drivers/media/rc/rc-main.c |    8 ++++++--
 include/media/rc-core.h    |    2 ++
 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/media/rc/rc-main.c +6 -0
index f6a930b..adf4a99 100644
@@ -1103,6 +1103,12 @@ int rc_register_device(struct rc_dev *dev)
 	kfree(path);
 
 	if (dev->driver_type == RC_DRIVER_IR_RAW) {
+		/* Load raw decoders, if they aren't already */
+		if (dev->raw_init) {
+			IR_dprintk(1, "Loading raw decoders\n");
+			ir_raw_init();
+			dev->raw_init = true;
+		}
 		rc = ir_raw_event_register(dev);
 		if (rc < 0)
 			goto out_input;

drivers/media/rc/rc-main.c static int __init rc_core_init(void) · line 1187

Quoted 8 lines
drivers/media/rc/rc-main.c +0 -2
@@ -1176,8 +1182,6 @@ static int __init rc_core_init(void)
 		return rc;
 	}
 
-	/* Initialize/load the decoders/keymap code that will be used */
-	ir_raw_init();
 	rc_map_register(&empty_map);
 
 	return 0;

Uhm. How does this ever actually work? The only place I see raw_init set to true is inside a conditional that requires it already be true. That's not going to fly.

Signature · 2 lines
Jarod Wilson
[email protected]
#2 lore raw
In reply to Mauro Carvalho Chehab
Quoted 5 lines
Quoted 3 lines

      if (dev->driver_type == RC_DRIVER_IR_RAW) {
+             /* Load raw decoders, if they aren't already */
+             if (dev->raw_init) {

The logic here seems to be inverted. it should be, instead !dev->raw_init.

Duh! Sorry about that. I'm *way* too accustomed to test things first. Will pay more attention in the future.

Thanks for the review. I'm resending it now.
Ezequiel.