25 #include <linux/kernel.h>
26 #include <linux/slab.h>
27 #include <linux/device.h>
28 #include <linux/export.h>
30 #include <linux/kdev_t.h>
31 #include <linux/random.h>
32 #include <linux/stat.h>
50 return !uwb_dev_addr_cmp(addr, &bcast);
92 handler->
cb(handler->
data, uwb_dev, event);
101 static void uwb_dev_sys_release(
struct device *
dev)
105 uwb_bce_put(uwb_dev->
bce);
106 memset(uwb_dev, 0x69,
sizeof(*uwb_dev));
119 uwb_dev->
dev.release = uwb_dev_sys_release;
120 uwb_dev_addr_init(&uwb_dev->
dev_addr);
121 uwb_mac_addr_init(&uwb_dev->
mac_addr);
131 uwb_mac_addr_print(addr,
sizeof(addr), &uwb_dev->
mac_addr);
132 return sprintf(buf,
"%s\n", addr);
142 uwb_dev_addr_print(addr,
sizeof(addr), &uwb_dev->
dev_addr);
143 return sprintf(buf,
"%s\n", addr);
164 bpst = bce->
be->wBPSTOffset
168 return sprintf(buf,
"%d\n", bpst);
198 result = stats_show(&uwb_dev->
bce->lqe_stats, buf);
205 const char *buf,
size_t size)
212 result = stats_store(&uwb_dev->
bce->lqe_stats, buf, size);
226 result = stats_show(&uwb_dev->
bce->rssi_stats, buf);
233 const char *buf,
size_t size)
240 result = stats_store(&uwb_dev->
bce->rssi_stats, buf, size);
248 &dev_attr_EUI_48.attr,
249 &dev_attr_DevAddr.attr,
271 static int __uwb_dev_sys_add(
struct uwb_dev *uwb_dev,
struct device *parent_dev)
278 if (&uwb_dev->
rc->uwb_dev != uwb_dev)
287 static void __uwb_dev_sys_rm(
struct uwb_dev *uwb_dev)
319 uwb_dev->
rc = parent_rc;
320 result = __uwb_dev_sys_add(uwb_dev, parent_dev);
322 printk(
KERN_ERR "UWB: unable to register dev %s with sysfs: %d\n",
323 dev_name(dev), result);
332 __uwb_dev_sys_rm(uwb_dev);
338 int __uwb_dev_try_get(
struct device *dev,
void *__target_uwb_dev)
340 struct uwb_dev *target_uwb_dev = __target_uwb_dev;
342 if (uwb_dev == target_uwb_dev) {
343 uwb_dev_get(uwb_dev);
374 uwb_mac_addr_print(macbuf,
sizeof(macbuf), &uwb_dev->
mac_addr);
375 uwb_dev_addr_print(devbuf,
sizeof(devbuf), &uwb_dev->
dev_addr);
376 dev_info(dev,
"uwb device (mac %s dev %s) disconnected from %s %s\n",
378 rc ? rc->
uwb_dev.dev.parent->bus->name :
"n/a",
379 rc ? dev_name(rc->
uwb_dev.dev.parent) :
"");
382 uwb_bce_put(uwb_dev->
bce);
383 uwb_dev_put(uwb_dev);
403 struct uwb_dev *uwb_dev;
429 struct uwb_dev *uwb_dev;
432 uwb_mac_addr_print(macbuf,
sizeof(macbuf), bce->
mac_addr);
433 uwb_dev_addr_print(devbuf,
sizeof(devbuf), &bce->
dev_addr);
434 uwb_dev = kzalloc(
sizeof(
struct uwb_dev),
GFP_KERNEL);
435 if (uwb_dev ==
NULL) {
436 dev_err(dev,
"new device %s: Cannot allocate memory\n",
446 dev_err(dev,
"new device %s: cannot instantiate device\n",
454 dev_info(dev,
"uwb device (mac %s dev %s) connected to %s %s\n",
455 macbuf, devbuf, rc->
uwb_dev.dev.parent->bus->name,
456 dev_name(rc->
uwb_dev.dev.parent));