Luis R. Rodriguez | d73f821 | 2018-03-10 06:14:49 -0800 | [diff] [blame^] | 1 | /* 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 | */ |
| 19 | struct 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 |
| 26 | int fw_sysfs_fallback(struct firmware *fw, const char *name, |
| 27 | struct device *device, |
| 28 | unsigned int opt_flags, |
| 29 | int ret); |
| 30 | void kill_pending_fw_fallback_reqs(bool only_kill_custom); |
| 31 | |
| 32 | void fw_fallback_set_cache_timeout(void); |
| 33 | void fw_fallback_set_default_timeout(void); |
| 34 | |
| 35 | int register_sysfs_loader(void); |
| 36 | void unregister_sysfs_loader(void); |
| 37 | #else /* CONFIG_FW_LOADER_USER_HELPER */ |
| 38 | static 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 | |
| 47 | static inline void kill_pending_fw_fallback_reqs(bool only_kill_custom) { } |
| 48 | static inline void fw_fallback_set_cache_timeout(void) { } |
| 49 | static inline void fw_fallback_set_default_timeout(void) { } |
| 50 | |
| 51 | static inline int register_sysfs_loader(void) |
| 52 | { |
| 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | static inline void unregister_sysfs_loader(void) |
| 57 | { |
| 58 | } |
| 59 | #endif /* CONFIG_FW_LOADER_USER_HELPER */ |
| 60 | |
| 61 | #endif /* __FIRMWARE_FALLBACK_H */ |