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 | |
0733d839 SG |
9 | #define FW_ACTION_NOUEVENT 0 |
10 | #define FW_ACTION_UEVENT 1 | |
6e3eaab0 | 11 | |
1da177e4 LT |
12 | struct firmware { |
13 | size_t size; | |
b7a39bd0 | 14 | const u8 *data; |
1f2b7959 ML |
15 | |
16 | /* firmware loader private fields */ | |
17 | void *priv; | |
1da177e4 | 18 | }; |
fbab976d | 19 | |
de477254 | 20 | struct module; |
1da177e4 | 21 | struct device; |
fbab976d | 22 | |
48d09e97 LC |
23 | /* |
24 | * Built-in firmware functionality is only available if FW_LOADER=y, but not | |
25 | * FW_LOADER=m | |
26 | */ | |
27 | #ifdef CONFIG_FW_LOADER | |
48d09e97 | 28 | bool firmware_request_builtin(struct firmware *fw, const char *name); |
48d09e97 LC |
29 | #else |
30 | static inline bool firmware_request_builtin(struct firmware *fw, | |
31 | const char *name) | |
32 | { | |
33 | return false; | |
34 | } | |
35 | #endif | |
36 | ||
69d44a18 | 37 | #if defined(CONFIG_FW_LOADER) || (defined(CONFIG_FW_LOADER_MODULE) && defined(MODULE)) |
1da177e4 LT |
38 | int request_firmware(const struct firmware **fw, const char *name, |
39 | struct device *device); | |
7dcc0134 AR |
40 | int firmware_request_nowarn(const struct firmware **fw, const char *name, |
41 | struct device *device); | |
e4c2c0ff HG |
42 | int firmware_request_platform(const struct firmware **fw, const char *name, |
43 | struct device *device); | |
1da177e4 | 44 | int request_firmware_nowait( |
072fc8f0 | 45 | struct module *module, bool uevent, |
9ebfbd45 | 46 | const char *name, struct device *device, gfp_t gfp, void *context, |
1da177e4 | 47 | void (*cont)(const struct firmware *fw, void *context)); |
c868edf4 LR |
48 | int request_firmware_direct(const struct firmware **fw, const char *name, |
49 | struct device *device); | |
a098ecd2 SB |
50 | int request_firmware_into_buf(const struct firmware **firmware_p, |
51 | const char *name, struct device *device, void *buf, size_t size); | |
59cdb23c SB |
52 | int request_partial_firmware_into_buf(const struct firmware **firmware_p, |
53 | const char *name, struct device *device, | |
54 | void *buf, size_t size, size_t offset); | |
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 | ||
e4c2c0ff HG |
72 | static inline int firmware_request_platform(const struct firmware **fw, |
73 | const char *name, | |
74 | struct device *device) | |
75 | { | |
76 | return -EINVAL; | |
77 | } | |
78 | ||
fbab976d | 79 | static inline int request_firmware_nowait( |
072fc8f0 | 80 | struct module *module, bool uevent, |
9ebfbd45 | 81 | const char *name, struct device *device, gfp_t gfp, void *context, |
fbab976d JB |
82 | void (*cont)(const struct firmware *fw, void *context)) |
83 | { | |
84 | return -EINVAL; | |
85 | } | |
86 | ||
87 | static inline void release_firmware(const struct firmware *fw) | |
88 | { | |
89 | } | |
2887b395 | 90 | |
c868edf4 LR |
91 | static inline int request_firmware_direct(const struct firmware **fw, |
92 | const char *name, | |
93 | struct device *device) | |
94 | { | |
95 | return -EINVAL; | |
96 | } | |
fbab976d | 97 | |
a098ecd2 SB |
98 | static inline int request_firmware_into_buf(const struct firmware **firmware_p, |
99 | const char *name, struct device *device, void *buf, size_t size) | |
100 | { | |
101 | return -EINVAL; | |
102 | } | |
103 | ||
59cdb23c SB |
104 | static inline int request_partial_firmware_into_buf |
105 | (const struct firmware **firmware_p, | |
106 | const char *name, | |
107 | struct device *device, | |
108 | void *buf, size_t size, size_t offset) | |
109 | { | |
110 | return -EINVAL; | |
111 | } | |
112 | ||
bba3a87e | 113 | #endif |
5d42c96e LR |
114 | |
115 | int firmware_request_cache(struct device *device, const char *name); | |
116 | ||
1da177e4 | 117 | #endif |