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>
9 * struct firmware_fallback_config - firmware fallback configuratioon settings
11 * Helps describe and fine tune the fallback mechanism.
13 * @force_sysfs_fallback: force the sysfs fallback mechanism to be used
14 * as if one had enabled CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y.
15 * Useful to help debug a CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
16 * functionality on a kernel where that config entry has been disabled.
17 * @ignore_sysfs_fallback: force to disable the sysfs fallback mechanism.
18 * This emulates the behaviour as if we had set the kernel
19 * config CONFIG_FW_LOADER_USER_HELPER=n.
20 * @old_timeout: for internal use
21 * @loading_timeout: the timeout to wait for the fallback mechanism before
22 * giving up, in seconds.
24 struct firmware_fallback_config {
25 unsigned int force_sysfs_fallback;
26 unsigned int ignore_sysfs_fallback;
31 #ifdef CONFIG_FW_LOADER_USER_HELPER
32 int fw_sysfs_fallback(struct firmware *fw, const char *name,
33 struct device *device,
34 unsigned int opt_flags,
36 void kill_pending_fw_fallback_reqs(bool only_kill_custom);
38 void fw_fallback_set_cache_timeout(void);
39 void fw_fallback_set_default_timeout(void);
41 int register_sysfs_loader(void);
42 void unregister_sysfs_loader(void);
43 #else /* CONFIG_FW_LOADER_USER_HELPER */
44 static inline int fw_sysfs_fallback(struct firmware *fw, const char *name,
45 struct device *device,
46 unsigned int opt_flags,
49 /* Keep carrying over the same error */
53 static inline void kill_pending_fw_fallback_reqs(bool only_kill_custom) { }
54 static inline void fw_fallback_set_cache_timeout(void) { }
55 static inline void fw_fallback_set_default_timeout(void) { }
57 static inline int register_sysfs_loader(void)
62 static inline void unregister_sysfs_loader(void)
65 #endif /* CONFIG_FW_LOADER_USER_HELPER */
67 #endif /* __FIRMWARE_FALLBACK_H */