Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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_NOHOTPLUG 0
10#define FW_ACTION_HOTPLUG 1
11
12struct firmware {
13 size_t size;
14 const u8 *data;
15 struct page **pages;
16
17 /* firmware loader private fields */
18 void *priv;
19};
20
21struct module;
22struct device;
23
24struct 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
42#if defined(CONFIG_FW_LOADER) || (defined(CONFIG_FW_LOADER_MODULE) && defined(MODULE))
43int request_firmware(const struct firmware **fw, const char *name,
44 struct device *device);
45int firmware_request_nowarn(const struct firmware **fw, const char *name,
46 struct device *device);
47int firmware_request_platform(const struct firmware **fw, const char *name,
48 struct device *device);
49int request_firmware_nowait(
50 struct module *module, bool uevent,
51 const char *name, struct device *device, gfp_t gfp, void *context,
52 void (*cont)(const struct firmware *fw, void *context));
53int request_firmware_direct(const struct firmware **fw, const char *name,
54 struct device *device);
55int request_firmware_into_buf(const struct firmware **firmware_p,
56 const char *name, struct device *device, void *buf, size_t size);
57
58void release_firmware(const struct firmware *fw);
59#else
60static inline int request_firmware(const struct firmware **fw,
61 const char *name,
62 struct device *device)
63{
64 return -EINVAL;
65}
66
67static inline int firmware_request_nowarn(const struct firmware **fw,
68 const char *name,
69 struct device *device)
70{
71 return -EINVAL;
72}
73
74static inline int firmware_request_platform(const struct firmware **fw,
75 const char *name,
76 struct device *device)
77{
78 return -EINVAL;
79}
80
81static inline int request_firmware_nowait(
82 struct module *module, bool uevent,
83 const char *name, struct device *device, gfp_t gfp, void *context,
84 void (*cont)(const struct firmware *fw, void *context))
85{
86 return -EINVAL;
87}
88
89static inline void release_firmware(const struct firmware *fw)
90{
91}
92
93static inline int request_firmware_direct(const struct firmware **fw,
94 const char *name,
95 struct device *device)
96{
97 return -EINVAL;
98}
99
100static inline int request_firmware_into_buf(const struct firmware **firmware_p,
101 const char *name, struct device *device, void *buf, size_t size)
102{
103 return -EINVAL;
104}
105
106#endif
107
108int firmware_request_cache(struct device *device, const char *name);
109
110#endif