Lines Matching defs:rc
41 * 2. Issue command [rc->cmd(rc, ...)]
105 struct uwb_rc *rc;
141 * Assigns @neh a context id from @rc's pool
143 * @rc: UWB Radio Controller descriptor; @rc->neh_lock taken
157 * first we search from where @rc->ctx_roll is, if not found, we
161 int __uwb_rc_ctx_get(struct uwb_rc *rc, struct uwb_rc_neh *neh)
164 result = find_next_zero_bit(rc->ctx_bm, UWB_RC_CTX_MAX,
165 rc->ctx_roll++);
168 result = find_first_zero_bit(rc->ctx_bm, UWB_RC_CTX_MAX);
173 set_bit(result, rc->ctx_bm);
179 /** Releases @neh's context ID back to @rc (@rc->neh_lock is locked). */
181 void __uwb_rc_ctx_put(struct uwb_rc *rc, struct uwb_rc_neh *neh)
183 struct device *dev = &rc->uwb_dev.dev;
186 if (test_bit(neh->context, rc->ctx_bm) == 0) {
191 clear_bit(neh->context, rc->ctx_bm);
197 * @rc: the radio controller
207 struct uwb_rc_neh *uwb_rc_neh_add(struct uwb_rc *rc, struct uwb_rccb *cmd,
213 struct device *dev = &rc->uwb_dev.dev;
228 neh->rc = rc;
234 spin_lock_irqsave(&rc->neh_lock, flags);
235 result = __uwb_rc_ctx_get(rc, neh);
238 list_add_tail(&neh->list_node, &rc->neh_list);
241 spin_unlock_irqrestore(&rc->neh_lock, flags);
254 static void __uwb_rc_neh_rm(struct uwb_rc *rc, struct uwb_rc_neh *neh)
256 __uwb_rc_ctx_put(rc, neh);
262 * @rc: the radio controller
268 void uwb_rc_neh_rm(struct uwb_rc *rc, struct uwb_rc_neh *neh)
272 spin_lock_irqsave(&rc->neh_lock, flags);
273 __uwb_rc_neh_rm(rc, neh);
274 spin_unlock_irqrestore(&rc->neh_lock, flags);
283 * @rc: UWB Radio Controller
284 * @neh: Notification/event handler for @rc
288 void uwb_rc_neh_arm(struct uwb_rc *rc, struct uwb_rc_neh *neh)
292 spin_lock_irqsave(&rc->neh_lock, flags);
296 spin_unlock_irqrestore(&rc->neh_lock, flags);
301 (*neh->cb)(neh->rc, neh->arg, rceb, size);
315 * @rc: UWB Radio Controller
327 struct uwb_rc_neh *uwb_rc_neh_lookup(struct uwb_rc *rc,
333 spin_lock_irqsave(&rc->neh_lock, flags);
335 list_for_each_entry(h, &rc->neh_list, list_node) {
343 __uwb_rc_neh_rm(rc, neh);
345 spin_unlock_irqrestore(&rc->neh_lock, flags);
354 * @rc: UWB Radio Control Interface descriptor
377 void uwb_rc_notif(struct uwb_rc *rc, struct uwb_rceb *rceb, ssize_t size)
379 struct device *dev = &rc->uwb_dev.dev;
397 uwb_evt->rc = __uwb_rc_get(rc); /* will be put by uwbd's uwbd_event_handle() */
406 static void uwb_rc_neh_grok_event(struct uwb_rc *rc, struct uwb_rceb *rceb, size_t size)
408 struct device *dev = &rc->uwb_dev.dev;
416 uwb_rc_notif(rc, notif, size);
422 neh = uwb_rc_neh_lookup(rc, rceb);
437 * @rc: UWB Radio Controller
459 * @rc->neh_lock is NOT taken
473 void uwb_rc_neh_grok(struct uwb_rc *rc, void *buf, size_t buf_size)
475 struct device *dev = &rc->uwb_dev.dev;
492 if (rc->filter_event) {
493 needtofree = rc->filter_event(rc, &rceb, size,
508 ssize_t ret = uwb_est_find_size(rc, rceb, size);
521 uwb_rc_neh_grok_event(rc, rceb, event_size);
537 * @rc: UWB Radio Controller
541 void uwb_rc_neh_error(struct uwb_rc *rc, int error)
547 spin_lock_irqsave(&rc->neh_lock, flags);
548 if (list_empty(&rc->neh_list)) {
549 spin_unlock_irqrestore(&rc->neh_lock, flags);
552 neh = list_first_entry(&rc->neh_list, struct uwb_rc_neh, list_node);
553 __uwb_rc_neh_rm(rc, neh);
554 spin_unlock_irqrestore(&rc->neh_lock, flags);
566 struct uwb_rc *rc = neh->rc;
569 spin_lock_irqsave(&rc->neh_lock, flags);
571 __uwb_rc_neh_rm(rc, neh);
574 spin_unlock_irqrestore(&rc->neh_lock, flags);
580 /** Initializes the @rc's neh subsystem
582 void uwb_rc_neh_create(struct uwb_rc *rc)
584 spin_lock_init(&rc->neh_lock);
585 INIT_LIST_HEAD(&rc->neh_list);
586 set_bit(0, rc->ctx_bm); /* 0 is reserved (see [WUSB] table 8-65) */
587 set_bit(0xff, rc->ctx_bm); /* and 0xff is invalid */
588 rc->ctx_roll = 1;
592 /** Release's the @rc's neh subsystem */
593 void uwb_rc_neh_destroy(struct uwb_rc *rc)
599 spin_lock_irqsave(&rc->neh_lock, flags);
600 if (list_empty(&rc->neh_list)) {
601 spin_unlock_irqrestore(&rc->neh_lock, flags);
604 neh = list_first_entry(&rc->neh_list, struct uwb_rc_neh, list_node);
605 __uwb_rc_neh_rm(rc, neh);
606 spin_unlock_irqrestore(&rc->neh_lock, flags);