firmware.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef _LINUX_FIRMWARE_H
  2. #define _LINUX_FIRMWARE_H
  3. #include <linux/types.h>
  4. #include <linux/compiler.h>
  5. #include <linux/gfp.h>
  6. #define FW_ACTION_NOHOTPLUG 0
  7. #define FW_ACTION_HOTPLUG 1
  8. struct firmware {
  9. size_t size;
  10. const u8 *data;
  11. struct page **pages;
  12. /* firmware loader private fields */
  13. void *priv;
  14. };
  15. struct module;
  16. struct device;
  17. struct builtin_fw {
  18. char *name;
  19. void *data;
  20. unsigned long size;
  21. };
  22. /* We have to play tricks here much like stringify() to get the
  23. __COUNTER__ macro to be expanded as we want it */
  24. #define __fw_concat1(x, y) x##y
  25. #define __fw_concat(x, y) __fw_concat1(x, y)
  26. #define DECLARE_BUILTIN_FIRMWARE(name, blob) \
  27. DECLARE_BUILTIN_FIRMWARE_SIZE(name, &(blob), sizeof(blob))
  28. #define DECLARE_BUILTIN_FIRMWARE_SIZE(name, blob, size) \
  29. static const struct builtin_fw __fw_concat(__builtin_fw,__COUNTER__) \
  30. __used __section(.builtin_fw) = { name, blob, size }
  31. #if defined(CONFIG_FW_LOADER) || (defined(CONFIG_FW_LOADER_MODULE) && defined(MODULE))
  32. int request_firmware(const struct firmware **fw, const char *name,
  33. struct device *device);
  34. int request_firmware_nowait(
  35. struct module *module, bool uevent,
  36. const char *name, struct device *device, gfp_t gfp, void *context,
  37. void (*cont)(const struct firmware *fw, void *context));
  38. int request_firmware_direct(const struct firmware **fw, const char *name,
  39. struct device *device);
  40. void release_firmware(const struct firmware *fw);
  41. #else
  42. static inline int request_firmware(const struct firmware **fw,
  43. const char *name,
  44. struct device *device)
  45. {
  46. return -EINVAL;
  47. }
  48. static inline int request_firmware_nowait(
  49. struct module *module, bool uevent,
  50. const char *name, struct device *device, gfp_t gfp, void *context,
  51. void (*cont)(const struct firmware *fw, void *context))
  52. {
  53. return -EINVAL;
  54. }
  55. static inline void release_firmware(const struct firmware *fw)
  56. {
  57. }
  58. static inline int request_firmware_direct(const struct firmware **fw,
  59. const char *name,
  60. struct device *device)
  61. {
  62. return -EINVAL;
  63. }
  64. #endif
  65. #endif