From bd55401e972d630338d3326373f8aef9d204faaf Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Mon, 25 Apr 2016 22:37:00 -0700 Subject: OF: Port of_match_device() and of_device_get_match_data() Port of_match_device() and of_device_get_match_data() from Linux kernel code. Signed-off-by: Andrey Smirnov Acked-by: Lucas Stach Signed-off-by: Sascha Hauer --- include/of_device.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 include/of_device.h (limited to 'include/of_device.h') diff --git a/include/of_device.h b/include/of_device.h new file mode 100644 index 0000000000..e84fc9c377 --- /dev/null +++ b/include/of_device.h @@ -0,0 +1,48 @@ +#ifndef __OF_DEVICE_H +#define __OF_DEVICE_H + +#include +#include + + +#ifdef CONFIG_OFTREE +extern const struct of_device_id *of_match_device( + const struct of_device_id *matches, const struct device_d *dev); + +/** + * of_driver_match_device - Tell if a driver's of_match_table matches a device. + * @drv: the device_driver structure to test + * @dev: the device structure to match against + */ +static inline int of_driver_match_device(struct device_d *dev, + const struct driver_d *drv) +{ + return of_match_device(drv->of_compatible, dev) != NULL; +} + +extern const void *of_device_get_match_data(const struct device_d *dev); + +#else /* CONFIG_OF */ + +static inline int of_driver_match_device(struct device_d *dev, + const struct device_d *drv) +{ + return 0; +} + +static inline const void *of_device_get_match_data(const struct device_d *dev) +{ + return NULL; +} + +static inline const struct of_device_id *__of_match_device( + const struct of_device_id *matches, const struct device_d *dev) +{ + return NULL; +} +#define of_match_device(matches, dev) \ + __of_match_device(of_match_ptr(matches), (dev)) + +#endif /* CONFIG_OF */ + +#endif /* _LINUX_OF_DEVICE_H */ -- cgit v1.2.3