xref: /linux-6.15/include/linux/of_device.h (revision 7e09cb0b)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_OF_DEVICE_H
3 #define _LINUX_OF_DEVICE_H
4 
5 #include <linux/platform_device.h>
6 #include <linux/of_platform.h> /* temporary until merge */
7 
8 #include <linux/of.h>
9 
10 struct device;
11 struct of_device_id;
12 struct kobj_uevent_env;
13 
14 #ifdef CONFIG_OF
15 extern const struct of_device_id *of_match_device(
16 	const struct of_device_id *matches, const struct device *dev);
17 
18 /**
19  * of_driver_match_device - Tell if a driver's of_match_table matches a device.
20  * @drv: the device_driver structure to test
21  * @dev: the device structure to match against
22  */
23 static inline int of_driver_match_device(struct device *dev,
24 					 const struct device_driver *drv)
25 {
26 	return of_match_device(drv->of_match_table, dev) != NULL;
27 }
28 
29 extern ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len);
30 extern int of_device_request_module(struct device *dev);
31 
32 extern void of_device_uevent(const struct device *dev, struct kobj_uevent_env *env);
33 extern int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *env);
34 
35 int of_dma_configure_id(struct device *dev,
36 		     struct device_node *np,
37 		     bool force_dma, const u32 *id);
38 static inline int of_dma_configure(struct device *dev,
39 				   struct device_node *np,
40 				   bool force_dma)
41 {
42 	return of_dma_configure_id(dev, np, force_dma, NULL);
43 }
44 #else /* CONFIG_OF */
45 
46 static inline int of_driver_match_device(struct device *dev,
47 					 const struct device_driver *drv)
48 {
49 	return 0;
50 }
51 
52 static inline void of_device_uevent(const struct device *dev,
53 			struct kobj_uevent_env *env) { }
54 
55 static inline int of_device_modalias(struct device *dev,
56 				     char *str, ssize_t len)
57 {
58 	return -ENODEV;
59 }
60 
61 static inline int of_device_request_module(struct device *dev)
62 {
63 	return -ENODEV;
64 }
65 
66 static inline int of_device_uevent_modalias(const struct device *dev,
67 				   struct kobj_uevent_env *env)
68 {
69 	return -ENODEV;
70 }
71 
72 static inline const struct of_device_id *of_match_device(
73 		const struct of_device_id *matches, const struct device *dev)
74 {
75 	return NULL;
76 }
77 
78 static inline int of_dma_configure_id(struct device *dev,
79 				      struct device_node *np,
80 				      bool force_dma,
81 				      const u32 *id)
82 {
83 	return 0;
84 }
85 static inline int of_dma_configure(struct device *dev,
86 				   struct device_node *np,
87 				   bool force_dma)
88 {
89 	return 0;
90 }
91 #endif /* CONFIG_OF */
92 
93 #endif /* _LINUX_OF_DEVICE_H */
94