Merge tag 'io_uring-5.11-2021-01-16' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / base / firmware_loader / fallback.h
blob3af7205b302fe351a0eb43883da16ff0a9865ac6
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __FIRMWARE_FALLBACK_H
3 #define __FIRMWARE_FALLBACK_H
5 #include <linux/firmware.h>
6 #include <linux/device.h>
8 #include "firmware.h"
10 /**
11 * struct firmware_fallback_config - firmware fallback configuration settings
13 * Helps describe and fine tune the fallback mechanism.
15 * @force_sysfs_fallback: force the sysfs fallback mechanism to be used
16 * as if one had enabled CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y.
17 * Useful to help debug a CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
18 * functionality on a kernel where that config entry has been disabled.
19 * @ignore_sysfs_fallback: force to disable the sysfs fallback mechanism.
20 * This emulates the behaviour as if we had set the kernel
21 * config CONFIG_FW_LOADER_USER_HELPER=n.
22 * @old_timeout: for internal use
23 * @loading_timeout: the timeout to wait for the fallback mechanism before
24 * giving up, in seconds.
26 struct firmware_fallback_config {
27 unsigned int force_sysfs_fallback;
28 unsigned int ignore_sysfs_fallback;
29 int old_timeout;
30 int loading_timeout;
33 #ifdef CONFIG_FW_LOADER_USER_HELPER
34 int firmware_fallback_sysfs(struct firmware *fw, const char *name,
35 struct device *device,
36 u32 opt_flags,
37 int ret);
38 void kill_pending_fw_fallback_reqs(bool only_kill_custom);
40 void fw_fallback_set_cache_timeout(void);
41 void fw_fallback_set_default_timeout(void);
43 int register_sysfs_loader(void);
44 void unregister_sysfs_loader(void);
45 #else /* CONFIG_FW_LOADER_USER_HELPER */
46 static inline int firmware_fallback_sysfs(struct firmware *fw, const char *name,
47 struct device *device,
48 u32 opt_flags,
49 int ret)
51 /* Keep carrying over the same error */
52 return ret;
55 static inline void kill_pending_fw_fallback_reqs(bool only_kill_custom) { }
56 static inline void fw_fallback_set_cache_timeout(void) { }
57 static inline void fw_fallback_set_default_timeout(void) { }
59 static inline int register_sysfs_loader(void)
61 return 0;
64 static inline void unregister_sysfs_loader(void)
67 #endif /* CONFIG_FW_LOADER_USER_HELPER */
69 #ifdef CONFIG_EFI_EMBEDDED_FIRMWARE
70 int firmware_fallback_platform(struct fw_priv *fw_priv);
71 #else
72 static inline int firmware_fallback_platform(struct fw_priv *fw_priv)
74 return -ENOENT;
76 #endif
78 #endif /* __FIRMWARE_FALLBACK_H */