• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6.36/drivers/uwb/
1
2
3#include <linux/kernel.h>
4#include <linux/init.h>
5#include <linux/module.h>
6#include <linux/device.h>
7#include <linux/err.h>
8#include <linux/kdev_t.h>
9#include <linux/random.h>
10
11#include "uwb-internal.h"
12
13
14/* UWB stack attributes (or 'global' constants) */
15
16
17/**
18 * If a beacon dissapears for longer than this, then we consider the
19 * device who was represented by that beacon to be gone.
20 *
21 * ECMA-368[17.2.3, last para] establishes that a device must not
22 * consider a device to be its neighbour if he doesn't receive a beacon
23 * for more than mMaxLostBeacons. mMaxLostBeacons is defined in
24 * ECMA-368[17.16] as 3; because we can get only one beacon per
25 * superframe, that'd be 3 * 65ms = 195 ~ 200 ms. Let's give it time
26 * for jitter and stuff and make it 500 ms.
27 */
28unsigned long beacon_timeout_ms = 500;
29
30static
31ssize_t beacon_timeout_ms_show(struct class *class,
32				struct class_attribute *attr,
33				char *buf)
34{
35	return scnprintf(buf, PAGE_SIZE, "%lu\n", beacon_timeout_ms);
36}
37
38static
39ssize_t beacon_timeout_ms_store(struct class *class,
40				struct class_attribute *attr,
41				const char *buf, size_t size)
42{
43	unsigned long bt;
44	ssize_t result;
45	result = sscanf(buf, "%lu", &bt);
46	if (result != 1)
47		return -EINVAL;
48	beacon_timeout_ms = bt;
49	return size;
50}
51
52static struct class_attribute uwb_class_attrs[] = {
53	__ATTR(beacon_timeout_ms, S_IWUSR | S_IRUGO,
54	       beacon_timeout_ms_show, beacon_timeout_ms_store),
55	__ATTR_NULL,
56};
57
58/** Device model classes */
59struct class uwb_rc_class = {
60	.name        = "uwb_rc",
61	.class_attrs = uwb_class_attrs,
62};
63
64
65static int __init uwb_subsys_init(void)
66{
67	int result = 0;
68
69	result = uwb_est_create();
70	if (result < 0) {
71		printk(KERN_ERR "uwb: Can't initialize EST subsystem\n");
72		goto error_est_init;
73	}
74
75	result = class_register(&uwb_rc_class);
76	if (result < 0)
77		goto error_uwb_rc_class_register;
78	uwb_dbg_init();
79	return 0;
80
81error_uwb_rc_class_register:
82	uwb_est_destroy();
83error_est_init:
84	return result;
85}
86module_init(uwb_subsys_init);
87
88static void __exit uwb_subsys_exit(void)
89{
90	uwb_dbg_exit();
91	class_unregister(&uwb_rc_class);
92	uwb_est_destroy();
93	return;
94}
95module_exit(uwb_subsys_exit);
96
97MODULE_AUTHOR("Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>");
98MODULE_DESCRIPTION("Ultra Wide Band core");
99MODULE_LICENSE("GPL");
100