fallback.h 2.0 KB

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