intel-iommu: Restore DMAR_BROKEN_GFX_WA option for broken graphics drivers
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / uwb / driver.c
blobda77e41de99004c5e80d2453561e6105553a0f40
1 /*
2 * Ultra Wide Band
3 * Driver initialization, etc
5 * Copyright (C) 2005-2006 Intel Corporation
6 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
23 * FIXME: docs
25 * Life cycle: FIXME: explain
27 * UWB radio controller:
29 * 1. alloc a uwb_rc, zero it
30 * 2. call uwb_rc_init() on it to set it up + ops (won't do any
31 * kind of allocation)
32 * 3. register (now it is owned by the UWB stack--deregister before
33 * freeing/destroying).
34 * 4. It lives on it's own now (UWB stack handles)--when it
35 * disconnects, call unregister()
36 * 5. free it.
38 * Make sure you have a reference to the uwb_rc before calling
39 * any of the UWB API functions.
41 * TODO:
43 * 1. Locking and life cycle management is crappy still. All entry
44 * points to the UWB HCD API assume you have a reference on the
45 * uwb_rc structure and that it won't go away. They mutex lock it
46 * before doing anything.
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>
57 #include "uwb-internal.h"
60 /* UWB stack attributes (or 'global' constants) */
63 /**
64 * If a beacon dissapears for longer than this, then we consider the
65 * device who was represented by that beacon to be gone.
67 * ECMA-368[17.2.3, last para] establishes that a device must not
68 * consider a device to be its neighbour if he doesn't receive a beacon
69 * for more than mMaxLostBeacons. mMaxLostBeacons is defined in
70 * ECMA-368[17.16] as 3; because we can get only one beacon per
71 * superframe, that'd be 3 * 65ms = 195 ~ 200 ms. Let's give it time
72 * for jitter and stuff and make it 500 ms.
74 unsigned long beacon_timeout_ms = 500;
76 static
77 ssize_t beacon_timeout_ms_show(struct class *class, char *buf)
79 return scnprintf(buf, PAGE_SIZE, "%lu\n", beacon_timeout_ms);
82 static
83 ssize_t beacon_timeout_ms_store(struct class *class,
84 const char *buf, size_t size)
86 unsigned long bt;
87 ssize_t result;
88 result = sscanf(buf, "%lu", &bt);
89 if (result != 1)
90 return -EINVAL;
91 beacon_timeout_ms = bt;
92 return size;
95 static struct class_attribute uwb_class_attrs[] = {
96 __ATTR(beacon_timeout_ms, S_IWUSR | S_IRUGO,
97 beacon_timeout_ms_show, beacon_timeout_ms_store),
98 __ATTR_NULL,
101 /** Device model classes */
102 struct class uwb_rc_class = {
103 .name = "uwb_rc",
104 .class_attrs = uwb_class_attrs,
108 static int __init uwb_subsys_init(void)
110 int result = 0;
112 result = uwb_est_create();
113 if (result < 0) {
114 printk(KERN_ERR "uwb: Can't initialize EST subsystem\n");
115 goto error_est_init;
118 result = class_register(&uwb_rc_class);
119 if (result < 0)
120 goto error_uwb_rc_class_register;
121 uwb_dbg_init();
122 return 0;
124 error_uwb_rc_class_register:
125 uwb_est_destroy();
126 error_est_init:
127 return result;
129 module_init(uwb_subsys_init);
131 static void __exit uwb_subsys_exit(void)
133 uwb_dbg_exit();
134 class_unregister(&uwb_rc_class);
135 uwb_est_destroy();
136 return;
138 module_exit(uwb_subsys_exit);
140 MODULE_AUTHOR("Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>");
141 MODULE_DESCRIPTION("Ultra Wide Band core");
142 MODULE_LICENSE("GPL");