forked from Minki/linux
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>
This commit is contained in:
parent
f7a07f7b96
commit
7c4fd90741
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user