firmware.h 1.7 KB

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