Merge tag 'platform-drivers-x86-v5.18-1' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-block.git] / include / linux / firmware.h
CommitLineData
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
12struct 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 20struct module;
1da177e4 21struct 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 28bool firmware_request_builtin(struct firmware *fw, const char *name);
48d09e97
LC
29#else
30static 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
38int request_firmware(const struct firmware **fw, const char *name,
39 struct device *device);
7dcc0134
AR
40int firmware_request_nowarn(const struct firmware **fw, const char *name,
41 struct device *device);
e4c2c0ff
HG
42int firmware_request_platform(const struct firmware **fw, const char *name,
43 struct device *device);
1da177e4 44int 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
48int request_firmware_direct(const struct firmware **fw, const char *name,
49 struct device *device);
a098ecd2
SB
50int request_firmware_into_buf(const struct firmware **firmware_p,
51 const char *name, struct device *device, void *buf, size_t size);
59cdb23c
SB
52int 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
56void release_firmware(const struct firmware *fw);
fbab976d
JB
57#else
58static inline int request_firmware(const struct firmware **fw,
59 const char *name,
60 struct device *device)
61{
62 return -EINVAL;
63}
7dcc0134
AR
64
65static 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
72static inline int firmware_request_platform(const struct firmware **fw,
73 const char *name,
74 struct device *device)
75{
76 return -EINVAL;
77}
78
fbab976d 79static 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
87static inline void release_firmware(const struct firmware *fw)
88{
89}
2887b395 90
c868edf4
LR
91static 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
98static 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
104static 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
115int firmware_request_cache(struct device *device, const char *name);
116
1da177e4 117#endif