Lines Matching refs:wa
68 static int __rpipe_get_descr(struct wahc *wa, in __rpipe_get_descr() argument
72 struct device *dev = &wa->usb_iface->dev; in __rpipe_get_descr()
78 wa->usb_dev, usb_rcvctrlpipe(wa->usb_dev, 0), in __rpipe_get_descr()
106 static int __rpipe_set_descr(struct wahc *wa, in __rpipe_set_descr() argument
110 struct device *dev = &wa->usb_iface->dev; in __rpipe_set_descr()
116 wa->usb_dev, usb_sndctrlpipe(wa->usb_dev, 0), in __rpipe_set_descr()
148 static unsigned rpipe_get_idx(struct wahc *wa, unsigned rpipe_idx) in rpipe_get_idx() argument
152 spin_lock_irqsave(&wa->rpipe_lock, flags); in rpipe_get_idx()
153 rpipe_idx = find_next_zero_bit(wa->rpipe_bm, wa->rpipes, rpipe_idx); in rpipe_get_idx()
154 if (rpipe_idx < wa->rpipes) in rpipe_get_idx()
155 set_bit(rpipe_idx, wa->rpipe_bm); in rpipe_get_idx()
156 spin_unlock_irqrestore(&wa->rpipe_lock, flags); in rpipe_get_idx()
161 static void rpipe_put_idx(struct wahc *wa, unsigned rpipe_idx) in rpipe_put_idx() argument
165 spin_lock_irqsave(&wa->rpipe_lock, flags); in rpipe_put_idx()
166 clear_bit(rpipe_idx, wa->rpipe_bm); in rpipe_put_idx()
167 spin_unlock_irqrestore(&wa->rpipe_lock, flags); in rpipe_put_idx()
177 rpipe_put_idx(rpipe->wa, index); in rpipe_destroy()
178 wa_put(rpipe->wa); in rpipe_destroy()
193 static int rpipe_get_idle(struct wa_rpipe **prpipe, struct wahc *wa, u8 crs, in rpipe_get_idle() argument
199 struct device *dev = &wa->usb_iface->dev; in rpipe_get_idle()
207 for (rpipe_idx = 0; rpipe_idx < wa->rpipes; rpipe_idx++) { in rpipe_get_idle()
208 rpipe_idx = rpipe_get_idx(wa, rpipe_idx); in rpipe_get_idle()
209 if (rpipe_idx >= wa->rpipes) /* no more pipes :( */ in rpipe_get_idle()
211 result = __rpipe_get_descr(wa, &rpipe->descr, rpipe_idx); in rpipe_get_idle()
217 rpipe_put_idx(wa, rpipe_idx); in rpipe_get_idle()
224 set_bit(rpipe_idx, wa->rpipe_bm); in rpipe_get_idle()
225 rpipe->wa = wa_get(wa); in rpipe_get_idle()
230 static int __rpipe_reset(struct wahc *wa, unsigned index) in __rpipe_reset() argument
233 struct device *dev = &wa->usb_iface->dev; in __rpipe_reset()
236 wa->usb_dev, usb_sndctrlpipe(wa->usb_dev, 0), in __rpipe_reset()
313 static int rpipe_aim(struct wa_rpipe *rpipe, struct wahc *wa, in rpipe_aim() argument
317 struct device *dev = &wa->usb_iface->dev; in rpipe_aim()
330 __rpipe_reset(wa, le16_to_cpu(rpipe->descr.wRPipeIndex)); in rpipe_aim()
376 rpipe->descr.bmRetryOptions = (wa->wusb->retry_count & 0xF); in rpipe_aim()
379 result = __rpipe_set_descr(wa, &rpipe->descr, in rpipe_aim()
396 static int rpipe_check_aim(const struct wa_rpipe *rpipe, const struct wahc *wa, in rpipe_check_aim() argument
401 struct device *dev = &wa->usb_iface->dev; in rpipe_check_aim()
437 int rpipe_get_by_ep(struct wahc *wa, struct usb_host_endpoint *ep, in rpipe_get_by_ep() argument
441 struct device *dev = &wa->usb_iface->dev; in rpipe_get_by_ep()
445 mutex_lock(&wa->rpipe_mutex); in rpipe_get_by_ep()
449 result = rpipe_check_aim(rpipe, wa, ep, urb, gfp); in rpipe_get_by_ep()
461 result = rpipe_get_idle(&rpipe, wa, 1 << eptype, gfp); in rpipe_get_by_ep()
464 result = rpipe_aim(rpipe, wa, ep, urb, gfp); in rpipe_get_by_ep()
477 mutex_unlock(&wa->rpipe_mutex); in rpipe_get_by_ep()
484 int wa_rpipes_create(struct wahc *wa) in wa_rpipes_create() argument
486 wa->rpipes = le16_to_cpu(wa->wa_descr->wNumRPipes); in wa_rpipes_create()
487 wa->rpipe_bm = kzalloc(BITS_TO_LONGS(wa->rpipes)*sizeof(unsigned long), in wa_rpipes_create()
489 if (wa->rpipe_bm == NULL) in wa_rpipes_create()
494 void wa_rpipes_destroy(struct wahc *wa) in wa_rpipes_destroy() argument
496 struct device *dev = &wa->usb_iface->dev; in wa_rpipes_destroy()
498 if (!bitmap_empty(wa->rpipe_bm, wa->rpipes)) { in wa_rpipes_destroy()
501 wa->rpipes, wa->rpipe_bm); in wa_rpipes_destroy()
503 kfree(wa->rpipe_bm); in wa_rpipes_destroy()
516 void rpipe_ep_disable(struct wahc *wa, struct usb_host_endpoint *ep) in rpipe_ep_disable() argument
520 mutex_lock(&wa->rpipe_mutex); in rpipe_ep_disable()
526 wa->usb_dev, usb_sndctrlpipe(wa->usb_dev, 0), in rpipe_ep_disable()
532 mutex_unlock(&wa->rpipe_mutex); in rpipe_ep_disable()
537 void rpipe_clear_feature_stalled(struct wahc *wa, struct usb_host_endpoint *ep) in rpipe_clear_feature_stalled() argument
541 mutex_lock(&wa->rpipe_mutex); in rpipe_clear_feature_stalled()
547 wa->usb_dev, usb_sndctrlpipe(wa->usb_dev, 0), in rpipe_clear_feature_stalled()
552 mutex_unlock(&wa->rpipe_mutex); in rpipe_clear_feature_stalled()