Use the generic platform add function. There are some tiny differences: - open code clk enable/disable instead of star/stop named functions - drop the BUG on in_interrupt() check in platform remove - since the clock is always added drop the null pointere check in spear_ehci_hcd_drv_remove() Signed-off-by: Sebastian Andrzej Siewior <sebastian@xxxxxxxxxxxxx> --- drivers/usb/host/ehci-spear.c | 90 ++++++----------------------------------- 1 files changed, 13 insertions(+), 77 deletions(-) diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c index dbf1e4e..c3a2d06 100644 --- a/drivers/usb/host/ehci-spear.c +++ b/drivers/usb/host/ehci-spear.c @@ -21,16 +21,6 @@ struct spear_ehci { #define to_spear_ehci(hcd) (struct spear_ehci *)hcd_to_ehci(hcd) -static void spear_start_ehci(struct spear_ehci *ehci) -{ - clk_enable(ehci->clk); -} - -static void spear_stop_ehci(struct spear_ehci *ehci) -{ - clk_disable(ehci->clk); -} - static int ehci_spear_setup(struct usb_hcd *hcd) { struct ehci_hcd *ehci = hcd_to_ehci(hcd); @@ -104,98 +94,44 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) if (pdata == NULL) return -EFAULT; - if (usb_disabled()) - return -ENODEV; - - irq = platform_get_irq(pdev, 0); - if (irq < 0) { - retval = irq; - goto fail_irq_get; - } - if (*pdata >= 0) sprintf(clk_name, "usbh.%01d_clk", *pdata); usbh_clk = clk_get(NULL, clk_name); if (IS_ERR(usbh_clk)) { dev_err(&pdev->dev, "Error getting interface clock\n"); - retval = PTR_ERR(usbh_clk); - goto fail_get_usbh_clk; - } - - hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); - if (!hcd) { - retval = -ENOMEM; - goto fail_create_hcd; + return PTR_ERR(usbh_clk); } + clk_enable(usbh_clk); - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - retval = -ENODEV; - goto fail_request_resource; - } - - hcd->rsrc_start = res->start; - hcd->rsrc_len = resource_size(res); - if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, - driver->description)) { - retval = -EBUSY; - goto fail_request_resource; - } - - hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); - if (hcd->regs == NULL) { - dev_dbg(&pdev->dev, "error mapping memory\n"); - retval = -ENOMEM; - goto fail_ioremap; + hcd = ehci_hcd_plat_add(pdev, driver); + if (IS_ERR(hcd)) { + retval = PTR_ERR(hcd); + goto err_add_hcd; } ehci = (struct spear_ehci *)hcd_to_ehci(hcd); ehci->clk = usbh_clk; - spear_start_ehci(ehci); - retval = usb_add_hcd(hcd, irq, IRQF_SHARED | IRQF_DISABLED); - if (retval) - goto fail_add_hcd; - return retval; -fail_add_hcd: - spear_stop_ehci(ehci); - iounmap(hcd->regs); -fail_ioremap: - release_mem_region(hcd->rsrc_start, hcd->rsrc_len); -fail_request_resource: - usb_put_hcd(hcd); -fail_create_hcd: +err_add_hcd: + clk_disable(usbh_clk); clk_put(usbh_clk); -fail_get_usbh_clk: -fail_irq_get: dev_err(&pdev->dev, "init fail, %d\n", retval); - - return retval ; + return retval; } static int spear_ehci_hcd_drv_remove(struct platform_device *pdev) { struct usb_hcd *hcd = platform_get_drvdata(pdev); struct spear_ehci *ehci_p = to_spear_ehci(hcd); + struct clk *usbh_clk = ehci_p->clk; - if (!hcd) - return 0; - if (in_interrupt()) - BUG(); - usb_remove_hcd(hcd); - - if (ehci_p->clk) - spear_stop_ehci(ehci_p); - iounmap(hcd->regs); - release_mem_region(hcd->rsrc_start, hcd->rsrc_len); - usb_put_hcd(hcd); - - if (ehci_p->clk) - clk_put(ehci_p->clk); + ehci_hcd_plat_cleanup(pdev, hcd); + clk_disable(usbh_clk); + clk_put(usbh_clk); return 0; } -- 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html