blob: 550498c7fa4c64e2be667089ca05bea4c124d8d3 [file] [log] [blame]
Luis R. Rodriguezd73f8212018-03-10 06:14:49 -08001/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __FIRMWARE_FALLBACK_H
3#define __FIRMWARE_FALLBACK_H
4
5#include <linux/firmware.h>
6#include <linux/device.h>
7
8/**
9 * struct firmware_fallback_config - firmware fallback configuratioon settings
10 *
11 * Helps describe and fine tune the fallback mechanism.
12 *
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 * @old_timeout: for internal use
16 * @loading_timeout: the timeout to wait for the fallback mechanism before
17 * giving up, in seconds.
18 */
19struct firmware_fallback_config {
20 const bool force_sysfs_fallback;
21 int old_timeout;
22 int loading_timeout;
23};
24
25#ifdef CONFIG_FW_LOADER_USER_HELPER
26int fw_sysfs_fallback(struct firmware *fw, const char *name,
27 struct device *device,
28 unsigned int opt_flags,
29 int ret);
30void kill_pending_fw_fallback_reqs(bool only_kill_custom);
31
32void fw_fallback_set_cache_timeout(void);
33void fw_fallback_set_default_timeout(void);
34
35int register_sysfs_loader(void);
36void unregister_sysfs_loader(void);
37#else /* CONFIG_FW_LOADER_USER_HELPER */
38static inline int fw_sysfs_fallback(struct firmware *fw, const char *name,
39 struct device *device,
40 unsigned int opt_flags,
41 int ret)
42{
43 /* Keep carrying over the same error */
44 return ret;
45}
46
47static inline void kill_pending_fw_fallback_reqs(bool only_kill_custom) { }
48static inline void fw_fallback_set_cache_timeout(void) { }
49static inline void fw_fallback_set_default_timeout(void) { }
50
51static inline int register_sysfs_loader(void)
52{
53 return 0;
54}
55
56static inline void unregister_sysfs_loader(void)
57{
58}
59#endif /* CONFIG_FW_LOADER_USER_HELPER */
60
61#endif /* __FIRMWARE_FALLBACK_H */