Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / include / linux / firmware.h
blobd4508080348d301444a50cfadf6947ac363147a5
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_FIRMWARE_H
3 #define _LINUX_FIRMWARE_H
5 #include <linux/types.h>
6 #include <linux/compiler.h>
7 #include <linux/gfp.h>
9 #define FW_ACTION_NOHOTPLUG 0
10 #define FW_ACTION_HOTPLUG 1
12 struct firmware {
13 size_t size;
14 const u8 *data;
15 struct page **pages;
17 /* firmware loader private fields */
18 void *priv;
21 struct module;
22 struct device;
24 struct builtin_fw {
25 char *name;
26 void *data;
27 unsigned long size;
30 /* We have to play tricks here much like stringify() to get the
31 __COUNTER__ macro to be expanded as we want it */
32 #define __fw_concat1(x, y) x##y
33 #define __fw_concat(x, y) __fw_concat1(x, y)
35 #define DECLARE_BUILTIN_FIRMWARE(name, blob) \
36 DECLARE_BUILTIN_FIRMWARE_SIZE(name, &(blob), sizeof(blob))
38 #define DECLARE_BUILTIN_FIRMWARE_SIZE(name, blob, size) \
39 static const struct builtin_fw __fw_concat(__builtin_fw,__COUNTER__) \
40 __used __section(.builtin_fw) = { name, blob, size }
42 #if defined(CONFIG_FW_LOADER) || (defined(CONFIG_FW_LOADER_MODULE) && defined(MODULE))
43 int request_firmware(const struct firmware **fw, const char *name,
44 struct device *device);
45 int request_firmware_nowait(
46 struct module *module, bool uevent,
47 const char *name, struct device *device, gfp_t gfp, void *context,
48 void (*cont)(const struct firmware *fw, void *context));
49 int request_firmware_direct(const struct firmware **fw, const char *name,
50 struct device *device);
51 int request_firmware_into_buf(const struct firmware **firmware_p,
52 const char *name, struct device *device, void *buf, size_t size);
54 void release_firmware(const struct firmware *fw);
55 #else
56 static inline int request_firmware(const struct firmware **fw,
57 const char *name,
58 struct device *device)
60 return -EINVAL;
62 static inline int request_firmware_nowait(
63 struct module *module, bool uevent,
64 const char *name, struct device *device, gfp_t gfp, void *context,
65 void (*cont)(const struct firmware *fw, void *context))
67 return -EINVAL;
70 static inline void release_firmware(const struct firmware *fw)
74 static inline int request_firmware_direct(const struct firmware **fw,
75 const char *name,
76 struct device *device)
78 return -EINVAL;
81 static inline int request_firmware_into_buf(const struct firmware **firmware_p,
82 const char *name, struct device *device, void *buf, size_t size)
84 return -EINVAL;
87 #endif
88 #endif