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