1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49#include <linux/kernel.h>
50#include <linux/init.h>
51#include <linux/module.h>
52#include <linux/device.h>
53#include <linux/err.h>
54#include <linux/kdev_t.h>
55#include <linux/random.h>
56
57#include "uwb-internal.h"
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74unsigned long beacon_timeout_ms = 500;
75
76static
77ssize_t beacon_timeout_ms_show(struct class *class,
78 struct class_attribute *attr,
79 char *buf)
80{
81 return scnprintf(buf, PAGE_SIZE, "%lu\n", beacon_timeout_ms);
82}
83
84static
85ssize_t beacon_timeout_ms_store(struct class *class,
86 struct class_attribute *attr,
87 const char *buf, size_t size)
88{
89 unsigned long bt;
90 ssize_t result;
91 result = sscanf(buf, "%lu", &bt);
92 if (result != 1)
93 return -EINVAL;
94 beacon_timeout_ms = bt;
95 return size;
96}
97
98static struct class_attribute uwb_class_attrs[] = {
99 __ATTR(beacon_timeout_ms, S_IWUSR | S_IRUGO,
100 beacon_timeout_ms_show, beacon_timeout_ms_store),
101 __ATTR_NULL,
102};
103
104
105struct class uwb_rc_class = {
106 .name = "uwb_rc",
107 .class_attrs = uwb_class_attrs,
108};
109
110
111static int __init uwb_subsys_init(void)
112{
113 int result = 0;
114
115 result = uwb_est_create();
116 if (result < 0) {
117 printk(KERN_ERR "uwb: Can't initialize EST subsystem\n");
118 goto error_est_init;
119 }
120
121 result = class_register(&uwb_rc_class);
122 if (result < 0)
123 goto error_uwb_rc_class_register;
124
125
126 result = bus_register(&uwb_bus_type);
127 if (result) {
128 pr_err("%s - registering bus driver failed\n", __func__);
129 goto exit_bus;
130 }
131
132 uwb_dbg_init();
133 return 0;
134
135exit_bus:
136 class_unregister(&uwb_rc_class);
137error_uwb_rc_class_register:
138 uwb_est_destroy();
139error_est_init:
140 return result;
141}
142module_init(uwb_subsys_init);
143
144static void __exit uwb_subsys_exit(void)
145{
146 uwb_dbg_exit();
147 bus_unregister(&uwb_bus_type);
148 class_unregister(&uwb_rc_class);
149 uwb_est_destroy();
150 return;
151}
152module_exit(uwb_subsys_exit);
153
154MODULE_AUTHOR("Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>");
155MODULE_DESCRIPTION("Ultra Wide Band core");
156MODULE_LICENSE("GPL");
157