Lines Matching refs:drv_data

43 static int nfcmrvl_inc_tx(struct nfcmrvl_usb_drv_data *drv_data)  in nfcmrvl_inc_tx()  argument
48 spin_lock_irqsave(&drv_data->txlock, flags); in nfcmrvl_inc_tx()
49 rv = test_bit(NFCMRVL_USB_SUSPENDING, &drv_data->flags); in nfcmrvl_inc_tx()
51 drv_data->tx_in_flight++; in nfcmrvl_inc_tx()
52 spin_unlock_irqrestore(&drv_data->txlock, flags); in nfcmrvl_inc_tx()
59 struct nfcmrvl_usb_drv_data *drv_data = urb->context; in nfcmrvl_bulk_complete() local
62 dev_dbg(&drv_data->udev->dev, "urb %p status %d count %d\n", in nfcmrvl_bulk_complete()
65 if (!test_bit(NFCMRVL_NCI_RUNNING, &drv_data->flags)) in nfcmrvl_bulk_complete()
71 skb = nci_skb_alloc(drv_data->priv->ndev, urb->actual_length, in nfcmrvl_bulk_complete()
74 nfc_err(&drv_data->udev->dev, "failed to alloc mem\n"); in nfcmrvl_bulk_complete()
78 if (nfcmrvl_nci_recv_frame(drv_data->priv, skb) < 0) in nfcmrvl_bulk_complete()
79 nfc_err(&drv_data->udev->dev, in nfcmrvl_bulk_complete()
84 if (!test_bit(NFCMRVL_USB_BULK_RUNNING, &drv_data->flags)) in nfcmrvl_bulk_complete()
87 usb_anchor_urb(urb, &drv_data->bulk_anchor); in nfcmrvl_bulk_complete()
88 usb_mark_last_busy(drv_data->udev); in nfcmrvl_bulk_complete()
96 nfc_err(&drv_data->udev->dev, in nfcmrvl_bulk_complete()
103 nfcmrvl_submit_bulk_urb(struct nfcmrvl_usb_drv_data *drv_data, gfp_t mem_flags) in nfcmrvl_submit_bulk_urb() argument
110 if (!drv_data->bulk_rx_ep) in nfcmrvl_submit_bulk_urb()
123 pipe = usb_rcvbulkpipe(drv_data->udev, in nfcmrvl_submit_bulk_urb()
124 drv_data->bulk_rx_ep->bEndpointAddress); in nfcmrvl_submit_bulk_urb()
126 usb_fill_bulk_urb(urb, drv_data->udev, pipe, buf, size, in nfcmrvl_submit_bulk_urb()
127 nfcmrvl_bulk_complete, drv_data); in nfcmrvl_submit_bulk_urb()
131 usb_mark_last_busy(drv_data->udev); in nfcmrvl_submit_bulk_urb()
132 usb_anchor_urb(urb, &drv_data->bulk_anchor); in nfcmrvl_submit_bulk_urb()
137 nfc_err(&drv_data->udev->dev, in nfcmrvl_submit_bulk_urb()
152 struct nfcmrvl_usb_drv_data *drv_data = priv->drv_data; in nfcmrvl_tx_complete() local
158 spin_lock_irqsave(&drv_data->txlock, flags); in nfcmrvl_tx_complete()
159 drv_data->tx_in_flight--; in nfcmrvl_tx_complete()
160 spin_unlock_irqrestore(&drv_data->txlock, flags); in nfcmrvl_tx_complete()
168 struct nfcmrvl_usb_drv_data *drv_data = priv->drv_data; in nfcmrvl_usb_nci_open() local
171 err = usb_autopm_get_interface(drv_data->intf); in nfcmrvl_usb_nci_open()
175 drv_data->intf->needs_remote_wakeup = 1; in nfcmrvl_usb_nci_open()
177 err = nfcmrvl_submit_bulk_urb(drv_data, GFP_KERNEL); in nfcmrvl_usb_nci_open()
181 set_bit(NFCMRVL_USB_BULK_RUNNING, &drv_data->flags); in nfcmrvl_usb_nci_open()
182 nfcmrvl_submit_bulk_urb(drv_data, GFP_KERNEL); in nfcmrvl_usb_nci_open()
184 usb_autopm_put_interface(drv_data->intf); in nfcmrvl_usb_nci_open()
188 usb_autopm_put_interface(drv_data->intf); in nfcmrvl_usb_nci_open()
192 static void nfcmrvl_usb_stop_traffic(struct nfcmrvl_usb_drv_data *drv_data) in nfcmrvl_usb_stop_traffic() argument
194 usb_kill_anchored_urbs(&drv_data->bulk_anchor); in nfcmrvl_usb_stop_traffic()
199 struct nfcmrvl_usb_drv_data *drv_data = priv->drv_data; in nfcmrvl_usb_nci_close() local
202 cancel_work_sync(&drv_data->waker); in nfcmrvl_usb_nci_close()
204 clear_bit(NFCMRVL_USB_BULK_RUNNING, &drv_data->flags); in nfcmrvl_usb_nci_close()
206 nfcmrvl_usb_stop_traffic(drv_data); in nfcmrvl_usb_nci_close()
207 usb_kill_anchored_urbs(&drv_data->tx_anchor); in nfcmrvl_usb_nci_close()
208 err = usb_autopm_get_interface(drv_data->intf); in nfcmrvl_usb_nci_close()
212 drv_data->intf->needs_remote_wakeup = 0; in nfcmrvl_usb_nci_close()
213 usb_autopm_put_interface(drv_data->intf); in nfcmrvl_usb_nci_close()
216 usb_scuttle_anchored_urbs(&drv_data->deferred); in nfcmrvl_usb_nci_close()
223 struct nfcmrvl_usb_drv_data *drv_data = priv->drv_data; in nfcmrvl_usb_nci_send() local
228 if (!drv_data->bulk_tx_ep) in nfcmrvl_usb_nci_send()
235 pipe = usb_sndbulkpipe(drv_data->udev, in nfcmrvl_usb_nci_send()
236 drv_data->bulk_tx_ep->bEndpointAddress); in nfcmrvl_usb_nci_send()
238 usb_fill_bulk_urb(urb, drv_data->udev, pipe, skb->data, skb->len, in nfcmrvl_usb_nci_send()
241 err = nfcmrvl_inc_tx(drv_data); in nfcmrvl_usb_nci_send()
243 usb_anchor_urb(urb, &drv_data->deferred); in nfcmrvl_usb_nci_send()
244 schedule_work(&drv_data->waker); in nfcmrvl_usb_nci_send()
249 usb_anchor_urb(urb, &drv_data->tx_anchor); in nfcmrvl_usb_nci_send()
254 nfc_err(&drv_data->udev->dev, in nfcmrvl_usb_nci_send()
259 usb_mark_last_busy(drv_data->udev); in nfcmrvl_usb_nci_send()
275 struct nfcmrvl_usb_drv_data *drv_data = in nfcmrvl_waker() local
279 err = usb_autopm_get_interface(drv_data->intf); in nfcmrvl_waker()
283 usb_autopm_put_interface(drv_data->intf); in nfcmrvl_waker()
289 struct nfcmrvl_usb_drv_data *drv_data; in nfcmrvl_probe() local
301 drv_data = devm_kzalloc(&intf->dev, sizeof(*drv_data), GFP_KERNEL); in nfcmrvl_probe()
302 if (!drv_data) in nfcmrvl_probe()
310 if (!drv_data->bulk_tx_ep && in nfcmrvl_probe()
312 drv_data->bulk_tx_ep = ep_desc; in nfcmrvl_probe()
313 } else if (!drv_data->bulk_rx_ep && in nfcmrvl_probe()
315 drv_data->bulk_rx_ep = ep_desc; in nfcmrvl_probe()
319 if (!drv_data->bulk_tx_ep || !drv_data->bulk_rx_ep) in nfcmrvl_probe()
322 drv_data->udev = udev; in nfcmrvl_probe()
323 drv_data->intf = intf; in nfcmrvl_probe()
325 INIT_WORK(&drv_data->waker, nfcmrvl_waker); in nfcmrvl_probe()
326 spin_lock_init(&drv_data->txlock); in nfcmrvl_probe()
328 init_usb_anchor(&drv_data->tx_anchor); in nfcmrvl_probe()
329 init_usb_anchor(&drv_data->bulk_anchor); in nfcmrvl_probe()
330 init_usb_anchor(&drv_data->deferred); in nfcmrvl_probe()
332 priv = nfcmrvl_nci_register_dev(NFCMRVL_PHY_USB, drv_data, &usb_ops, in nfcmrvl_probe()
337 drv_data->priv = priv; in nfcmrvl_probe()
338 drv_data->priv->support_fw_dnld = false; in nfcmrvl_probe()
340 usb_set_intfdata(intf, drv_data); in nfcmrvl_probe()
347 struct nfcmrvl_usb_drv_data *drv_data = usb_get_intfdata(intf); in nfcmrvl_disconnect() local
349 if (!drv_data) in nfcmrvl_disconnect()
352 nfc_info(&drv_data->udev->dev, "intf %p\n", intf); in nfcmrvl_disconnect()
354 nfcmrvl_nci_unregister_dev(drv_data->priv); in nfcmrvl_disconnect()
356 usb_set_intfdata(drv_data->intf, NULL); in nfcmrvl_disconnect()
362 struct nfcmrvl_usb_drv_data *drv_data = usb_get_intfdata(intf); in nfcmrvl_suspend() local
364 nfc_info(&drv_data->udev->dev, "intf %p\n", intf); in nfcmrvl_suspend()
366 if (drv_data->suspend_count++) in nfcmrvl_suspend()
369 spin_lock_irq(&drv_data->txlock); in nfcmrvl_suspend()
370 if (!(PMSG_IS_AUTO(message) && drv_data->tx_in_flight)) { in nfcmrvl_suspend()
371 set_bit(NFCMRVL_USB_SUSPENDING, &drv_data->flags); in nfcmrvl_suspend()
372 spin_unlock_irq(&drv_data->txlock); in nfcmrvl_suspend()
374 spin_unlock_irq(&drv_data->txlock); in nfcmrvl_suspend()
375 drv_data->suspend_count--; in nfcmrvl_suspend()
379 nfcmrvl_usb_stop_traffic(drv_data); in nfcmrvl_suspend()
380 usb_kill_anchored_urbs(&drv_data->tx_anchor); in nfcmrvl_suspend()
385 static void nfcmrvl_play_deferred(struct nfcmrvl_usb_drv_data *drv_data) in nfcmrvl_play_deferred() argument
390 while ((urb = usb_get_from_anchor(&drv_data->deferred))) { in nfcmrvl_play_deferred()
391 usb_anchor_urb(urb, &drv_data->tx_anchor); in nfcmrvl_play_deferred()
401 drv_data->tx_in_flight++; in nfcmrvl_play_deferred()
406 while ((urb = usb_get_from_anchor(&drv_data->deferred))) { in nfcmrvl_play_deferred()
414 struct nfcmrvl_usb_drv_data *drv_data = usb_get_intfdata(intf); in nfcmrvl_resume() local
417 nfc_info(&drv_data->udev->dev, "intf %p\n", intf); in nfcmrvl_resume()
419 if (--drv_data->suspend_count) in nfcmrvl_resume()
422 if (!test_bit(NFCMRVL_NCI_RUNNING, &drv_data->flags)) in nfcmrvl_resume()
425 if (test_bit(NFCMRVL_USB_BULK_RUNNING, &drv_data->flags)) { in nfcmrvl_resume()
426 err = nfcmrvl_submit_bulk_urb(drv_data, GFP_NOIO); in nfcmrvl_resume()
428 clear_bit(NFCMRVL_USB_BULK_RUNNING, &drv_data->flags); in nfcmrvl_resume()
432 nfcmrvl_submit_bulk_urb(drv_data, GFP_NOIO); in nfcmrvl_resume()
435 spin_lock_irq(&drv_data->txlock); in nfcmrvl_resume()
436 nfcmrvl_play_deferred(drv_data); in nfcmrvl_resume()
437 clear_bit(NFCMRVL_USB_SUSPENDING, &drv_data->flags); in nfcmrvl_resume()
438 spin_unlock_irq(&drv_data->txlock); in nfcmrvl_resume()
443 usb_scuttle_anchored_urbs(&drv_data->deferred); in nfcmrvl_resume()
445 spin_lock_irq(&drv_data->txlock); in nfcmrvl_resume()
446 clear_bit(NFCMRVL_USB_SUSPENDING, &drv_data->flags); in nfcmrvl_resume()
447 spin_unlock_irq(&drv_data->txlock); in nfcmrvl_resume()