xref: /openbsd/sys/dev/pci/drm/include/linux/device.h (revision 3f7c134f)
1 /* Public domain. */
2 
3 #ifndef _LINUX_DEVICE_H
4 #define _LINUX_DEVICE_H
5 
6 #include <sys/types.h>
7 #include <sys/systm.h>
8 #include <sys/device.h>
9 #include <sys/param.h>
10 #include <sys/proc.h>
11 #include <linux/ioport.h>
12 #include <linux/lockdep.h>
13 #include <linux/pm.h>
14 #include <linux/kobject.h>
15 #include <linux/ratelimit.h> /* dev_printk.h -> ratelimit.h */
16 #include <linux/module.h> /* via device/driver.h */
17 
18 struct device_node;
19 
20 struct bus_type {
21 };
22 
23 struct device_driver {
24 	struct device *dev;
25 };
26 
27 struct device_attribute {
28 	struct attribute attr;
29 	ssize_t (*show)(struct device *, struct device_attribute *, char *);
30 };
31 
32 #define DEVICE_ATTR(_name, _mode, _show, _store) \
33 	struct device_attribute dev_attr_##_name
34 #define DEVICE_ATTR_RO(_name) \
35 	struct device_attribute dev_attr_##_name
36 
37 #define device_create_file(a, b)	0
38 #define device_remove_file(a, b)
39 
40 void	*dev_get_drvdata(struct device *);
41 void	dev_set_drvdata(struct device *, void *);
42 
43 #define dev_pm_set_driver_flags(x, y)
44 
45 #define devm_kzalloc(x, y, z)	kzalloc(y, z)
46 #define devm_kfree(x, y)	kfree(y)
47 
48 static inline int
devm_device_add_group(struct device * dev,const struct attribute_group * g)49 devm_device_add_group(struct device *dev, const struct attribute_group *g)
50 {
51 	return 0;
52 }
53 
54 #define dev_warn(dev, fmt, arg...)				\
55 	printf("drm:pid%d:%s *WARNING* " fmt, curproc->p_p->ps_pid,	\
56 	    __func__ , ## arg)
57 #define dev_WARN(dev, fmt, arg...)					\
58 	WARN(1, "drm:pid%d:%s *WARNING* " fmt, curproc->p_p->ps_pid,	\
59 	    __func__ , ## arg)
60 #define dev_notice(dev, fmt, arg...)				\
61 	printf("drm:pid%d:%s *NOTICE* " fmt, curproc->p_p->ps_pid,	\
62 	    __func__ , ## arg)
63 #define dev_crit(dev, fmt, arg...)				\
64 	printf("drm:pid%d:%s *ERROR* " fmt, curproc->p_p->ps_pid,	\
65 	    __func__ , ## arg)
66 #define dev_err(dev, fmt, arg...)				\
67 	printf("drm:pid%d:%s *ERROR* " fmt, curproc->p_p->ps_pid,	\
68 	    __func__ , ## arg)
69 #define dev_emerg(dev, fmt, arg...)				\
70 	printf("drm:pid%d:%s *EMERGENCY* " fmt, curproc->p_p->ps_pid,	\
71 	    __func__ , ## arg)
72 #define dev_printk(level, dev, fmt, arg...)				\
73 	printf("drm:pid%d:%s *PRINTK* " fmt, curproc->p_p->ps_pid,	\
74 	    __func__ , ## arg)
75 
76 #define dev_warn_ratelimited(dev, fmt, arg...)				\
77 	printf("drm:pid%d:%s *WARNING* " fmt, curproc->p_p->ps_pid,	\
78 	    __func__ , ## arg)
79 #define dev_notice_ratelimited(dev, fmt, arg...)			\
80 	printf("drm:pid%d:%s *NOTICE* " fmt, curproc->p_p->ps_pid,	\
81 	    __func__ , ## arg)
82 #define dev_err_ratelimited(dev, fmt, arg...)				\
83 	printf("drm:pid%d:%s *ERROR* " fmt, curproc->p_p->ps_pid,	\
84 	    __func__ , ## arg)
85 
86 #define dev_warn_once(dev, fmt, arg...)				\
87 	printf("drm:pid%d:%s *WARNING* " fmt, curproc->p_p->ps_pid,	\
88 	    __func__ , ## arg)
89 #define dev_WARN_ONCE(dev, cond, fmt, arg...)					\
90 	WARN_ONCE(cond, "drm:pid%d:%s *WARNING* " fmt, curproc->p_p->ps_pid,	\
91 	    __func__ , ## arg)
92 #define dev_err_once(dev, fmt, arg...)				\
93 	printf("drm:pid%d:%s *ERROR* " fmt, curproc->p_p->ps_pid,	\
94 	    __func__ , ## arg)
95 
96 #define dev_err_probe(dev, err, fmt, arg...)				\
97 	printf("drm:pid%d:%s *ERROR* " fmt, curproc->p_p->ps_pid,	\
98 	       __func__ , ## arg), err
99 
100 #ifdef DRMDEBUG
101 #define dev_info(dev, fmt, arg...)				\
102 	printf("drm: " fmt, ## arg)
103 #define dev_info_once(dev, fmt, arg...)				\
104 	printf("drm: " fmt, ## arg)
105 #define dev_dbg(dev, fmt, arg...)				\
106 	printf("drm:pid%d:%s *DEBUG* " fmt, curproc->p_p->ps_pid,	\
107 	    __func__ , ## arg)
108 #define dev_dbg_once(dev, fmt, arg...)				\
109 	printf("drm:pid%d:%s *DEBUG* " fmt, curproc->p_p->ps_pid,	\
110 	    __func__ , ## arg)
111 #define dev_dbg_ratelimited(dev, fmt, arg...)			\
112 	printf("drm:pid%d:%s *DEBUG* " fmt, curproc->p_p->ps_pid,	\
113 	    __func__ , ## arg)
114 #else
115 
116 static inline void
dev_info(struct device * dev,const char * fmt,...)117 dev_info(struct device *dev, const char *fmt, ...)
118 {
119 }
120 
121 static inline void
dev_info_once(struct device * dev,const char * fmt,...)122 dev_info_once(struct device *dev, const char *fmt, ...)
123 {
124 }
125 
126 static inline void
dev_dbg(struct device * dev,const char * fmt,...)127 dev_dbg(struct device *dev, const char *fmt, ...)
128 {
129 }
130 
131 static inline void
dev_dbg_once(struct device * dev,const char * fmt,...)132 dev_dbg_once(struct device *dev, const char *fmt, ...)
133 {
134 }
135 
136 static inline void
dev_dbg_ratelimited(struct device * dev,const char * fmt,...)137 dev_dbg_ratelimited(struct device *dev, const char *fmt, ...)
138 {
139 }
140 
141 #endif
142 
143 static inline const char *
dev_driver_string(struct device * dev)144 dev_driver_string(struct device *dev)
145 {
146 	return dev->dv_cfdata->cf_driver->cd_name;
147 }
148 
149 /* XXX return true for thunderbolt/USB4 */
150 #define dev_is_removable(x)	false
151 
152 /* should be bus id as string, ie 0000:00:02.0 */
153 #define dev_name(dev)		""
154 
155 static inline void
device_set_wakeup_path(struct device * dev)156 device_set_wakeup_path(struct device *dev)
157 {
158 }
159 
160 #endif
161