xref: /openbsd-src/sys/dev/pci/drm/include/linux/device.h (revision 8550894424f8a4aa4aafb6cd57229dd6ed7cd9dd)
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/slab.h>
12 #include <linux/ioport.h>
13 #include <linux/lockdep.h>
14 #include <linux/pm.h>
15 #include <linux/kobject.h>
16 #include <linux/ratelimit.h> /* dev_printk.h -> ratelimit.h */
17 
18 struct device_node;
19 
20 struct device_driver {
21 	struct device *dev;
22 };
23 
24 struct device_attribute {
25 	struct attribute attr;
26 	ssize_t (*show)(struct device *, struct device_attribute *, char *);
27 };
28 
29 #define DEVICE_ATTR(_name, _mode, _show, _store) \
30 	struct device_attribute dev_attr_##_name
31 #define DEVICE_ATTR_RO(_name) \
32 	struct device_attribute dev_attr_##_name
33 
34 #define device_create_file(a, b)	0
35 #define device_remove_file(a, b)
36 
37 #define dev_get_drvdata(x)	NULL
38 #define dev_set_drvdata(x, y)
39 
40 #define dev_pm_set_driver_flags(x, y)
41 
42 #define devm_kzalloc(x, y, z)	kzalloc(y, z)
43 
44 #define dev_warn(dev, fmt, arg...)				\
45 	printf("drm:pid%d:%s *WARNING* " fmt, curproc->p_p->ps_pid,	\
46 	    __func__ , ## arg)
47 #define dev_WARN(dev, fmt, arg...)				\
48 	printf("drm:pid%d:%s *WARNING* " fmt, curproc->p_p->ps_pid,	\
49 	    __func__ , ## arg)
50 #define dev_notice(dev, fmt, arg...)				\
51 	printf("drm:pid%d:%s *NOTICE* " fmt, curproc->p_p->ps_pid,	\
52 	    __func__ , ## arg)
53 #define dev_crit(dev, fmt, arg...)				\
54 	printf("drm:pid%d:%s *ERROR* " fmt, curproc->p_p->ps_pid,	\
55 	    __func__ , ## arg)
56 #define dev_err(dev, fmt, arg...)				\
57 	printf("drm:pid%d:%s *ERROR* " fmt, curproc->p_p->ps_pid,	\
58 	    __func__ , ## arg)
59 #define dev_emerg(dev, fmt, arg...)				\
60 	printf("drm:pid%d:%s *EMERGENCY* " fmt, curproc->p_p->ps_pid,	\
61 	    __func__ , ## arg)
62 #define dev_printk(level, dev, fmt, arg...)				\
63 	printf("drm:pid%d:%s *PRINTK* " fmt, curproc->p_p->ps_pid,	\
64 	    __func__ , ## arg)
65 
66 #define dev_warn_ratelimited(dev, fmt, arg...)				\
67 	printf("drm:pid%d:%s *WARNING* " fmt, curproc->p_p->ps_pid,	\
68 	    __func__ , ## arg)
69 #define dev_notice_ratelimited(dev, fmt, arg...)			\
70 	printf("drm:pid%d:%s *NOTICE* " fmt, curproc->p_p->ps_pid,	\
71 	    __func__ , ## arg)
72 #define dev_err_ratelimited(dev, fmt, arg...)				\
73 	printf("drm:pid%d:%s *ERROR* " fmt, curproc->p_p->ps_pid,	\
74 	    __func__ , ## arg)
75 
76 #define dev_warn_once(dev, fmt, arg...)				\
77 	printf("drm:pid%d:%s *WARNING* " fmt, curproc->p_p->ps_pid,	\
78 	    __func__ , ## arg)
79 #define dev_err_once(dev, fmt, arg...)				\
80 	printf("drm:pid%d:%s *ERROR* " fmt, curproc->p_p->ps_pid,	\
81 	    __func__ , ## arg)
82 
83 #ifdef DRMDEBUG
84 #define dev_info(dev, fmt, arg...)				\
85 	printf("drm: " fmt, ## arg)
86 #define dev_info_once(dev, fmt, arg...)				\
87 	printf("drm: " fmt, ## arg)
88 #define dev_dbg(dev, fmt, arg...)				\
89 	printf("drm:pid%d:%s *DEBUG* " fmt, curproc->p_p->ps_pid,	\
90 	    __func__ , ## arg)
91 #define dev_dbg_once(dev, fmt, arg...)				\
92 	printf("drm:pid%d:%s *DEBUG* " fmt, curproc->p_p->ps_pid,	\
93 	    __func__ , ## arg)
94 #define dev_dbg_ratelimited(dev, fmt, arg...)			\
95 	printf("drm:pid%d:%s *DEBUG* " fmt, curproc->p_p->ps_pid,	\
96 	    __func__ , ## arg)
97 #else
98 #define dev_info(dev, fmt, arg...) 				\
99 	    do { } while(0)
100 #define dev_info_once(dev, fmt, arg...) 			\
101 	    do { } while(0)
102 #define dev_dbg(dev, fmt, arg...) 				\
103 	    do { } while(0)
104 #define dev_dbg_once(dev, fmt, arg...) 				\
105 	    do { } while(0)
106 #define dev_dbg_ratelimited(dev, fmt, arg...) 			\
107 	    do { } while(0)
108 #endif
109 
110 static inline const char *
111 dev_driver_string(struct device *dev)
112 {
113 	return dev->dv_cfdata->cf_driver->cd_name;
114 }
115 
116 /* should be bus id as string, ie 0000:00:02.0 */
117 #define dev_name(dev)		""
118 
119 #endif
120