Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | #ifndef _LINUX_FIRMWARE_H |
3 | #define _LINUX_FIRMWARE_H | |
5658c769 | 4 | |
1da177e4 | 5 | #include <linux/types.h> |
5658c769 | 6 | #include <linux/compiler.h> |
9ebfbd45 | 7 | #include <linux/gfp.h> |
5658c769 | 8 | |
6e3eaab0 AS |
9 | #define FW_ACTION_NOHOTPLUG 0 |
10 | #define FW_ACTION_HOTPLUG 1 | |
11 | ||
1da177e4 LT |
12 | struct firmware { |
13 | size_t size; | |
b7a39bd0 | 14 | const u8 *data; |
dd336c55 | 15 | struct page **pages; |
1f2b7959 ML |
16 | |
17 | /* firmware loader private fields */ | |
18 | void *priv; | |
1da177e4 | 19 | }; |
fbab976d | 20 | |
de477254 | 21 | struct module; |
1da177e4 | 22 | struct device; |
fbab976d | 23 | |
5658c769 DW |
24 | struct builtin_fw { |
25 | char *name; | |
26 | void *data; | |
27 | unsigned long size; | |
28 | }; | |
29 | ||
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) | |
34 | ||
35 | #define DECLARE_BUILTIN_FIRMWARE(name, blob) \ | |
36 | DECLARE_BUILTIN_FIRMWARE_SIZE(name, &(blob), sizeof(blob)) | |
37 | ||
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 } | |
41 | ||
69d44a18 | 42 | #if defined(CONFIG_FW_LOADER) || (defined(CONFIG_FW_LOADER_MODULE) && defined(MODULE)) |
1da177e4 LT |
43 | int request_firmware(const struct firmware **fw, const char *name, |
44 | struct device *device); | |
7dcc0134 AR |
45 | int firmware_request_nowarn(const struct firmware **fw, const char *name, |
46 | struct device *device); | |
1da177e4 | 47 | int request_firmware_nowait( |
072fc8f0 | 48 | struct module *module, bool uevent, |
9ebfbd45 | 49 | const char *name, struct device *device, gfp_t gfp, void *context, |
1da177e4 | 50 | void (*cont)(const struct firmware *fw, void *context)); |
c868edf4 LR |
51 | int request_firmware_direct(const struct firmware **fw, const char *name, |
52 | struct device *device); | |
a098ecd2 SB |
53 | int request_firmware_into_buf(const struct firmware **firmware_p, |
54 | const char *name, struct device *device, void *buf, size_t size); | |
1da177e4 LT |
55 | |
56 | void release_firmware(const struct firmware *fw); | |
fbab976d JB |
57 | #else |
58 | static inline int request_firmware(const struct firmware **fw, | |
59 | const char *name, | |
60 | struct device *device) | |
61 | { | |
62 | return -EINVAL; | |
63 | } | |
7dcc0134 AR |
64 | |
65 | static inline int firmware_request_nowarn(const struct firmware **fw, | |
66 | const char *name, | |
67 | struct device *device) | |
68 | { | |
69 | return -EINVAL; | |
70 | } | |
71 | ||
fbab976d | 72 | static inline int request_firmware_nowait( |
072fc8f0 | 73 | struct module *module, bool uevent, |
9ebfbd45 | 74 | const char *name, struct device *device, gfp_t gfp, void *context, |
fbab976d JB |
75 | void (*cont)(const struct firmware *fw, void *context)) |
76 | { | |
77 | return -EINVAL; | |
78 | } | |
79 | ||
80 | static inline void release_firmware(const struct firmware *fw) | |
81 | { | |
82 | } | |
2887b395 | 83 | |
c868edf4 LR |
84 | static inline int request_firmware_direct(const struct firmware **fw, |
85 | const char *name, | |
86 | struct device *device) | |
87 | { | |
88 | return -EINVAL; | |
89 | } | |
fbab976d | 90 | |
a098ecd2 SB |
91 | static inline int request_firmware_into_buf(const struct firmware **firmware_p, |
92 | const char *name, struct device *device, void *buf, size_t size) | |
93 | { | |
94 | return -EINVAL; | |
95 | } | |
96 | ||
bba3a87e | 97 | #endif |
5d42c96e LR |
98 | |
99 | int firmware_request_cache(struct device *device, const char *name); | |
100 | ||
1da177e4 | 101 | #endif |