int i, retval = 0;
unsigned char zlt, ios = 0, mult = 0;
+ if (!_ep || !desc)
+ return -EINVAL;
+
ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev;
dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
- if (!_ep || !desc || ep->desc
- || desc->bDescriptorType != USB_DT_ENDPOINT)
+ if (ep->desc || desc->bDescriptorType != USB_DT_ENDPOINT)
return -EINVAL;
if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)
int ep_num;
u32 endptctrl;
+ if (!_ep)
+ return -EINVAL;
+
ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev;
dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
- if (!_ep || !ep->desc)
+ if (!ep->desc)
return -EINVAL;
- pm_runtime_get(&dev->pdev->dev);
-
spin_lock_irqsave(&dev->lock, flags);
if (!ep->desc) {
spin_unlock_irqrestore(&dev->lock, flags);
- pm_runtime_put(&dev->pdev->dev);
dev_err(&dev->pdev->dev, "ep has already disabled\n");
return -EINVAL;
}
spin_unlock_irqrestore(&dev->lock, flags);
- pm_runtime_put(&dev->pdev->dev);
-
dev_dbg(&dev->pdev->dev, "disabled %s\n", _ep->name);
dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
struct langwell_udc *dev;
struct langwell_request *req = NULL;
+ if (!_ep || !_req)
+ return;
+
ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev;
dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
- if (!_ep || !_req)
- return;
-
req = container_of(_req, struct langwell_request, req);
WARN_ON(!list_empty(&req->queue));
unsigned long flags;
int is_iso = 0, zlflag = 0, in = 0;
+ if (unlikely(!_ep || !_req))
+ return -EINVAL;
/* always require a cpu-view buffer */
req = container_of(_req, struct langwell_request, req);
ep = container_of(_ep, struct langwell_ep, ep);
- if (!_req || !_req->complete || !_req->buf
+ if (!_req->complete || !_req->buf
|| !list_empty(&req->queue)) {
return -EINVAL;
}
- if (unlikely(!_ep || !ep->desc))
- return -EINVAL;
-
dev = ep->dev;
req->ep = ep;
dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
int stopped, ep_num, retval = 0;
u32 endptctrl;
+ if (!_ep || !_req)
+ return -EINVAL;
+
ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev;
dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
- if (!_ep || !ep->desc || !_req)
+ if (!ep->desc)
return -EINVAL;
if (!dev->driver)
return -ESHUTDOWN;
- pm_runtime_get_sync(&dev->pdev->dev);
-
spin_lock_irqsave(&dev->lock, flags);
stopped = ep->stopped;
ep->stopped = stopped;
spin_unlock_irqrestore(&dev->lock, flags);
- pm_runtime_put_sync(&dev->pdev->dev);
-
dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return retval;
}
unsigned long flags;
int retval = 0;
+ if (!_ep)
+ return -EINVAL;
+
ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev;
-
dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
-
if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)
return -ESHUTDOWN;
-
spin_lock_irqsave(&dev->lock, flags);
- if (!_ep || !ep->desc) {
+ if (!ep->desc) {
retval = -EINVAL;
goto done;
}
struct langwell_ep *ep;
struct langwell_udc *dev;
+ if (!_ep)
+ return -EINVAL;
+
ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev;
-
dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
- if (!_ep || !ep->desc)
+ if (!ep->desc)
return -EINVAL;
dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
u32 flush_bit;
unsigned long timeout;
+ if (!_ep)
+ return;
+
ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev;
dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
- if (!_ep || !ep->desc) {
- dev_vdbg(&dev->pdev->dev, "ep or ep->desc is NULL\n");
+ if (!ep->desc) {
+ dev_vdbg(&dev->pdev->dev, "ep->desc is NULL\n");
dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return;
}
return -ENOTSUPP;
}
- pm_runtime_get_sync(&dev->pdev->dev);
-
spin_lock_irqsave(&dev->lock, flags);
portsc1 = readl(&dev->op_regs->portsc1);
if (!(portsc1 & PORTS_SUSP)) {
spin_unlock_irqrestore(&dev->lock, flags);
- pm_runtime_put(&dev->pdev->dev);
return 0;
}
else
dev_info(&dev->pdev->dev, "device remote wakeup\n");
- /* exit PHY low power suspend */
- langwell_phy_low_power(dev, 0);
-
/* force port resume */
portsc1 |= PORTS_FPR;
writel(portsc1, &dev->op_regs->portsc1);
spin_unlock_irqrestore(&dev->lock, flags);
- pm_runtime_put(&dev->pdev->dev);
dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0;
return -ENODEV;
}
- pm_runtime_get_sync(&dev->pdev->dev);
- /* PHY should exit low power before set USBCMD Run/Stop */
- langwell_phy_low_power(dev, 0);
-
spin_lock_irqsave(&dev->lock, flags);
dev->softconnected = (is_on != 0);
}
spin_unlock_irqrestore(&dev->lock, flags);
- pm_runtime_put(&dev->pdev->dev);
-
dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0;
}
dev->usb_state = dev->resume_state;
dev->resume_state = 0;
- /* exit PHY low power suspend */
- langwell_phy_low_power(dev, 0);
-
langwell_udc_notify_otg(MID_OTG_NOTIFY_CRESUME);
/* report resume to the driver */
return 0;
}
-#ifdef CONFIG_PM_RUNTIME
-/* device controller runtime suspend */
-static int langwell_udc_runtime_suspend(struct device *device)
-{
- struct langwell_udc *dev = the_controller;
- struct pci_dev *pdev;
-
- dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
-
- pdev = to_pci_dev(device);
-
- /* save PCI state */
- pci_save_state(pdev);
-
- /* disable PCI device */
- pci_disable_device(pdev);
-
- /* set device power state */
- pci_set_power_state(pdev, PCI_D3hot);
-
- dev->vbus_active = 0;
-
- dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
- return 0;
-}
-
-
-/* device controller runtime resume */
-static int langwell_udc_runtime_resume(struct device *device)
-{
- struct langwell_udc *dev = the_controller;
- struct pci_dev *pdev;
-
- dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
-
- pdev = to_pci_dev(device);
-
- /* set device D0 power state */
- pci_set_power_state(pdev, PCI_D0);
-
- /* restore PCI state */
- pci_restore_state(pdev);
-
- /* enable PCI device */
- if (pci_enable_device(pdev) < 0)
- return -ENODEV;
-
- dev->vbus_active = 1;
-
- dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
- return 0;
-}
-
-#else
-
-#define langwell_udc_runtime_suspend NULL
-#define langwell_udc_runtime_resume NULL
-
-#endif
/* pci driver shutdown */
MODULE_DEVICE_TABLE(pci, pci_ids);
-static const struct dev_pm_ops langwell_udc_pm_ops = {
- .runtime_suspend = langwell_udc_runtime_suspend,
- .runtime_resume = langwell_udc_runtime_resume,
-};
static struct pci_driver langwell_pci_driver = {
- .driver = {
- .pm = &langwell_udc_pm_ops,
- },
.name = (char *) driver_name,
.id_table = pci_ids,
dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
wake_lock(&dev->wake_lock);
- pm_runtime_get(&dev->pdev->dev);
+ pm_runtime_get_sync(&dev->pdev->dev);
/* exit PHY low power suspend */
langwell_phy_low_power(dev, 0);