firmware.h 1.7 KB

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