1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _LINUX_FIRMWARE_H 3 #define _LINUX_FIRMWARE_H 4 5 #include <linux/types.h> 6 #include <linux/compiler.h> 7 #include <linux/gfp.h> 8 9 #define FW_ACTION_NOUEVENT 0 10 #define FW_ACTION_UEVENT 1 11 12 struct firmware { 13 size_t size; 14 const u8 *data; 15 16 /* firmware loader private fields */ 17 void *priv; 18 }; 19 20 struct module; 21 struct device; 22 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 28 bool firmware_request_builtin(struct firmware *fw, const char *name); 29 #else 30 static inline bool firmware_request_builtin(struct firmware *fw, 31 const char *name) 32 { 33 return false; 34 } 35 #endif 36 37 #if IS_REACHABLE(CONFIG_FW_LOADER) 38 int request_firmware(const struct firmware **fw, const char *name, 39 struct device *device); 40 int firmware_request_nowarn(const struct firmware **fw, const char *name, 41 struct device *device); 42 int firmware_request_platform(const struct firmware **fw, const char *name, 43 struct device *device); 44 int request_firmware_nowait( 45 struct module *module, bool uevent, 46 const char *name, struct device *device, gfp_t gfp, void *context, 47 void (*cont)(const struct firmware *fw, void *context)); 48 int request_firmware_direct(const struct firmware **fw, const char *name, 49 struct device *device); 50 int request_firmware_into_buf(const struct firmware **firmware_p, 51 const char *name, struct device *device, void *buf, size_t size); 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); 55 56 void release_firmware(const struct firmware *fw); 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 } 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 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 79 static inline int request_firmware_nowait( 80 struct module *module, bool uevent, 81 const char *name, struct device *device, gfp_t gfp, void *context, 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 } 90 91 static inline int request_firmware_direct(const struct firmware **fw, 92 const char *name, 93 struct device *device) 94 { 95 return -EINVAL; 96 } 97 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 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 113 #endif 114 115 int firmware_request_cache(struct device *device, const char *name); 116 117 #endif 118