summaryrefslogtreecommitdiff
path: root/include/linux/firmware.h
diff options
context:
space:
mode:
authorLuis Chamberlain <mcgrof@kernel.org>2021-10-21 08:58:34 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-10-22 14:13:44 +0200
commit48d09e97876bed4bcc503d528bdba8c907e43cb3 (patch)
tree19c98782f93da87cf9e1b2c6a0ac817e0c9fa9bf /include/linux/firmware.h
parentc87761db2100677a69be551365105125d872af5b (diff)
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>
Diffstat (limited to 'include/linux/firmware.h')
-rw-r--r--include/linux/firmware.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/firmware.h b/include/linux/firmware.h
index 25109192cebe..d743a8d1c2fe 100644
--- a/include/linux/firmware.h
+++ b/include/linux/firmware.h
@@ -20,12 +20,19 @@ struct firmware {
struct module;
struct device;
+/*
+ * Built-in firmware functionality is only available if FW_LOADER=y, but not
+ * FW_LOADER=m
+ */
+#ifdef CONFIG_FW_LOADER
struct builtin_fw {
char *name;
void *data;
unsigned long size;
};
+bool firmware_request_builtin(struct firmware *fw, const char *name);
+
/* We have to play tricks here much like stringify() to get the
__COUNTER__ macro to be expanded as we want it */
#define __fw_concat1(x, y) x##y
@@ -38,6 +45,14 @@ struct builtin_fw {
static const struct builtin_fw __fw_concat(__builtin_fw,__COUNTER__) \
__used __section(".builtin_fw") = { name, blob, size }
+#else
+static inline bool firmware_request_builtin(struct firmware *fw,
+ const char *name)
+{
+ return false;
+}
+#endif
+
#if defined(CONFIG_FW_LOADER) || (defined(CONFIG_FW_LOADER_MODULE) && defined(MODULE))
int request_firmware(const struct firmware **fw, const char *name,
struct device *device);