diff options
author | Jingoo Han <jg1.han@samsung.com> | 2013-12-16 01:13:31 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-12-17 14:17:42 -0500 |
commit | 40a8fb2a671319c589baa9995e7b6f3b8c72c30c (patch) | |
tree | 25849790be055c795d957c4d31ef98fcfc7b43b1 /drivers/usb/gadget/atmel_usba_udc.c | |
parent | 45ab460975c5433d1bd81b211fe643732abaae19 (diff) |
usb: gadget: atmel_usba: Use devm_*() functions
Use devm_*() functions to make cleanup paths simpler.
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/atmel_usba_udc.c')
-rw-r--r-- | drivers/usb/gadget/atmel_usba_udc.c | 64 |
1 files changed, 17 insertions, 47 deletions
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index 68cf3a40f98e..bb1eb4220785 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c | |||
@@ -1996,14 +1996,12 @@ static int __init usba_udc_probe(struct platform_device *pdev) | |||
1996 | if (irq < 0) | 1996 | if (irq < 0) |
1997 | return irq; | 1997 | return irq; |
1998 | 1998 | ||
1999 | pclk = clk_get(&pdev->dev, "pclk"); | 1999 | pclk = devm_clk_get(&pdev->dev, "pclk"); |
2000 | if (IS_ERR(pclk)) | 2000 | if (IS_ERR(pclk)) |
2001 | return PTR_ERR(pclk); | 2001 | return PTR_ERR(pclk); |
2002 | hclk = clk_get(&pdev->dev, "hclk"); | 2002 | hclk = devm_clk_get(&pdev->dev, "hclk"); |
2003 | if (IS_ERR(hclk)) { | 2003 | if (IS_ERR(hclk)) |
2004 | ret = PTR_ERR(hclk); | 2004 | return PTR_ERR(hclk); |
2005 | goto err_get_hclk; | ||
2006 | } | ||
2007 | 2005 | ||
2008 | spin_lock_init(&udc->lock); | 2006 | spin_lock_init(&udc->lock); |
2009 | udc->pdev = pdev; | 2007 | udc->pdev = pdev; |
@@ -2012,17 +2010,17 @@ static int __init usba_udc_probe(struct platform_device *pdev) | |||
2012 | udc->vbus_pin = -ENODEV; | 2010 | udc->vbus_pin = -ENODEV; |
2013 | 2011 | ||
2014 | ret = -ENOMEM; | 2012 | ret = -ENOMEM; |
2015 | udc->regs = ioremap(regs->start, resource_size(regs)); | 2013 | udc->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs)); |
2016 | if (!udc->regs) { | 2014 | if (!udc->regs) { |
2017 | dev_err(&pdev->dev, "Unable to map I/O memory, aborting.\n"); | 2015 | dev_err(&pdev->dev, "Unable to map I/O memory, aborting.\n"); |
2018 | goto err_map_regs; | 2016 | return ret; |
2019 | } | 2017 | } |
2020 | dev_info(&pdev->dev, "MMIO registers at 0x%08lx mapped at %p\n", | 2018 | dev_info(&pdev->dev, "MMIO registers at 0x%08lx mapped at %p\n", |
2021 | (unsigned long)regs->start, udc->regs); | 2019 | (unsigned long)regs->start, udc->regs); |
2022 | udc->fifo = ioremap(fifo->start, resource_size(fifo)); | 2020 | udc->fifo = devm_ioremap(&pdev->dev, fifo->start, resource_size(fifo)); |
2023 | if (!udc->fifo) { | 2021 | if (!udc->fifo) { |
2024 | dev_err(&pdev->dev, "Unable to map FIFO, aborting.\n"); | 2022 | dev_err(&pdev->dev, "Unable to map FIFO, aborting.\n"); |
2025 | goto err_map_fifo; | 2023 | return ret; |
2026 | } | 2024 | } |
2027 | dev_info(&pdev->dev, "FIFO at 0x%08lx mapped at %p\n", | 2025 | dev_info(&pdev->dev, "FIFO at 0x%08lx mapped at %p\n", |
2028 | (unsigned long)fifo->start, udc->fifo); | 2026 | (unsigned long)fifo->start, udc->fifo); |
@@ -2033,7 +2031,7 @@ static int __init usba_udc_probe(struct platform_device *pdev) | |||
2033 | ret = clk_prepare_enable(pclk); | 2031 | ret = clk_prepare_enable(pclk); |
2034 | if (ret) { | 2032 | if (ret) { |
2035 | dev_err(&pdev->dev, "Unable to enable pclk, aborting.\n"); | 2033 | dev_err(&pdev->dev, "Unable to enable pclk, aborting.\n"); |
2036 | goto err_clk_enable; | 2034 | return ret; |
2037 | } | 2035 | } |
2038 | toggle_bias(0); | 2036 | toggle_bias(0); |
2039 | usba_writel(udc, CTRL, USBA_DISABLE_MASK); | 2037 | usba_writel(udc, CTRL, USBA_DISABLE_MASK); |
@@ -2044,22 +2042,22 @@ static int __init usba_udc_probe(struct platform_device *pdev) | |||
2044 | else | 2042 | else |
2045 | udc->usba_ep = usba_udc_pdata(pdev, udc); | 2043 | udc->usba_ep = usba_udc_pdata(pdev, udc); |
2046 | 2044 | ||
2047 | if (IS_ERR(udc->usba_ep)) { | 2045 | if (IS_ERR(udc->usba_ep)) |
2048 | ret = PTR_ERR(udc->usba_ep); | 2046 | return PTR_ERR(udc->usba_ep); |
2049 | goto err_alloc_ep; | ||
2050 | } | ||
2051 | 2047 | ||
2052 | ret = request_irq(irq, usba_udc_irq, 0, "atmel_usba_udc", udc); | 2048 | ret = devm_request_irq(&pdev->dev, irq, usba_udc_irq, 0, |
2049 | "atmel_usba_udc", udc); | ||
2053 | if (ret) { | 2050 | if (ret) { |
2054 | dev_err(&pdev->dev, "Cannot request irq %d (error %d)\n", | 2051 | dev_err(&pdev->dev, "Cannot request irq %d (error %d)\n", |
2055 | irq, ret); | 2052 | irq, ret); |
2056 | goto err_request_irq; | 2053 | return ret; |
2057 | } | 2054 | } |
2058 | udc->irq = irq; | 2055 | udc->irq = irq; |
2059 | 2056 | ||
2060 | if (gpio_is_valid(udc->vbus_pin)) { | 2057 | if (gpio_is_valid(udc->vbus_pin)) { |
2061 | if (!devm_gpio_request(&pdev->dev, udc->vbus_pin, "atmel_usba_udc")) { | 2058 | if (!devm_gpio_request(&pdev->dev, udc->vbus_pin, "atmel_usba_udc")) { |
2062 | ret = request_irq(gpio_to_irq(udc->vbus_pin), | 2059 | ret = devm_request_irq(&pdev->dev, |
2060 | gpio_to_irq(udc->vbus_pin), | ||
2063 | usba_vbus_irq, 0, | 2061 | usba_vbus_irq, 0, |
2064 | "atmel_usba_udc", udc); | 2062 | "atmel_usba_udc", udc); |
2065 | if (ret) { | 2063 | if (ret) { |
@@ -2078,31 +2076,13 @@ static int __init usba_udc_probe(struct platform_device *pdev) | |||
2078 | 2076 | ||
2079 | ret = usb_add_gadget_udc(&pdev->dev, &udc->gadget); | 2077 | ret = usb_add_gadget_udc(&pdev->dev, &udc->gadget); |
2080 | if (ret) | 2078 | if (ret) |
2081 | goto err_add_udc; | 2079 | return ret; |
2082 | 2080 | ||
2083 | usba_init_debugfs(udc); | 2081 | usba_init_debugfs(udc); |
2084 | for (i = 1; i < udc->num_ep; i++) | 2082 | for (i = 1; i < udc->num_ep; i++) |
2085 | usba_ep_init_debugfs(udc, &udc->usba_ep[i]); | 2083 | usba_ep_init_debugfs(udc, &udc->usba_ep[i]); |
2086 | 2084 | ||
2087 | return 0; | 2085 | return 0; |
2088 | |||
2089 | err_add_udc: | ||
2090 | if (gpio_is_valid(udc->vbus_pin)) | ||
2091 | free_irq(gpio_to_irq(udc->vbus_pin), udc); | ||
2092 | |||
2093 | free_irq(irq, udc); | ||
2094 | err_request_irq: | ||
2095 | err_alloc_ep: | ||
2096 | err_clk_enable: | ||
2097 | iounmap(udc->fifo); | ||
2098 | err_map_fifo: | ||
2099 | iounmap(udc->regs); | ||
2100 | err_map_regs: | ||
2101 | clk_put(hclk); | ||
2102 | err_get_hclk: | ||
2103 | clk_put(pclk); | ||
2104 | |||
2105 | return ret; | ||
2106 | } | 2086 | } |
2107 | 2087 | ||
2108 | static int __exit usba_udc_remove(struct platform_device *pdev) | 2088 | static int __exit usba_udc_remove(struct platform_device *pdev) |
@@ -2118,16 +2098,6 @@ static int __exit usba_udc_remove(struct platform_device *pdev) | |||
2118 | usba_ep_cleanup_debugfs(&udc->usba_ep[i]); | 2098 | usba_ep_cleanup_debugfs(&udc->usba_ep[i]); |
2119 | usba_cleanup_debugfs(udc); | 2099 | usba_cleanup_debugfs(udc); |
2120 | 2100 | ||
2121 | if (gpio_is_valid(udc->vbus_pin)) { | ||
2122 | free_irq(gpio_to_irq(udc->vbus_pin), udc); | ||
2123 | } | ||
2124 | |||
2125 | free_irq(udc->irq, udc); | ||
2126 | iounmap(udc->fifo); | ||
2127 | iounmap(udc->regs); | ||
2128 | clk_put(udc->hclk); | ||
2129 | clk_put(udc->pclk); | ||
2130 | |||
2131 | return 0; | 2101 | return 0; |
2132 | } | 2102 | } |
2133 | 2103 | ||