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