firmware.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. void release_firmware(const struct firmware *fw);
  39. #else
  40. static inline int request_firmware(const struct firmware **fw,
  41. const char *name,
  42. struct device *device)
  43. {
  44. return -EINVAL;
  45. }
  46. static inline int request_firmware_nowait(
  47. struct module *module, bool uevent,
  48. const char *name, struct device *device, gfp_t gfp, void *context,
  49. void (*cont)(const struct firmware *fw, void *context))
  50. {
  51. return -EINVAL;
  52. }
  53. static inline void release_firmware(const struct firmware *fw)
  54. {
  55. }
  56. #endif
  57. #endif