firmware_loader: formalize built-in firmware API

Formalize the built-in firmware with a proper API. This can later
be used by other callers where all they need is built-in firmware.

We export the firmware_request_builtin() call for now only
under the TEST_FIRMWARE symbol namespace as there are no
direct modular users for it. If they pop up they are free
to export it generally. Built-in code always gets access to
the callers and we'll demonstrate a hidden user which has been
lurking in the kernel for a while and the reason why using a
proper API was better long term.

Reviewed-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20211021155843.1969401-2-mcgrof@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Luis Chamberlain
2021-10-21 08:58:34 -07:00
committed by Greg Kroah-Hartman
parent c87761db21
commit 48d09e9787
5 changed files with 137 additions and 79 deletions

View File

@@ -151,6 +151,23 @@ static inline void fw_state_done(struct fw_priv *fw_priv)
int assign_fw(struct firmware *fw, struct device *device);
#ifdef CONFIG_FW_LOADER
bool firmware_is_builtin(const struct firmware *fw);
bool firmware_request_builtin_buf(struct firmware *fw, const char *name,
void *buf, size_t size);
#else /* module case */
static inline bool firmware_is_builtin(const struct firmware *fw)
{
return false;
}
static inline bool firmware_request_builtin_buf(struct firmware *fw,
const char *name,
void *buf, size_t size)
{
return false;
}
#endif
#ifdef CONFIG_FW_LOADER_PAGED_BUF
void fw_free_paged_buf(struct fw_priv *fw_priv);
int fw_grow_paged_buf(struct fw_priv *fw_priv, int pages_needed);