Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _LINUX_OF_DEVICE_H
0003 #define _LINUX_OF_DEVICE_H
0004 
0005 #include <linux/cpu.h>
0006 #include <linux/platform_device.h>
0007 #include <linux/of_platform.h> /* temporary until merge */
0008 
0009 #include <linux/of.h>
0010 #include <linux/mod_devicetable.h>
0011 
0012 struct device;
0013 
0014 #ifdef CONFIG_OF
0015 extern const struct of_device_id *of_match_device(
0016     const struct of_device_id *matches, const struct device *dev);
0017 
0018 /**
0019  * of_driver_match_device - Tell if a driver's of_match_table matches a device.
0020  * @drv: the device_driver structure to test
0021  * @dev: the device structure to match against
0022  */
0023 static inline int of_driver_match_device(struct device *dev,
0024                      const struct device_driver *drv)
0025 {
0026     return of_match_device(drv->of_match_table, dev) != NULL;
0027 }
0028 
0029 extern int of_device_add(struct platform_device *pdev);
0030 extern int of_device_register(struct platform_device *ofdev);
0031 extern void of_device_unregister(struct platform_device *ofdev);
0032 
0033 extern const void *of_device_get_match_data(const struct device *dev);
0034 
0035 extern ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len);
0036 extern int of_device_request_module(struct device *dev);
0037 
0038 extern void of_device_uevent(struct device *dev, struct kobj_uevent_env *env);
0039 extern int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env);
0040 
0041 static inline struct device_node *of_cpu_device_node_get(int cpu)
0042 {
0043     struct device *cpu_dev;
0044     cpu_dev = get_cpu_device(cpu);
0045     if (!cpu_dev)
0046         return of_get_cpu_node(cpu, NULL);
0047     return of_node_get(cpu_dev->of_node);
0048 }
0049 
0050 int of_dma_configure_id(struct device *dev,
0051              struct device_node *np,
0052              bool force_dma, const u32 *id);
0053 static inline int of_dma_configure(struct device *dev,
0054                    struct device_node *np,
0055                    bool force_dma)
0056 {
0057     return of_dma_configure_id(dev, np, force_dma, NULL);
0058 }
0059 #else /* CONFIG_OF */
0060 
0061 static inline int of_driver_match_device(struct device *dev,
0062                      const struct device_driver *drv)
0063 {
0064     return 0;
0065 }
0066 
0067 static inline void of_device_uevent(struct device *dev,
0068             struct kobj_uevent_env *env) { }
0069 
0070 static inline const void *of_device_get_match_data(const struct device *dev)
0071 {
0072     return NULL;
0073 }
0074 
0075 static inline int of_device_modalias(struct device *dev,
0076                      char *str, ssize_t len)
0077 {
0078     return -ENODEV;
0079 }
0080 
0081 static inline int of_device_request_module(struct device *dev)
0082 {
0083     return -ENODEV;
0084 }
0085 
0086 static inline int of_device_uevent_modalias(struct device *dev,
0087                    struct kobj_uevent_env *env)
0088 {
0089     return -ENODEV;
0090 }
0091 
0092 static inline const struct of_device_id *of_match_device(
0093         const struct of_device_id *matches, const struct device *dev)
0094 {
0095     return NULL;
0096 }
0097 
0098 static inline struct device_node *of_cpu_device_node_get(int cpu)
0099 {
0100     return NULL;
0101 }
0102 
0103 static inline int of_dma_configure_id(struct device *dev,
0104                       struct device_node *np,
0105                       bool force_dma,
0106                       const u32 *id)
0107 {
0108     return 0;
0109 }
0110 static inline int of_dma_configure(struct device *dev,
0111                    struct device_node *np,
0112                    bool force_dma)
0113 {
0114     return 0;
0115 }
0116 #endif /* CONFIG_OF */
0117 
0118 #endif /* _LINUX_OF_DEVICE_H */