summaryrefslogtreecommitdiffstats
path: root/include/of_device.h
blob: cef6d5b5cc87a77af050c8081510160ea144176d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef __OF_DEVICE_H
#define __OF_DEVICE_H

#include <driver.h>
#include <of.h>


#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);
extern const char *of_device_get_match_compatible(const struct device_d *dev);

#else /* CONFIG_OFTREE */

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 char *of_device_get_match_compatible(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(matches, (dev))

#endif /* CONFIG_OFTREE */

#endif /* _LINUX_OF_DEVICE_H */