static void resp_avail_cb(struct urb *urb) { struct usb_device *udev; struct ctrl_pkt_list_elem *list_elem = NULL; struct rmnet_ctrl_dev *rx_dev, *dev = urb->context; void *cpkt; int ch_id, status = 0; size_t cpkt_size = 0; unsigned int iface_num; udev = interface_to_usbdev(dev->intf); iface_num = dev->intf->cur_altsetting->desc.bInterfaceNumber; usb_autopm_put_interface_async(dev->intf); switch (urb->status) { case 0: pr_debug("[RACB:%d]<\n", iface_num); /*success*/ break; /*do not resubmit*/ case -ESHUTDOWN: case -ENOENT: case -ECONNRESET: case -EPROTO: return; /*resubmit*/ case -EOVERFLOW: pr_err_ratelimited("%s: Babble error happened\n", __func__); default: pr_debug_ratelimited("%s: Non zero urb status = %d\n", __func__, urb->status); goto resubmit_int_urb; } dev_dbg(dev->devicep, "Read %d bytes for %s\n", urb->actual_length, dev->name); cpkt = urb->transfer_buffer; cpkt_size = urb->actual_length; if (!cpkt_size) { dev->zlp_cnt++; dev_dbg(dev->devicep, "%s: zero length pkt received\n", __func__); goto resubmit_int_urb; } list_elem = kmalloc(sizeof(struct ctrl_pkt_list_elem), GFP_ATOMIC); if (!list_elem) { dev_err(dev->devicep, "%s: list_elem alloc failed\n", __func__); return; } list_elem->cpkt.data = kmalloc(cpkt_size, GFP_ATOMIC); if (!list_elem->cpkt.data) { dev_err(dev->devicep, "%s: list_elem->data alloc failed\n", __func__); kfree(list_elem); return; } memcpy(list_elem->cpkt.data, cpkt, cpkt_size); list_elem->cpkt.data_size = cpkt_size; rx_dev = dev; if (test_bit(RMNET_CTRL_DEV_MUX_EN, &dev->status)) { ch_id = rmnet_usb_ctrl_dmux(list_elem); if (ch_id < 0) { kfree(list_elem->cpkt.data); kfree(list_elem); goto resubmit_int_urb; } rx_dev = &ctrl_devs[dev->id][ch_id]; } rx_dev->get_encap_resp_cnt++; spin_lock(&rx_dev->rx_lock); list_add_tail(&list_elem->list, &rx_dev->rx_list); spin_unlock(&rx_dev->rx_lock); wake_up(&rx_dev->read_wait_queue); resubmit_int_urb: /*check if it is already submitted in resume*/ if (!dev->inturb->anchor) { usb_mark_last_busy(udev); usb_anchor_urb(dev->inturb, &dev->rx_submitted); status = usb_submit_urb(dev->inturb, GFP_ATOMIC); if (status) { usb_unanchor_urb(dev->inturb); if (status != -ENODEV) dev_err(dev->devicep, "%s: Error re-submitting Int URB %d\n", __func__, status); } pr_debug("[CHKRA:%d]>\n", iface_num); } }
static void resp_avail_cb(struct urb *urb) { struct usb_device *udev; struct ctrl_pkt_list_elem *list_elem = NULL; struct rmnet_ctrl_udev *dev = urb->context; struct rmnet_ctrl_dev *rx_dev; void *cpkt; int status = 0; int ch_id = -EINVAL; size_t cpkt_size = 0; /*usb device disconnect*/ if (urb->dev->state == USB_STATE_NOTATTACHED) return; udev = interface_to_usbdev(dev->intf); #ifdef CONFIG_QCT_9K_MODEM if (get_radio_flag() & RADIO_FLAG_MORE_LOG) pr_info("[RMNET] rcb\n"); #endif usb_autopm_put_interface_async(dev->intf); switch (urb->status) { case 0: /*success*/ break; /*do not resubmit*/ case -ESHUTDOWN: case -ENOENT: case -ECONNRESET: case -EPROTO: return; /*resubmit*/ case -EOVERFLOW: pr_err_ratelimited("%s: Babble error happened\n", __func__); default: pr_debug_ratelimited("%s: Non zero urb status = %d\n", __func__, urb->status); goto resubmit_int_urb; } #ifdef CONFIG_QCT_9K_MODEM if (get_radio_flag() & RADIO_FLAG_MORE_LOG) pr_info("[RMNET] rcb: %i\n", urb->actual_length); #endif cpkt = urb->transfer_buffer; cpkt_size = urb->actual_length; if (!cpkt_size) { dev->zlp_cnt++; dev_dbg(&dev->intf->dev, "%s: zero length pkt received\n", __func__); goto resubmit_int_urb; } list_elem = kmalloc(sizeof(struct ctrl_pkt_list_elem), GFP_ATOMIC); if (!list_elem) { dev_err(&dev->intf->dev, "%s: list_elem alloc failed\n", __func__); return; } list_elem->cpkt.data = kmalloc(cpkt_size, GFP_ATOMIC); if (!list_elem->cpkt.data) { dev_err(&dev->intf->dev, "%s: list_elem->data alloc failed\n", __func__); kfree(list_elem); return; } memcpy(list_elem->cpkt.data, cpkt, cpkt_size); list_elem->cpkt.data_size = cpkt_size; #ifdef CONFIG_QCT_9K_MODEM if (get_radio_flag() & RADIO_FLAG_MORE_LOG) pr_info("[RMNET] wake_up\n"); #endif ch_id = dev->ctrldev_id; if (test_bit(RMNET_CTRL_DEV_MUX_EN, &dev->status)) { ch_id = rmnet_usb_ctrl_dmux(list_elem); if (ch_id < 0) { dev->invalid_mux_id_cnt++; kfree(list_elem->cpkt.data); kfree(list_elem); goto resubmit_int_urb; } } rx_dev = &ctrl_devs[dev->rdev_num][ch_id]; dev->get_encap_resp_cnt++; dev_dbg(&dev->intf->dev, "Read %d bytes for %s\n", urb->actual_length, rx_dev->name); spin_lock(&rx_dev->rx_lock); list_add_tail(&list_elem->list, &rx_dev->rx_list); spin_unlock(&rx_dev->rx_lock); wake_up(&rx_dev->read_wait_queue); resubmit_int_urb: /*check if it is already submitted in resume*/ if (!dev->inturb->anchor) { usb_mark_last_busy(udev); usb_anchor_urb(dev->inturb, &dev->rx_submitted); status = usb_submit_urb(dev->inturb, GFP_ATOMIC); if (status) { usb_unanchor_urb(dev->inturb); if (status != -ENODEV) pr_err("%s: Error re-submitting Int URB %d\n", __func__, status); } } }