Lines Matching refs:neh
120 struct uwb_rc_neh *neh = container_of(kref, struct uwb_rc_neh, kref); in uwb_rc_neh_release() local
122 kfree(neh); in uwb_rc_neh_release()
125 static void uwb_rc_neh_get(struct uwb_rc_neh *neh) in uwb_rc_neh_get() argument
127 kref_get(&neh->kref); in uwb_rc_neh_get()
134 void uwb_rc_neh_put(struct uwb_rc_neh *neh) in uwb_rc_neh_put() argument
136 kref_put(&neh->kref, uwb_rc_neh_release); in uwb_rc_neh_put()
161 int __uwb_rc_ctx_get(struct uwb_rc *rc, struct uwb_rc_neh *neh) in __uwb_rc_ctx_get() argument
174 neh->context = result; in __uwb_rc_ctx_get()
181 void __uwb_rc_ctx_put(struct uwb_rc *rc, struct uwb_rc_neh *neh) in __uwb_rc_ctx_put() argument
184 if (neh->context == 0) in __uwb_rc_ctx_put()
186 if (test_bit(neh->context, rc->ctx_bm) == 0) { in __uwb_rc_ctx_put()
188 neh->context); in __uwb_rc_ctx_put()
191 clear_bit(neh->context, rc->ctx_bm); in __uwb_rc_ctx_put()
192 neh->context = 0; in __uwb_rc_ctx_put()
214 struct uwb_rc_neh *neh; in uwb_rc_neh_add() local
216 neh = kzalloc(sizeof(*neh), GFP_KERNEL); in uwb_rc_neh_add()
217 if (neh == NULL) { in uwb_rc_neh_add()
222 kref_init(&neh->kref); in uwb_rc_neh_add()
223 INIT_LIST_HEAD(&neh->list_node); in uwb_rc_neh_add()
224 init_timer(&neh->timer); in uwb_rc_neh_add()
225 neh->timer.function = uwb_rc_neh_timer; in uwb_rc_neh_add()
226 neh->timer.data = (unsigned long)neh; in uwb_rc_neh_add()
228 neh->rc = rc; in uwb_rc_neh_add()
229 neh->evt_type = expected_type; in uwb_rc_neh_add()
230 neh->evt = cpu_to_le16(expected_event); in uwb_rc_neh_add()
231 neh->cb = cb; in uwb_rc_neh_add()
232 neh->arg = arg; in uwb_rc_neh_add()
235 result = __uwb_rc_ctx_get(rc, neh); in uwb_rc_neh_add()
237 cmd->bCommandContext = neh->context; in uwb_rc_neh_add()
238 list_add_tail(&neh->list_node, &rc->neh_list); in uwb_rc_neh_add()
239 uwb_rc_neh_get(neh); in uwb_rc_neh_add()
245 return neh; in uwb_rc_neh_add()
248 kfree(neh); 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()
257 list_del(&neh->list_node); 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
273 __uwb_rc_neh_rm(rc, neh); in uwb_rc_neh_rm()
276 del_timer_sync(&neh->timer); in uwb_rc_neh_rm()
277 uwb_rc_neh_put(neh); 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
293 if (neh->context) in uwb_rc_neh_arm()
294 mod_timer(&neh->timer, in uwb_rc_neh_arm()
299 static void uwb_rc_neh_cb(struct uwb_rc_neh *neh, struct uwb_rceb *rceb, size_t size) in uwb_rc_neh_cb() argument
301 (*neh->cb)(neh->rc, neh->arg, rceb, size); in uwb_rc_neh_cb()
302 uwb_rc_neh_put(neh); in uwb_rc_neh_cb()
305 static bool uwb_rc_neh_match(struct uwb_rc_neh *neh, const struct uwb_rceb *rceb) in uwb_rc_neh_match() argument
307 return neh->evt_type == rceb->bEventType in uwb_rc_neh_match()
308 && neh->evt == rceb->wEvent in uwb_rc_neh_match()
309 && neh->context == rceb->bEventContext; in uwb_rc_neh_match()
330 struct uwb_rc_neh *neh = NULL, *h; in uwb_rc_neh_lookup() local
337 neh = h; in uwb_rc_neh_lookup()
342 if (neh) in uwb_rc_neh_lookup()
343 __uwb_rc_neh_rm(rc, neh); in uwb_rc_neh_lookup()
347 return neh; in uwb_rc_neh_lookup()
409 struct uwb_rc_neh *neh; in uwb_rc_neh_grok_event() local
422 neh = uwb_rc_neh_lookup(rc, rceb); in uwb_rc_neh_grok_event()
423 if (neh) { in uwb_rc_neh_grok_event()
424 del_timer_sync(&neh->timer); in uwb_rc_neh_grok_event()
425 uwb_rc_neh_cb(neh, rceb, size); in uwb_rc_neh_grok_event()
543 struct uwb_rc_neh *neh; in uwb_rc_neh_error() local
552 neh = list_first_entry(&rc->neh_list, struct uwb_rc_neh, list_node); in uwb_rc_neh_error()
553 __uwb_rc_neh_rm(rc, neh); in uwb_rc_neh_error()
556 del_timer_sync(&neh->timer); in uwb_rc_neh_error()
557 uwb_rc_neh_cb(neh, NULL, error); in uwb_rc_neh_error()
565 struct uwb_rc_neh *neh = (struct uwb_rc_neh *)arg; in uwb_rc_neh_timer() local
566 struct uwb_rc *rc = neh->rc; in uwb_rc_neh_timer()
570 if (neh->context) in uwb_rc_neh_timer()
571 __uwb_rc_neh_rm(rc, neh); in uwb_rc_neh_timer()
573 neh = NULL; in uwb_rc_neh_timer()
576 if (neh) in uwb_rc_neh_timer()
577 uwb_rc_neh_cb(neh, NULL, -ETIMEDOUT); in uwb_rc_neh_timer()
596 struct uwb_rc_neh *neh; in uwb_rc_neh_destroy() local
604 neh = list_first_entry(&rc->neh_list, struct uwb_rc_neh, list_node); in uwb_rc_neh_destroy()
605 __uwb_rc_neh_rm(rc, neh); in uwb_rc_neh_destroy()
608 del_timer_sync(&neh->timer); in uwb_rc_neh_destroy()
609 uwb_rc_neh_put(neh); in uwb_rc_neh_destroy()