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