Lines Matching refs:neh

122 	struct uwb_rc_neh *neh = container_of(kref, struct uwb_rc_neh, kref);  in uwb_rc_neh_release()  local
124 kfree(neh); in uwb_rc_neh_release()
127 static void uwb_rc_neh_get(struct uwb_rc_neh *neh) in uwb_rc_neh_get() argument
129 kref_get(&neh->kref); in uwb_rc_neh_get()
136 void uwb_rc_neh_put(struct uwb_rc_neh *neh) in uwb_rc_neh_put() argument
138 kref_put(&neh->kref, uwb_rc_neh_release); in uwb_rc_neh_put()
163 int __uwb_rc_ctx_get(struct uwb_rc *rc, struct uwb_rc_neh *neh) in __uwb_rc_ctx_get() argument
176 neh->context = result; 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
186 if (neh->context == 0) in __uwb_rc_ctx_put()
188 if (test_bit(neh->context, rc->ctx_bm) == 0) { in __uwb_rc_ctx_put()
190 neh->context); in __uwb_rc_ctx_put()
193 clear_bit(neh->context, rc->ctx_bm); in __uwb_rc_ctx_put()
194 neh->context = 0; in __uwb_rc_ctx_put()
216 struct uwb_rc_neh *neh; in uwb_rc_neh_add() local
218 neh = kzalloc(sizeof(*neh), GFP_KERNEL); in uwb_rc_neh_add()
219 if (neh == NULL) { in uwb_rc_neh_add()
224 kref_init(&neh->kref); in uwb_rc_neh_add()
225 INIT_LIST_HEAD(&neh->list_node); in uwb_rc_neh_add()
226 init_timer(&neh->timer); in uwb_rc_neh_add()
227 neh->timer.function = uwb_rc_neh_timer; in uwb_rc_neh_add()
228 neh->timer.data = (unsigned long)neh; in uwb_rc_neh_add()
230 neh->rc = rc; in uwb_rc_neh_add()
231 neh->evt_type = expected_type; in uwb_rc_neh_add()
232 neh->evt = cpu_to_le16(expected_event); in uwb_rc_neh_add()
233 neh->cb = cb; in uwb_rc_neh_add()
234 neh->arg = arg; in uwb_rc_neh_add()
237 result = __uwb_rc_ctx_get(rc, neh); in uwb_rc_neh_add()
239 cmd->bCommandContext = neh->context; in uwb_rc_neh_add()
240 list_add_tail(&neh->list_node, &rc->neh_list); in uwb_rc_neh_add()
241 uwb_rc_neh_get(neh); in uwb_rc_neh_add()
247 return neh; in uwb_rc_neh_add()
250 kfree(neh); 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()
259 list_del(&neh->list_node); 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
275 __uwb_rc_neh_rm(rc, neh); in uwb_rc_neh_rm()
278 del_timer_sync(&neh->timer); in uwb_rc_neh_rm()
279 uwb_rc_neh_put(neh); 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
295 if (neh->context) in uwb_rc_neh_arm()
296 mod_timer(&neh->timer, in uwb_rc_neh_arm()
301 static void uwb_rc_neh_cb(struct uwb_rc_neh *neh, struct uwb_rceb *rceb, size_t size) in uwb_rc_neh_cb() argument
303 (*neh->cb)(neh->rc, neh->arg, rceb, size); in uwb_rc_neh_cb()
304 uwb_rc_neh_put(neh); in uwb_rc_neh_cb()
307 static bool uwb_rc_neh_match(struct uwb_rc_neh *neh, const struct uwb_rceb *rceb) in uwb_rc_neh_match() argument
309 return neh->evt_type == rceb->bEventType in uwb_rc_neh_match()
310 && neh->evt == rceb->wEvent in uwb_rc_neh_match()
311 && neh->context == rceb->bEventContext; in uwb_rc_neh_match()
332 struct uwb_rc_neh *neh = NULL, *h; in uwb_rc_neh_lookup() local
339 neh = h; in uwb_rc_neh_lookup()
344 if (neh) in uwb_rc_neh_lookup()
345 __uwb_rc_neh_rm(rc, neh); in uwb_rc_neh_lookup()
349 return neh; in uwb_rc_neh_lookup()
411 struct uwb_rc_neh *neh; in uwb_rc_neh_grok_event() local
425 neh = uwb_rc_neh_lookup(rc, rceb); in uwb_rc_neh_grok_event()
426 if (neh) { in uwb_rc_neh_grok_event()
429 neh->completed = 1; in uwb_rc_neh_grok_event()
430 del_timer(&neh->timer); in uwb_rc_neh_grok_event()
432 uwb_rc_neh_cb(neh, rceb, size); in uwb_rc_neh_grok_event()
550 struct uwb_rc_neh *neh; in uwb_rc_neh_error() local
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()
563 del_timer_sync(&neh->timer); in uwb_rc_neh_error()
564 uwb_rc_neh_cb(neh, NULL, error); in uwb_rc_neh_error()
572 struct uwb_rc_neh *neh = (struct uwb_rc_neh *)arg; in uwb_rc_neh_timer() local
573 struct uwb_rc *rc = neh->rc; in uwb_rc_neh_timer()
577 if (neh->completed) { in uwb_rc_neh_timer()
581 if (neh->context) in uwb_rc_neh_timer()
582 __uwb_rc_neh_rm(rc, neh); in uwb_rc_neh_timer()
584 neh = NULL; in uwb_rc_neh_timer()
587 if (neh) in uwb_rc_neh_timer()
588 uwb_rc_neh_cb(neh, NULL, -ETIMEDOUT); in uwb_rc_neh_timer()
607 struct uwb_rc_neh *neh; in uwb_rc_neh_destroy() local
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()
619 del_timer_sync(&neh->timer); in uwb_rc_neh_destroy()
620 uwb_rc_neh_put(neh); in uwb_rc_neh_destroy()