[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210917182226.3532898-3-mcgrof@kernel.org>
Date: Fri, 17 Sep 2021 11:22:14 -0700
From: "Luis R. Rodriguez" <mcgrof@...nel.org>
To: gregkh@...uxfoundation.org
Cc: bp@...e.de, akpm@...ux-foundation.org, josh@...htriplett.org,
rishabhb@...eaurora.org, kubakici@...pl, maco@...roid.com,
david.brown@...aro.org, bjorn.andersson@...aro.org,
linux-wireless@...r.kernel.org, keescook@...omium.org,
shuah@...nel.org, mfuzzey@...keon.com, zohar@...ux.vnet.ibm.com,
dhowells@...hat.com, pali.rohar@...il.com, tiwai@...e.de,
arend.vanspriel@...adcom.com, zajec5@...il.com, nbroeking@...com,
broonie@...nel.org, dmitry.torokhov@...il.com, dwmw2@...radead.org,
torvalds@...ux-foundation.org, Abhay_Salunke@...l.com,
jewalt@...innovations.com, cantabile.desu@...il.com, ast@...com,
andresx7@...il.com, dan.rue@...aro.org, brendanhiggins@...gle.com,
yzaikin@...gle.com, sfr@...b.auug.org.au, rdunlap@...radead.org,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
Luis Chamberlain <mcgrof@...nel.org>
Subject: [PATCH 02/14] firmware_loader: split built-in firmware call
From: Luis Chamberlain <mcgrof@...nel.org>
There are two ways the firmware_loader can use the built-in
firmware: with or without the pre-allocated buffer. We already
have one explicit use case for each of these, and so split them
up so that it is clear what the intention is on the caller side.
This also paves the way so that eventually other callers outside
of the firmware loader can uses these if and when needed.
While at it, adopt the firmware prefix for the routine names.
Signed-off-by: Luis Chamberlain <mcgrof@...nel.org>
---
drivers/base/firmware_loader/main.c | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c
index ef904b8b112e..eb4085b92ad4 100644
--- a/drivers/base/firmware_loader/main.c
+++ b/drivers/base/firmware_loader/main.c
@@ -111,8 +111,7 @@ static bool fw_copy_to_prealloc_buf(struct firmware *fw,
return true;
}
-static bool fw_get_builtin_firmware(struct firmware *fw, const char *name,
- void *buf, size_t size)
+static bool firmware_request_builtin(struct firmware *fw, const char *name)
{
struct builtin_fw *b_fw;
@@ -120,13 +119,21 @@ static bool fw_get_builtin_firmware(struct firmware *fw, const char *name,
if (strcmp(name, b_fw->name) == 0) {
fw->size = b_fw->size;
fw->data = b_fw->data;
- return fw_copy_to_prealloc_buf(fw, buf, size);
+ return true;
}
}
return false;
}
+static bool firmware_request_builtin_buf(struct firmware *fw, const char *name,
+ void *buf, size_t size)
+{
+ if (!firmware_request_builtin(fw, name))
+ return false;
+ return fw_copy_to_prealloc_buf(fw, buf, size);
+}
+
static bool fw_is_builtin_firmware(const struct firmware *fw)
{
struct builtin_fw *b_fw;
@@ -140,9 +147,15 @@ static bool fw_is_builtin_firmware(const struct firmware *fw)
#else /* Module case - no builtin firmware support */
-static inline bool fw_get_builtin_firmware(struct firmware *fw,
- const char *name, void *buf,
- size_t size)
+static inline bool firmware_request_builtin(struct firmware *fw,
+ const char *name)
+{
+ return false;
+}
+
+static inline bool firmware_request_builtin_buf(struct firmware *fw,
+ const char *name, void *buf,
+ size_t size)
{
return false;
}
@@ -737,7 +750,7 @@ _request_firmware_prepare(struct firmware **firmware_p, const char *name,
return -ENOMEM;
}
- if (fw_get_builtin_firmware(firmware, name, dbuf, size)) {
+ if (firmware_request_builtin_buf(firmware, name, dbuf, size)) {
dev_dbg(device, "using built-in %s\n", name);
return 0; /* assigned */
}
@@ -1216,7 +1229,7 @@ static int uncache_firmware(const char *fw_name)
pr_debug("%s: %s\n", __func__, fw_name);
- if (fw_get_builtin_firmware(&fw, fw_name, NULL, 0))
+ if (firmware_request_builtin(&fw, fw_name))
return 0;
fw_priv = lookup_fw_priv(fw_name);
--
2.30.2
Powered by blists - more mailing lists