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()
230 neh->rc = rc; in uwb_rc_neh_add()
236 spin_lock_irqsave(&rc->neh_lock, flags); in uwb_rc_neh_add()
237 result = __uwb_rc_ctx_get(rc, neh); in uwb_rc_neh_add()
240 list_add_tail(&neh->list_node, &rc->neh_list); in uwb_rc_neh_add()
243 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_add()
256 static void __uwb_rc_neh_rm(struct uwb_rc *rc, struct uwb_rc_neh *neh) in __uwb_rc_neh_rm() argument
258 __uwb_rc_ctx_put(rc, neh); in __uwb_rc_neh_rm()
270 void uwb_rc_neh_rm(struct uwb_rc *rc, struct uwb_rc_neh *neh) in uwb_rc_neh_rm() argument
274 spin_lock_irqsave(&rc->neh_lock, flags); in uwb_rc_neh_rm()
275 __uwb_rc_neh_rm(rc, neh); in uwb_rc_neh_rm()
276 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_rm()
290 void uwb_rc_neh_arm(struct uwb_rc *rc, struct uwb_rc_neh *neh) in uwb_rc_neh_arm() argument
294 spin_lock_irqsave(&rc->neh_lock, flags); in uwb_rc_neh_arm()
298 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_arm()
303 (*neh->cb)(neh->rc, neh->arg, rceb, size); in uwb_rc_neh_cb()
329 struct uwb_rc_neh *uwb_rc_neh_lookup(struct uwb_rc *rc, in uwb_rc_neh_lookup() argument
335 spin_lock_irqsave(&rc->neh_lock, flags); in uwb_rc_neh_lookup()
337 list_for_each_entry(h, &rc->neh_list, list_node) { in uwb_rc_neh_lookup()
345 __uwb_rc_neh_rm(rc, neh); in uwb_rc_neh_lookup()
347 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_lookup()
379 void uwb_rc_notif(struct uwb_rc *rc, struct uwb_rceb *rceb, ssize_t size) in uwb_rc_notif() argument
381 struct device *dev = &rc->uwb_dev.dev; in uwb_rc_notif()
399 uwb_evt->rc = __uwb_rc_get(rc); /* will be put by uwbd's uwbd_event_handle() */ in uwb_rc_notif()
408 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
410 struct device *dev = &rc->uwb_dev.dev; in uwb_rc_neh_grok_event()
419 uwb_rc_notif(rc, notif, size); in uwb_rc_neh_grok_event()
425 neh = uwb_rc_neh_lookup(rc, rceb); in uwb_rc_neh_grok_event()
427 spin_lock_irqsave(&rc->neh_lock, flags); in uwb_rc_neh_grok_event()
431 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_grok_event()
480 void uwb_rc_neh_grok(struct uwb_rc *rc, void *buf, size_t buf_size) in uwb_rc_neh_grok() argument
482 struct device *dev = &rc->uwb_dev.dev; in uwb_rc_neh_grok()
499 if (rc->filter_event) { in uwb_rc_neh_grok()
500 needtofree = rc->filter_event(rc, &rceb, size, in uwb_rc_neh_grok()
515 ssize_t ret = uwb_est_find_size(rc, rceb, size); in uwb_rc_neh_grok()
528 uwb_rc_neh_grok_event(rc, rceb, event_size); in uwb_rc_neh_grok()
548 void uwb_rc_neh_error(struct uwb_rc *rc, int error) in uwb_rc_neh_error() argument
554 spin_lock_irqsave(&rc->neh_lock, flags); in uwb_rc_neh_error()
555 if (list_empty(&rc->neh_list)) { in uwb_rc_neh_error()
556 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_error()
559 neh = list_first_entry(&rc->neh_list, struct uwb_rc_neh, list_node); in uwb_rc_neh_error()
560 __uwb_rc_neh_rm(rc, neh); in uwb_rc_neh_error()
561 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_error()
573 struct uwb_rc *rc = neh->rc; in uwb_rc_neh_timer() local
576 spin_lock_irqsave(&rc->neh_lock, flags); in uwb_rc_neh_timer()
578 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_timer()
582 __uwb_rc_neh_rm(rc, neh); in uwb_rc_neh_timer()
585 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_timer()
593 void uwb_rc_neh_create(struct uwb_rc *rc) in uwb_rc_neh_create() argument
595 spin_lock_init(&rc->neh_lock); in uwb_rc_neh_create()
596 INIT_LIST_HEAD(&rc->neh_list); in uwb_rc_neh_create()
597 set_bit(0, rc->ctx_bm); /* 0 is reserved (see [WUSB] table 8-65) */ in uwb_rc_neh_create()
598 set_bit(0xff, rc->ctx_bm); /* and 0xff is invalid */ in uwb_rc_neh_create()
599 rc->ctx_roll = 1; in uwb_rc_neh_create()
604 void uwb_rc_neh_destroy(struct uwb_rc *rc) in uwb_rc_neh_destroy() argument
610 spin_lock_irqsave(&rc->neh_lock, flags); in uwb_rc_neh_destroy()
611 if (list_empty(&rc->neh_list)) { in uwb_rc_neh_destroy()
612 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_destroy()
615 neh = list_first_entry(&rc->neh_list, struct uwb_rc_neh, list_node); in uwb_rc_neh_destroy()
616 __uwb_rc_neh_rm(rc, neh); in uwb_rc_neh_destroy()
617 spin_unlock_irqrestore(&rc->neh_lock, flags); in uwb_rc_neh_destroy()