blob: 3cbcf65d3b33e47b4cf0dde5783b4ffd894077b7 [file] [log] [blame]
Nicholas Flintham1e3d3112013-04-10 10:48:38 +01001#ifndef _LINUX_FIRMWARE_H
2#define _LINUX_FIRMWARE_H
3
4#include <linux/types.h>
5#include <linux/compiler.h>
6#include <linux/gfp.h>
7
8#define FW_ACTION_NOHOTPLUG 0
9#define FW_ACTION_HOTPLUG 1
10
11struct firmware {
12 size_t size;
13 const u8 *data;
14 struct page **pages;
15};
16
17struct module;
18struct device;
19
20struct builtin_fw {
21 char *name;
22 void *data;
23 unsigned long size;
24};
25
26#define __fw_concat1(x, y) x##y
27#define __fw_concat(x, y) __fw_concat1(x, y)
28
29#define DECLARE_BUILTIN_FIRMWARE(name, blob) \
30 DECLARE_BUILTIN_FIRMWARE_SIZE(name, &(blob), sizeof(blob))
31
32#define DECLARE_BUILTIN_FIRMWARE_SIZE(name, blob, size) \
33 static const struct builtin_fw __fw_concat(__builtin_fw,__COUNTER__) \
34 __used __section(.builtin_fw) = { name, blob, size }
35
36#if defined(CONFIG_FW_LOADER) || (defined(CONFIG_FW_LOADER_MODULE) && defined(MODULE))
37int request_firmware(const struct firmware **fw, const char *name,
38 struct device *device);
39int request_firmware_nowait(
40 struct module *module, bool uevent,
41 const char *name, struct device *device, gfp_t gfp, void *context,
42 void (*cont)(const struct firmware *fw, void *context));
43
44void release_firmware(const struct firmware *fw);
45#else
46static inline int request_firmware(const struct firmware **fw,
47 const char *name,
48 struct device *device)
49{
50 return -EINVAL;
51}
52static inline int request_firmware_nowait(
53 struct module *module, bool uevent,
54 const char *name, struct device *device, gfp_t gfp, void *context,
55 void (*cont)(const struct firmware *fw, void *context))
56{
57 return -EINVAL;
58}
59
60static inline void release_firmware(const struct firmware *fw)
61{
62}
63#endif
64
65#endif