firmware.h 1.7 KB

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