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