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}
97static CLASS_ATTR_RW(beacon_timeout_ms);
98
99static struct attribute *uwb_class_attrs[] = {
100 &class_attr_beacon_timeout_ms.attr,
101 NULL,
102};
103ATTRIBUTE_GROUPS(uwb_class);
104
105
106struct class uwb_rc_class = {
107 .name = "uwb_rc",
108 .class_groups = uwb_class_groups,
109};
110
111
112static int __init uwb_subsys_init(void)
113{
114 int result = 0;
115
116 result = uwb_est_create();
117 if (result < 0) {
118 printk(KERN_ERR "uwb: Can't initialize EST subsystem\n");
119 goto error_est_init;
120 }
121
122 result = class_register(&uwb_rc_class);
123 if (result < 0)
124 goto error_uwb_rc_class_register;
125
126
127 result = bus_register(&uwb_bus_type);
128 if (result) {
129 pr_err("%s - registering bus driver failed\n", __func__);
130 goto exit_bus;
131 }
132
133 uwb_dbg_init();
134 return 0;
135
136exit_bus:
137 class_unregister(&uwb_rc_class);
138error_uwb_rc_class_register:
139 uwb_est_destroy();
140error_est_init:
141 return result;
142}
143module_init(uwb_subsys_init);
144
145static void __exit uwb_subsys_exit(void)
146{
147 uwb_dbg_exit();
148 bus_unregister(&uwb_bus_type);
149 class_unregister(&uwb_rc_class);
150 uwb_est_destroy();
151 return;
152}
153module_exit(uwb_subsys_exit);
154
155MODULE_AUTHOR("Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>");
156MODULE_DESCRIPTION("Ultra Wide Band core");
157MODULE_LICENSE("GPL");
158