* [PATCH v2] media: rc: Pospone ir raw decoders loading until really needed
@ 2012-03-15 20:53 Ezequiel Garcia
2012-03-15 21:35 ` Jarod Wilson
0 siblings, 1 reply; 4+ messages in thread
From: Ezequiel Garcia @ 2012-03-15 20:53 UTC (permalink / raw)
To: mchehab; +Cc: jarod, linux-media, 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.
We use a static boolean variable, to ensure decoders modules
are only loaded once.
Tested with rc-loopback device only.
Signed-off-by: Ezequiel Garcia <elezegarcia@gmail.com>
---
v2: Fix broken logic in v1.
Also, put raw_init as static instead of inside rc_dev
struct to ensure loading is only tried the first time.
---
drivers/media/rc/rc-main.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index f6a930b..d366d53 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -32,6 +32,9 @@
static LIST_HEAD(rc_map_list);
static DEFINE_SPINLOCK(rc_map_lock);
+/* Used to load raw decoders modules only if needed */
+static bool raw_init;
+
static struct rc_map_list *seek_rc_map(const char *name)
{
struct rc_map_list *map = NULL;
@@ -1103,6 +1106,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 (!raw_init) {
+ IR_dprintk(1, "Loading raw decoders\n");
+ ir_raw_init();
+ raw_init = true;
+ }
rc = ir_raw_event_register(dev);
if (rc < 0)
goto out_input;
@@ -1176,8 +1185,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;
--
1.7.3.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] media: rc: Pospone ir raw decoders loading until really needed
2012-03-15 20:53 [PATCH v2] media: rc: Pospone ir raw decoders loading until really needed Ezequiel Garcia
@ 2012-03-15 21:35 ` Jarod Wilson
2012-03-15 21:42 ` Ezequiel García
0 siblings, 1 reply; 4+ messages in thread
From: Jarod Wilson @ 2012-03-15 21:35 UTC (permalink / raw)
To: Ezequiel Garcia; +Cc: mchehab, linux-media
On Thu, Mar 15, 2012 at 05:53:49PM -0300, Ezequiel Garcia wrote:
> 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.
> We use a static boolean variable, to ensure decoders modules
> are only loaded once.
> Tested with rc-loopback device only.
>
> Signed-off-by: Ezequiel Garcia <elezegarcia@gmail.com>
> ---
> v2: Fix broken logic in v1.
> Also, put raw_init as static instead of inside rc_dev
> struct to ensure loading is only tried the first time.
> ---
> drivers/media/rc/rc-main.c | 11 +++++++++--
> 1 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
> index f6a930b..d366d53 100644
> --- a/drivers/media/rc/rc-main.c
> +++ b/drivers/media/rc/rc-main.c
> @@ -32,6 +32,9 @@
> static LIST_HEAD(rc_map_list);
> static DEFINE_SPINLOCK(rc_map_lock);
>
> +/* Used to load raw decoders modules only if needed */
> +static bool raw_init;
> +
> static struct rc_map_list *seek_rc_map(const char *name)
> {
> struct rc_map_list *map = NULL;
> @@ -1103,6 +1106,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 (!raw_init) {
> + IR_dprintk(1, "Loading raw decoders\n");
I think this is slightly redundant, since we already print something for
each of the decoders loaded, but eh, its a debug printk, maybe you're
debugging why none are loading, so its good to know you're reaching the
call to ir_raw_init...
So yeah, ok, I'm fine with this. Haven't tested it with actual raw IR
hardware, but I don't see any reason it wouldn't work.
Acked-by: Jarod Wilson <jarod@redhat.com>
> + ir_raw_init();
> + raw_init = true;
> + }
> rc = ir_raw_event_register(dev);
> if (rc < 0)
> goto out_input;
> @@ -1176,8 +1185,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;
--
Jarod Wilson
jarod@redhat.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] media: rc: Pospone ir raw decoders loading until really needed
2012-03-15 21:35 ` Jarod Wilson
@ 2012-03-15 21:42 ` Ezequiel García
2012-03-15 22:43 ` Jarod Wilson
0 siblings, 1 reply; 4+ messages in thread
From: Ezequiel García @ 2012-03-15 21:42 UTC (permalink / raw)
To: Jarod Wilson; +Cc: mchehab, linux-media
Hi Jarod,
On Thu, Mar 15, 2012 at 6:35 PM, Jarod Wilson <jarod@redhat.com> wrote:
>
> So yeah, ok, I'm fine with this. Haven't tested it with actual raw IR
> hardware, but I don't see any reason it wouldn't work.
>
> Acked-by: Jarod Wilson <jarod@redhat.com>
Thanks for the feedback.
I have a paranoid question: Is it ok to solve this with a static variable?
I don't like static (as I fear globals), but in this case I saw no
cleaner solution.
Thanks again,
Ezequiel.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] media: rc: Pospone ir raw decoders loading until really needed
2012-03-15 21:42 ` Ezequiel García
@ 2012-03-15 22:43 ` Jarod Wilson
0 siblings, 0 replies; 4+ messages in thread
From: Jarod Wilson @ 2012-03-15 22:43 UTC (permalink / raw)
To: Ezequiel García
Cc: Jarod Wilson, mchehab@infradead.org, linux-media@vger.kernel.org
On Mar 15, 2012, at 5:42 PM, Ezequiel García <elezegarcia@gmail.com> wrote:
> Hi Jarod,
>
> On Thu, Mar 15, 2012 at 6:35 PM, Jarod Wilson <jarod@redhat.com> wrote:
>>
>> So yeah, ok, I'm fine with this. Haven't tested it with actual raw IR
>> hardware, but I don't see any reason it wouldn't work.
>>
>> Acked-by: Jarod Wilson <jarod@redhat.com>
>
> Thanks for the feedback.
> I have a paranoid question: Is it ok to solve this with a static variable?
> I don't like static (as I fear globals), but in this case I saw no
> cleaner solution.
Ah, actually... I think you could avoid the global and just make it function-local, since no others access it, and be just as functional.
-j
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-03-15 22:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-15 20:53 [PATCH v2] media: rc: Pospone ir raw decoders loading until really needed Ezequiel Garcia
2012-03-15 21:35 ` Jarod Wilson
2012-03-15 21:42 ` Ezequiel García
2012-03-15 22:43 ` Jarod Wilson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox