static int ohci_hcd_s5pv210_drv_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct usb_hcd *hcd = platform_get_drvdata(pdev); struct ohci_hcd *ohci = hcd_to_ohci(hcd); unsigned long flags; int rc = 0; /* Root hub was already suspended. Disable irq emission and * mark HW unaccessible, bail out if RH has been resumed. Use * the spinlock to properly synchronize with possible pending * RH suspend or resume activity. * * This is still racy as hcd->state is manipulated outside of * any locks =P But that will be a different fix. */ spin_lock_irqsave(&ohci->lock, flags); if (hcd->state != HC_STATE_SUSPENDED) { rc = -EINVAL; goto bail; } clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); s5pv210_stop_ohc(); bail: spin_unlock_irqrestore(&ohci->lock, flags); return rc; }
static int ohci_hcd_s5pv210_drv_probe(struct platform_device *pdev) { struct usb_hcd *hcd = NULL; int retval = 0; if (usb_disabled()) return -ENODEV; if (pdev->resource[1].flags != IORESOURCE_IRQ) { dev_err(&pdev->dev, "resource[1] is not IORESOURCE_IRQ.\n"); return -ENODEV; } hcd = usb_create_hcd(&ohci_s5pv210_hc_driver, &pdev->dev, "s5pv210"); if (!hcd) { dev_err(&pdev->dev, "usb_create_hcd failed!\n"); return -ENODEV; } hcd->rsrc_start = pdev->resource[0].start; hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { dev_err(&pdev->dev, "request_mem_region failed!\n"); retval = -EBUSY; goto err1; } s5pv210_start_ohc(); hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); if (!hcd->regs) { dev_err(&pdev->dev, "ioremap failed!\n"); retval = -ENOMEM; goto err2; } ohci_hcd_init(hcd_to_ohci(hcd)); retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_DISABLED | IRQF_SHARED); if (retval == 0) { platform_set_drvdata(pdev, hcd); #ifdef CONFIG_USB_SUSPEND pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); #endif return retval; } s5pv210_stop_ohc(); iounmap(hcd->regs); err2: release_mem_region(hcd->rsrc_start, hcd->rsrc_len); err1: usb_put_hcd(hcd); return retval; }
static int ohci_hcd_s5pv210_drv_remove(struct platform_device *pdev) { struct usb_hcd *hcd = platform_get_drvdata(pdev); usb_remove_hcd(hcd); iounmap(hcd->regs); release_mem_region(hcd->rsrc_start, hcd->rsrc_len); usb_put_hcd(hcd); s5pv210_stop_ohc(); platform_set_drvdata(pdev, NULL); return 0; }
static int ohci_hcd_s5pv210_drv_probe(struct platform_device *pdev) { struct usb_hcd *hcd = NULL; int retval = 0; if (usb_disabled()) { return -ENODEV; } if (pdev->resource[1].flags != IORESOURCE_IRQ) { dev_err(&pdev->dev,"resource[1] is not IORESOURCE_IRQ.\n"); return -ENODEV; } hcd = usb_create_hcd(&ohci_s5pv210_hc_driver, &pdev->dev, "s5pv210"); if (!hcd) { dev_err(&pdev->dev,"usb_create_hcd failed!\n"); return -ENODEV; } hcd->rsrc_start = pdev->resource[0].start; hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; if(!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { dev_err(&pdev->dev,"request_mem_region failed!\n"); retval = -EBUSY; goto err1; } usb_clk = clk_get(&pdev->dev, "usb-host"); if (IS_ERR(usb_clk)) { dev_err(&pdev->dev, "cannot get usb-host clock\n"); retval = -ENODEV; goto err2; } s5pv210_start_ohc(); hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); if (!hcd->regs) { dev_err(&pdev->dev,"ioremap failed!\n"); retval = -ENOMEM; goto err2; } ohci_hcd_init(hcd_to_ohci(hcd)); retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_DISABLED | IRQF_SHARED); if (retval == 0) { platform_set_drvdata(pdev, hcd); return retval; } s5pv210_stop_ohc(); iounmap(hcd->regs); err2: release_mem_region(hcd->rsrc_start, hcd->rsrc_len); err1: clk_put(usb_clk); usb_put_hcd(hcd); return retval; }