From: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
To: "David Härdeman" <david@hardeman.nu>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH] rc-core: improve the lirc protocol reporting
Date: Tue, 11 Aug 2015 13:27:12 -0300 [thread overview]
Message-ID: <20150811132712.52cf4e4b@recife.lan> (raw)
In-Reply-To: <20150722205524.1907.37521.stgit@zeus.muc.hardeman.nu>
Hi David,
Em Wed, 22 Jul 2015 22:55:24 +0200
David Härdeman <david@hardeman.nu> escreveu:
> Commit 275ddb40bcf686d210d86c6718e42425a6a0bc76 removed the lirc
> "protocol" but kept backwards compatibility by always listing
> the protocol as present and enabled. This patch further improves
> the logic by only listing the protocol if the lirc module is loaded
> (or if lirc is builtin).
Makes sense, but see below.
>
> Signed-off-by: David Härdeman <david@hardeman.nu>
> ---
> drivers/media/rc/rc-main.c | 19 ++++++++++++++++++-
> 1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
> index ecaee02..3f0f71a 100644
> --- a/drivers/media/rc/rc-main.c
> +++ b/drivers/media/rc/rc-main.c
> @@ -828,6 +828,23 @@ struct rc_filter_attribute {
> .mask = (_mask), \
> }
>
> +static bool lirc_is_present(void)
> +{
> +#if defined(CONFIG_LIRC_MODULE)
> + struct module *lirc;
> +
> + mutex_lock(&module_mutex);
> + lirc = find_module("lirc_dev");
> + mutex_unlock(&module_mutex);
I don't think it would be a good idea to play with the module mutex
lock here or calling find_module(). This is something that no other driver
does (well, except for FB DRM driver, that dynamically loads a module
if not found).
Perhaps we could use some simpler logic, like storing some value if lirc
got loaded or not (worse case, we might use a static atomic var at rc core).
> +
> + return lirc ? true : false;
> +#elif defined(CONFIG_LIRC)
> + return true;
> +#else
> + return false;
> +#endif
> +}
> +
> /**
> * show_protocols() - shows the current/wakeup IR protocol(s)
> * @device: the device descriptor
> @@ -882,7 +899,7 @@ static ssize_t show_protocols(struct device *device,
> allowed &= ~proto_names[i].type;
> }
>
> - if (dev->driver_type == RC_DRIVER_IR_RAW)
> + if (dev->driver_type == RC_DRIVER_IR_RAW && lirc_is_present())
> tmp += sprintf(tmp, "[lirc] ");
>
> if (tmp != buf)
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2015-08-11 16:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-22 20:55 [PATCH] rc-core: improve the lirc protocol reporting David Härdeman
2015-08-11 16:27 ` Mauro Carvalho Chehab [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150811132712.52cf4e4b@recife.lan \
--to=mchehab@osg.samsung.com \
--cc=david@hardeman.nu \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.