summaryrefslogtreecommitdiff
path: root/drivers/base/firmware_loader
diff options
context:
space:
mode:
authorLuis Chamberlain <mcgrof@kernel.org>2021-09-17 11:22:14 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-10-05 16:26:37 +0200
commit7c4fd90741b724b199089869262862542a8f026b (patch)
tree5ff4b8493d576275e0caef3e9766c6abe9800e7e /drivers/base/firmware_loader
parentf7a07f7b96033df7709042ff38e998720a3f7119 (diff)
firmware_loader: split built-in firmware call
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@kernel.org> Link: https://lore.kernel.org/r/20210917182226.3532898-3-mcgrof@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/firmware_loader')
-rw-r--r--drivers/base/firmware_loader/main.c29
1 files 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);