30 #include <linux/kernel.h>
31 #include <linux/string.h>
32 #include <linux/device.h>
34 #include <linux/random.h>
35 #include <linux/kdev_t.h>
38 #include <linux/slab.h>
39 #include <linux/export.h>
48 if (rc->
index == *index)
53 static struct uwb_rc *uwb_rc_find_by_index(
int index)
64 static int uwb_rc_new_index(
void)
69 if (!uwb_rc_find_by_index(index))
79 static void uwb_rc_sys_release(
struct device *dev)
95 rc->
uwb_dev.dev.release = uwb_rc_sys_release;
136 static int uwb_rc_sys_add(
struct uwb_rc *rc)
142 static void __uwb_rc_sys_rm(
struct uwb_rc *rc)
157 int uwb_rc_mac_addr_setup(
struct uwb_rc *rc)
167 dev_err(dev,
"cannot retrieve UWB EUI-48 address: %d\n", result);
171 if (uwb_mac_addr_unset(&
addr) || uwb_mac_addr_bcast(&
addr)) {
177 uwb_mac_addr_print(devname,
sizeof(devname), &
addr);
178 dev_err(dev,
"cannot set EUI-48 address %s: %d\n",
189 static int uwb_rc_setup(
struct uwb_rc *rc)
196 dev_err(dev,
"cannot setup UWB radio: %d\n", result);
199 result = uwb_rc_mac_addr_setup(rc);
201 dev_err(dev,
"cannot setup UWB MAC address: %d\n", result);
206 dev_err(dev,
"cannot assign UWB DevAddr: %d\n", result);
211 dev_err(dev,
"cannot setup IE subsystem: %d\n", result);
216 dev_err(dev,
"cannot setup reservation subsystem: %d\n", result);
217 goto error_rsv_setup;
246 rc->
index = uwb_rc_new_index();
254 INIT_LIST_HEAD(&rc->
uwbd.event_list);
259 result = rc->
start(rc);
263 result = uwb_rc_setup(rc);
265 dev_err(dev,
"cannot setup UWB radio controller: %d\n", result);
273 result = uwb_rc_sys_add(rc);
275 dev_err(parent_dev,
"cannot register UWB radio controller "
276 "dev attributes: %d\n", result);
280 uwb_mac_addr_print(macbuf,
sizeof(macbuf), &rc->
uwb_dev.mac_addr);
281 uwb_dev_addr_print(devbuf,
sizeof(devbuf), &rc->
uwb_dev.dev_addr);
283 "new uwb radio controller (mac %s dev %s) on %s %s\n",
284 macbuf, devbuf, parent_dev->
bus->name, dev_name(parent_dev));
300 static int uwb_dev_offair_helper(
struct device *dev,
void *
priv)
337 static int find_rc_try_get(
struct device *dev,
void *data)
346 if (rc == target_rc) {
381 static inline struct uwb_rc *uwb_rc_get(
struct uwb_rc *rc)
389 static int find_rc_grandpa(
struct device *dev,
void *data)
394 if (rc->
uwb_dev.dev.parent->parent == grandpa_dev) {
435 static int find_rc_dev(
struct device *dev,
void *data)
444 if (!uwb_dev_addr_cmp(&rc->
uwb_dev.dev_addr, addr)) {