From: "Rafał Miłecki" <zajec5@gmail.com>
To: Ming Lei <ming.lei@canonical.com>,
"Luis R . Rodriguez" <mcgrof@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: "Rafał Miłecki" <rafal@milecki.pl>
Subject: [PATCH V2] firmware: simplify defining and handling FW_OPT_FALLBACK
Date: Sun, 11 Dec 2016 22:21:43 +0100 [thread overview]
Message-ID: <20161211212143.15495-1-zajec5@gmail.com> (raw)
In-Reply-To: <20161211132626.9908-1-zajec5@gmail.com>
From: Rafał Miłecki <rafal@milecki.pl>
I found handling of FW_OPT_FALLBACK a bit complex. It was defined using
another option and their values were dependent on kernel config.
It was also non-trivial to follow the code. Some callers were using
FW_OPT_FALLBACK which was confusing since the _request_firmware function
was always checking for FW_OPT_USERHELPER (the same bit in a relevant
configuration).
With this patch FW_OPT_USERHELPER gets its own bit and is explicitly
checked in the _request_firmware which hopefully makes code easier to
understand.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
V2: s/config_enabled/IS_ENABLED/ to compile since c0a0aba8e47 ("kconfig.h: remove config_enabled() macro")
---
drivers/base/firmware_class.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 22d1760..0e1d5b8 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -112,13 +112,9 @@ static inline long firmware_loading_timeout(void)
#else
#define FW_OPT_USERHELPER 0
#endif
-#ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK
-#define FW_OPT_FALLBACK FW_OPT_USERHELPER
-#else
-#define FW_OPT_FALLBACK 0
-#endif
#define FW_OPT_NO_WARN (1U << 3)
#define FW_OPT_NOCACHE (1U << 4)
+#define FW_OPT_FALLBACK (1U << 5)
struct firmware_cache {
/* firmware_buf instance will be added into the below list */
@@ -1175,8 +1171,12 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
dev_warn(device,
"Direct firmware load for %s failed with error %d\n",
name, ret);
- if (opt_flags & FW_OPT_USERHELPER) {
+ if (IS_ENABLED(CONFIG_FW_LOADER_USER_HELPER_FALLBACK) &&
+ opt_flags & FW_OPT_FALLBACK) {
dev_warn(device, "Falling back to user helper\n");
+ opt_flags |= FW_OPT_USERHELPER;
+ }
+ if (opt_flags & FW_OPT_USERHELPER) {
ret = fw_load_from_user_helper(fw, name, device,
opt_flags, timeout);
}
--
2.10.1
next prev parent reply other threads:[~2016-12-11 21:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-11 13:26 [PATCH] " Rafał Miłecki
2016-12-11 21:21 ` Rafał Miłecki [this message]
[not found] ` <6ad5eb68-37c2-482c-395e-b6544a599046@broadcom.com>
2016-12-12 10:24 ` [PATCH V2] " Rafał Miłecki
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=20161211212143.15495-1-zajec5@gmail.com \
--to=zajec5@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=ming.lei@canonical.com \
--cc=rafal@milecki.pl \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®