Lines Matching refs:wusb_dev
98 static void wusb_dev_free(struct wusb_dev *wusb_dev) in wusb_dev_free() argument
100 kfree(wusb_dev); in wusb_dev_free()
103 static struct wusb_dev *wusb_dev_alloc(struct wusbhc *wusbhc) in wusb_dev_alloc()
105 struct wusb_dev *wusb_dev; in wusb_dev_alloc() local
107 wusb_dev = kzalloc(sizeof(*wusb_dev), GFP_KERNEL); in wusb_dev_alloc()
108 if (wusb_dev == NULL) in wusb_dev_alloc()
111 wusb_dev->wusbhc = wusbhc; in wusb_dev_alloc()
113 INIT_WORK(&wusb_dev->devconnect_acked_work, wusbhc_devconnect_acked_work); in wusb_dev_alloc()
115 return wusb_dev; in wusb_dev_alloc()
117 wusb_dev_free(wusb_dev); in wusb_dev_alloc()
135 struct wusb_dev *dev_itr; in wusbhc_fill_cack_ie()
162 static struct wusb_dev *wusbhc_cack_add(struct wusbhc *wusbhc, in wusbhc_cack_add()
167 struct wusb_dev *wusb_dev; in wusbhc_cack_add() local
173 list_for_each_entry(wusb_dev, &wusbhc->cack_list, cack_node) in wusbhc_cack_add()
174 if (!memcmp(&wusb_dev->cdid, &dnc->CDID, in wusbhc_cack_add()
175 sizeof(wusb_dev->cdid))) in wusbhc_cack_add()
176 return wusb_dev; in wusbhc_cack_add()
178 wusb_dev = wusb_dev_alloc(wusbhc); in wusbhc_cack_add()
179 if (wusb_dev == NULL) in wusbhc_cack_add()
181 wusb_dev_init(wusb_dev); in wusbhc_cack_add()
182 wusb_dev->cdid = dnc->CDID; in wusbhc_cack_add()
183 wusb_dev->port_idx = port_idx; in wusbhc_cack_add()
192 bitmap_fill(wusb_dev->availability.bm, UWB_NUM_MAS); in wusbhc_cack_add()
204 result = wusb_set_dev_addr(wusbhc, wusb_dev, dev_addr); in wusbhc_cack_add()
208 wusb_dev->entry_ts = jiffies; in wusbhc_cack_add()
209 list_add_tail(&wusb_dev->cack_node, &wusbhc->cack_list); in wusbhc_cack_add()
213 return wusb_dev; in wusbhc_cack_add()
221 static void wusbhc_cack_rm(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev) in wusbhc_cack_rm() argument
223 list_del_init(&wusb_dev->cack_node); in wusbhc_cack_rm()
231 void wusbhc_devconnect_acked(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev) in wusbhc_devconnect_acked() argument
233 wusbhc_cack_rm(wusbhc, wusb_dev); in wusbhc_devconnect_acked()
242 struct wusb_dev *wusb_dev = container_of(work, struct wusb_dev, in wusbhc_devconnect_acked_work() local
244 struct wusbhc *wusbhc = wusb_dev->wusbhc; in wusbhc_devconnect_acked_work()
247 wusbhc_devconnect_acked(wusbhc, wusb_dev); in wusbhc_devconnect_acked_work()
250 wusb_dev_put(wusb_dev); in wusbhc_devconnect_acked_work()
285 struct wusb_dev *wusb_dev; in wusbhc_devconnect_ack() local
294 if (port->wusb_dev in wusbhc_devconnect_ack()
295 && memcmp(&dnc->CDID, &port->wusb_dev->cdid, sizeof(dnc->CDID)) == 0) in wusbhc_devconnect_ack()
320 wusb_dev = wusbhc_cack_add(wusbhc, dnc, pr_cdid, idx); in wusbhc_devconnect_ack()
321 if (wusb_dev == NULL) in wusbhc_devconnect_ack()
329 port->wusb_dev = wusb_dev; in wusbhc_devconnect_ack()
361 struct wusb_dev *wusb_dev = port->wusb_dev; in __wusbhc_dev_disconnect() local
367 if (wusb_dev) { in __wusbhc_dev_disconnect()
368 dev_dbg(wusbhc->dev, "disconnecting device from port %d\n", wusb_dev->port_idx); in __wusbhc_dev_disconnect()
369 if (!list_empty(&wusb_dev->cack_node)) in __wusbhc_dev_disconnect()
370 list_del_init(&wusb_dev->cack_node); in __wusbhc_dev_disconnect()
372 wusb_dev_put(wusb_dev); in __wusbhc_dev_disconnect()
374 port->wusb_dev = NULL; in __wusbhc_dev_disconnect()
407 struct wusb_dev *wusb_dev; in __wusbhc_keep_alive() local
420 wusb_dev = wusb_port->wusb_dev; in __wusbhc_keep_alive()
422 if (wusb_dev == NULL) in __wusbhc_keep_alive()
424 if (wusb_dev->usb_dev == NULL) in __wusbhc_keep_alive()
427 if (time_after(jiffies, wusb_dev->entry_ts + tt)) { in __wusbhc_keep_alive()
429 wusb_dev->addr); in __wusbhc_keep_alive()
431 } else if (time_after(jiffies, wusb_dev->entry_ts + tt/3)) { in __wusbhc_keep_alive()
433 ie->bDeviceAddress[keep_alives++] = wusb_dev->addr; in __wusbhc_keep_alive()
469 static struct wusb_dev *wusbhc_find_dev_by_addr(struct wusbhc *wusbhc, u8 addr) in wusbhc_find_dev_by_addr()
480 return wusb_port_by_idx(wusbhc, port)->wusb_dev; in wusbhc_find_dev_by_addr()
485 struct wusb_dev *wusb_dev = wusb_port_by_idx(wusbhc, p)->wusb_dev; in wusbhc_find_dev_by_addr() local
486 if (wusb_dev && wusb_dev->addr == addr) in wusbhc_find_dev_by_addr()
487 return wusb_dev; in wusbhc_find_dev_by_addr()
502 struct wusb_dev *wusb_dev; in wusbhc_handle_dn_alive() local
505 wusb_dev = wusbhc_find_dev_by_addr(wusbhc, srcaddr); in wusbhc_handle_dn_alive()
506 if (wusb_dev == NULL) { in wusbhc_handle_dn_alive()
510 wusb_dev->entry_ts = jiffies; in wusbhc_handle_dn_alive()
569 struct wusb_dev *wusb_dev; in wusbhc_handle_dn_disconnect() local
572 wusb_dev = wusbhc_find_dev_by_addr(wusbhc, srcaddr); in wusbhc_handle_dn_disconnect()
573 if (wusb_dev == NULL) { in wusbhc_handle_dn_disconnect()
578 wusb_dev->addr); in wusbhc_handle_dn_disconnect()
580 wusb_dev->port_idx)); in wusbhc_handle_dn_disconnect()
657 struct wusb_dev *wusb_dev; in __wusbhc_dev_disable() local
660 wusb_dev = wusb_port_by_idx(wusbhc, port_idx)->wusb_dev; in __wusbhc_dev_disable()
661 if (wusb_dev == NULL) { in __wusbhc_dev_disable()
674 ie->bDeviceAddress = wusb_dev->addr; in __wusbhc_dev_disable()
703 struct wusb_dev *wusb_dev, in wusb_dev_bos_grok() argument
739 if (cap_size != sizeof(*wusb_dev->wusb_cap_descr)) in wusb_dev_bos_grok()
743 sizeof(*wusb_dev->wusb_cap_descr)); in wusb_dev_bos_grok()
745 wusb_dev->wusb_cap_descr = itr; in wusb_dev_bos_grok()
774 struct wusb_dev *wusb_dev) in wusb_dev_bos_add() argument
811 result = wusb_dev_bos_grok(usb_dev, wusb_dev, bos, result); in wusb_dev_bos_add()
814 wusb_dev->bos = bos; in wusb_dev_bos_add()
820 wusb_dev->wusb_cap_descr = NULL; in wusb_dev_bos_add()
824 static void wusb_dev_bos_rm(struct wusb_dev *wusb_dev) in wusb_dev_bos_rm() argument
826 kfree(wusb_dev->bos); in wusb_dev_bos_rm()
827 wusb_dev->wusb_cap_descr = NULL; in wusb_dev_bos_rm()
855 struct wusb_dev *wusb_dev; in wusb_dev_add_ncb() local
869 wusb_dev = __wusb_dev_get_by_usb_dev(wusbhc, usb_dev); in wusb_dev_add_ncb()
872 if (wusb_dev == NULL) in wusb_dev_add_ncb()
874 wusb_dev->usb_dev = usb_get_dev(usb_dev); in wusb_dev_add_ncb()
875 usb_dev->wusb_dev = wusb_dev_get(wusb_dev); in wusb_dev_add_ncb()
876 result = wusb_dev_sec_add(wusbhc, usb_dev, wusb_dev); in wusb_dev_add_ncb()
882 result = wusb_dev_bos_add(usb_dev, wusb_dev); in wusb_dev_add_ncb()
887 result = wusb_dev_sysfs_add(wusbhc, usb_dev, wusb_dev); in wusb_dev_add_ncb()
891 wusb_dev_put(wusb_dev); in wusb_dev_add_ncb()
896 wusb_dev_sysfs_rm(wusb_dev); in wusb_dev_add_ncb()
898 wusb_dev_bos_rm(wusb_dev); in wusb_dev_add_ncb()
900 wusb_dev_sec_rm(wusb_dev); in wusb_dev_add_ncb()
915 struct wusb_dev *wusb_dev = usb_dev->wusb_dev; in wusb_dev_rm_ncb() local
920 wusb_dev_sysfs_rm(wusb_dev); in wusb_dev_rm_ncb()
921 wusb_dev_bos_rm(wusb_dev); in wusb_dev_rm_ncb()
922 wusb_dev_sec_rm(wusb_dev); in wusb_dev_rm_ncb()
923 wusb_dev->usb_dev = NULL; in wusb_dev_rm_ncb()
924 usb_dev->wusb_dev = NULL; in wusb_dev_rm_ncb()
925 wusb_dev_put(wusb_dev); in wusb_dev_rm_ncb()
963 struct wusb_dev *__wusb_dev_get_by_usb_dev(struct wusbhc *wusbhc, in __wusb_dev_get_by_usb_dev()
966 struct wusb_dev *wusb_dev; in __wusb_dev_get_by_usb_dev() local
971 wusb_dev = wusb_port_by_idx(wusbhc, port_idx)->wusb_dev; in __wusb_dev_get_by_usb_dev()
972 if (wusb_dev != NULL) /* ops, device is gone */ in __wusb_dev_get_by_usb_dev()
973 wusb_dev_get(wusb_dev); in __wusb_dev_get_by_usb_dev()
974 return wusb_dev; in __wusb_dev_get_by_usb_dev()
980 struct wusb_dev *wusb_dev = container_of(_wusb_dev, struct wusb_dev, refcnt); in wusb_dev_destroy() local
982 list_del_init(&wusb_dev->cack_node); in wusb_dev_destroy()
983 wusb_dev_free(wusb_dev); in wusb_dev_destroy()
1067 if (wusbhc->port[i].wusb_dev) in wusbhc_devconnect_stop()
1084 int wusb_set_dev_addr(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev, u8 addr) in wusb_set_dev_addr() argument
1088 wusb_dev->addr = addr; in wusb_set_dev_addr()
1089 result = wusbhc->dev_info_set(wusbhc, wusb_dev); in wusb_set_dev_addr()
1092 "address\n", wusb_dev->port_idx); in wusb_set_dev_addr()
1095 wusb_dev->port_idx, in wusb_set_dev_addr()
1097 wusb_dev->addr); in wusb_set_dev_addr()