Lines Matching refs:rc
106 struct uwb_rc *rc; member
163 int __uwb_rc_ctx_get(struct uwb_rc *rc, struct uwb_rc_neh *neh) in __uwb_rc_ctx_get() argument
166 result = find_next_zero_bit(rc->ctx_bm, UWB_RC_CTX_MAX, in __uwb_rc_ctx_get()
167 rc->ctx_roll++); in __uwb_rc_ctx_get()
170 result = find_first_zero_bit(rc->ctx_bm, UWB_RC_CTX_MAX); in __uwb_rc_ctx_get()
175 set_bit(result, rc->ctx_bm); in __uwb_rc_ctx_get()
183 void __uwb_rc_ctx_put(struct uwb_rc *rc, struct uwb_rc_neh *neh) in __uwb_rc_ctx_put() argument
185 struct device *dev = &rc->uwb_dev.dev; in __uwb_rc_ctx_put()
188 if (test_bit(neh->context, rc->ctx_bm) == 0) { in __uwb_rc_ctx_put()
193 clear_bit(neh->context, rc->ctx_bm); in __uwb_rc_ctx_put()
209 struct uwb_rc_neh *uwb_rc_neh_add(struct uwb_rc *rc, struct uwb_rccb *cmd, in uwb_rc_neh_add() argument
215 struct device *dev = &rc->uwb_dev.dev; in uwb_rc_neh_add()
228 neh->rc = rc; in uwb_rc_neh_add()
234 spin_lock_irqsave(&rc->neh_lock, flags); in uwb_rc_neh_add()
235 result = __uwb_rc_ctx_get(rc, neh); in uwb_rc_neh_add()
238 list_add_tail(&neh->list_node, &rc->neh_list); in uwb_rc_neh_add()
241 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_add()
254 static void __uwb_rc_neh_rm(struct uwb_rc *rc, struct uwb_rc_neh *neh) in __uwb_rc_neh_rm() argument
256 __uwb_rc_ctx_put(rc, neh); in __uwb_rc_neh_rm()
268 void uwb_rc_neh_rm(struct uwb_rc *rc, struct uwb_rc_neh *neh) in uwb_rc_neh_rm() argument
272 spin_lock_irqsave(&rc->neh_lock, flags); in uwb_rc_neh_rm()
273 __uwb_rc_neh_rm(rc, neh); in uwb_rc_neh_rm()
274 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_rm()
288 void uwb_rc_neh_arm(struct uwb_rc *rc, struct uwb_rc_neh *neh) in uwb_rc_neh_arm() argument
292 spin_lock_irqsave(&rc->neh_lock, flags); in uwb_rc_neh_arm()
296 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_arm()
301 (*neh->cb)(neh->rc, neh->arg, rceb, size); in uwb_rc_neh_cb()
327 struct uwb_rc_neh *uwb_rc_neh_lookup(struct uwb_rc *rc, in uwb_rc_neh_lookup() argument
333 spin_lock_irqsave(&rc->neh_lock, flags); in uwb_rc_neh_lookup()
335 list_for_each_entry(h, &rc->neh_list, list_node) { in uwb_rc_neh_lookup()
343 __uwb_rc_neh_rm(rc, neh); in uwb_rc_neh_lookup()
345 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_lookup()
377 void uwb_rc_notif(struct uwb_rc *rc, struct uwb_rceb *rceb, ssize_t size) in uwb_rc_notif() argument
379 struct device *dev = &rc->uwb_dev.dev; in uwb_rc_notif()
397 uwb_evt->rc = __uwb_rc_get(rc); /* will be put by uwbd's uwbd_event_handle() */ in uwb_rc_notif()
406 static void uwb_rc_neh_grok_event(struct uwb_rc *rc, struct uwb_rceb *rceb, size_t size) in uwb_rc_neh_grok_event() argument
408 struct device *dev = &rc->uwb_dev.dev; in uwb_rc_neh_grok_event()
417 uwb_rc_notif(rc, notif, size); in uwb_rc_neh_grok_event()
423 neh = uwb_rc_neh_lookup(rc, rceb); in uwb_rc_neh_grok_event()
425 spin_lock_irqsave(&rc->neh_lock, flags); in uwb_rc_neh_grok_event()
429 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_grok_event()
478 void uwb_rc_neh_grok(struct uwb_rc *rc, void *buf, size_t buf_size) in uwb_rc_neh_grok() argument
480 struct device *dev = &rc->uwb_dev.dev; in uwb_rc_neh_grok()
497 if (rc->filter_event) { in uwb_rc_neh_grok()
498 needtofree = rc->filter_event(rc, &rceb, size, in uwb_rc_neh_grok()
513 ssize_t ret = uwb_est_find_size(rc, rceb, size); in uwb_rc_neh_grok()
526 uwb_rc_neh_grok_event(rc, rceb, event_size); in uwb_rc_neh_grok()
546 void uwb_rc_neh_error(struct uwb_rc *rc, int error) in uwb_rc_neh_error() argument
552 spin_lock_irqsave(&rc->neh_lock, flags); in uwb_rc_neh_error()
553 if (list_empty(&rc->neh_list)) { in uwb_rc_neh_error()
554 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_error()
557 neh = list_first_entry(&rc->neh_list, struct uwb_rc_neh, list_node); in uwb_rc_neh_error()
558 __uwb_rc_neh_rm(rc, neh); in uwb_rc_neh_error()
559 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_error()
571 struct uwb_rc *rc = neh->rc; in uwb_rc_neh_timer() local
574 spin_lock_irqsave(&rc->neh_lock, flags); in uwb_rc_neh_timer()
576 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_timer()
580 __uwb_rc_neh_rm(rc, neh); in uwb_rc_neh_timer()
583 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_timer()
591 void uwb_rc_neh_create(struct uwb_rc *rc) in uwb_rc_neh_create() argument
593 spin_lock_init(&rc->neh_lock); in uwb_rc_neh_create()
594 INIT_LIST_HEAD(&rc->neh_list); in uwb_rc_neh_create()
595 set_bit(0, rc->ctx_bm); /* 0 is reserved (see [WUSB] table 8-65) */ in uwb_rc_neh_create()
596 set_bit(0xff, rc->ctx_bm); /* and 0xff is invalid */ in uwb_rc_neh_create()
597 rc->ctx_roll = 1; in uwb_rc_neh_create()
602 void uwb_rc_neh_destroy(struct uwb_rc *rc) in uwb_rc_neh_destroy() argument
608 spin_lock_irqsave(&rc->neh_lock, flags); in uwb_rc_neh_destroy()
609 if (list_empty(&rc->neh_list)) { in uwb_rc_neh_destroy()
610 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_destroy()
613 neh = list_first_entry(&rc->neh_list, struct uwb_rc_neh, list_node); in uwb_rc_neh_destroy()
614 __uwb_rc_neh_rm(rc, neh); in uwb_rc_neh_destroy()
615 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_destroy()