firmware.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. int request_firmware_into_buf(const struct firmware **firmware_p,
  41. const char *name, struct device *device, void *buf, size_t size);
  42. void release_firmware(const struct firmware *fw);
  43. #else
  44. static inline int request_firmware(const struct firmware **fw,
  45. const char *name,
  46. struct device *device)
  47. {
  48. return -EINVAL;
  49. }
  50. static inline int request_firmware_nowait(
  51. struct module *module, bool uevent,
  52. const char *name, struct device *device, gfp_t gfp, void *context,
  53. void (*cont)(const struct firmware *fw, void *context))
  54. {
  55. return -EINVAL;
  56. }
  57. static inline void release_firmware(const struct firmware *fw)
  58. {
  59. }
  60. static inline int request_firmware_direct(const struct firmware **fw,
  61. const char *name,
  62. struct device *device)
  63. {
  64. return -EINVAL;
  65. }
  66. static inline int request_firmware_into_buf(const struct firmware **firmware_p,
  67. const char *name, struct device *device, void *buf, size_t size)
  68. {
  69. return -EINVAL;
  70. }
  71. #endif
  72. #endif