of_device.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef _LINUX_OF_DEVICE_H
  2. #define _LINUX_OF_DEVICE_H
  3. /*
  4. * The of_device *was* a kind of "base class" that was a superset of
  5. * struct device for use by devices attached to an OF node and probed
  6. * using OF properties. However, the important bit of OF-style
  7. * probing, namely the device node pointer, has been moved into the
  8. * common struct device when CONFIG_OF is set to make OF-style probing
  9. * available to all bus types. So now, just make of_device and
  10. * platform_device equivalent so that current of_platform bus users
  11. * can be transparently migrated over to using the platform bus.
  12. *
  13. * This line will go away once all references to of_device are removed
  14. * from the kernel.
  15. */
  16. #define of_device platform_device
  17. #include <linux/platform_device.h>
  18. #include <linux/of_platform.h> /* temporary until merge */
  19. #ifdef CONFIG_OF_DEVICE
  20. #include <linux/device.h>
  21. #include <linux/of.h>
  22. #include <linux/mod_devicetable.h>
  23. #define to_of_device(d) container_of(d, struct of_device, dev)
  24. extern const struct of_device_id *of_match_device(
  25. const struct of_device_id *matches, const struct device *dev);
  26. /**
  27. * of_driver_match_device - Tell if a driver's of_match_table matches a device.
  28. * @drv: the device_driver structure to test
  29. * @dev: the device structure to match against
  30. */
  31. static inline int of_driver_match_device(const struct device *dev,
  32. const struct device_driver *drv)
  33. {
  34. return of_match_device(drv->of_match_table, dev) != NULL;
  35. }
  36. extern struct platform_device *of_dev_get(struct platform_device *dev);
  37. extern void of_dev_put(struct platform_device *dev);
  38. extern int of_device_register(struct platform_device *ofdev);
  39. extern void of_device_unregister(struct platform_device *ofdev);
  40. extern void of_release_dev(struct device *dev);
  41. static inline void of_device_free(struct platform_device *dev)
  42. {
  43. of_release_dev(&dev->dev);
  44. }
  45. extern ssize_t of_device_get_modalias(struct device *dev,
  46. char *str, ssize_t len);
  47. extern int of_device_uevent(struct device *dev, struct kobj_uevent_env *env);
  48. #else /* CONFIG_OF_DEVICE */
  49. static inline int of_driver_match_device(struct device *dev,
  50. struct device_driver *drv)
  51. {
  52. return 0;
  53. }
  54. static inline int of_device_uevent(struct device *dev,
  55. struct kobj_uevent_env *env)
  56. {
  57. return -ENODEV;
  58. }
  59. #endif /* CONFIG_OF_DEVICE */
  60. #endif /* _LINUX_OF_DEVICE_H */