fallback.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __FIRMWARE_FALLBACK_H
  3. #define __FIRMWARE_FALLBACK_H
  4. #include <linux/firmware.h>
  5. #include <linux/device.h>
  6. #include "firmware.h"
  7. /**
  8. * struct firmware_fallback_config - firmware fallback configuration settings
  9. *
  10. * Helps describe and fine tune the fallback mechanism.
  11. *
  12. * @force_sysfs_fallback: force the sysfs fallback mechanism to be used
  13. * as if one had enabled CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y.
  14. * Useful to help debug a CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
  15. * functionality on a kernel where that config entry has been disabled.
  16. * @ignore_sysfs_fallback: force to disable the sysfs fallback mechanism.
  17. * This emulates the behaviour as if we had set the kernel
  18. * config CONFIG_FW_LOADER_USER_HELPER=n.
  19. * @old_timeout: for internal use
  20. * @loading_timeout: the timeout to wait for the fallback mechanism before
  21. * giving up, in seconds.
  22. */
  23. struct firmware_fallback_config {
  24. unsigned int force_sysfs_fallback;
  25. unsigned int ignore_sysfs_fallback;
  26. int old_timeout;
  27. int loading_timeout;
  28. };
  29. #ifdef CONFIG_FW_LOADER_USER_HELPER
  30. int firmware_fallback_sysfs(struct firmware *fw, const char *name,
  31. struct device *device,
  32. enum fw_opt opt_flags,
  33. int ret);
  34. void kill_pending_fw_fallback_reqs(bool only_kill_custom);
  35. void fw_fallback_set_cache_timeout(void);
  36. void fw_fallback_set_default_timeout(void);
  37. int register_sysfs_loader(void);
  38. void unregister_sysfs_loader(void);
  39. #else /* CONFIG_FW_LOADER_USER_HELPER */
  40. static inline int firmware_fallback_sysfs(struct firmware *fw, const char *name,
  41. struct device *device,
  42. enum fw_opt opt_flags,
  43. int ret)
  44. {
  45. /* Keep carrying over the same error */
  46. return ret;
  47. }
  48. static inline void kill_pending_fw_fallback_reqs(bool only_kill_custom) { }
  49. static inline void fw_fallback_set_cache_timeout(void) { }
  50. static inline void fw_fallback_set_default_timeout(void) { }
  51. static inline int register_sysfs_loader(void)
  52. {
  53. return 0;
  54. }
  55. static inline void unregister_sysfs_loader(void)
  56. {
  57. }
  58. #endif /* CONFIG_FW_LOADER_USER_HELPER */
  59. #endif /* __FIRMWARE_FALLBACK_H */