diff options
author | Himangi Saraogi <himangi774@gmail.com> | 2014-07-01 16:34:44 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-07-09 19:31:48 -0400 |
commit | 0e278b3408999d5bdce50bd0d7f97608483eebea (patch) | |
tree | 0c95116135239abc5a26092f74e10ed0c7c0cd2d /drivers/usb/host/fotg210-hcd.c | |
parent | 96ae571338a4b2ecd2e42a6881bb0daa1a4e7d4f (diff) |
fotg210: Use managed interfaces for allocation of resources
This patch intoduces the use of devm_ioremap_resource instead of
request_mem_region and ioremap_nocache and removes the calls to free the
allocated memory. Some labels are removes and a new label failed
introduced to make it less specific to the context. The call to a
platform get resource with IORESOURCE_IO is removed as it allocates
memory that is not needed.
Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host/fotg210-hcd.c')
-rw-r--r-- | drivers/usb/host/fotg210-hcd.c | 48 |
1 files changed, 9 insertions, 39 deletions
diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c index 98a89d16cc3e..adcd2050dced 100644 --- a/drivers/usb/host/fotg210-hcd.c +++ b/drivers/usb/host/fotg210-hcd.c | |||
@@ -5838,41 +5838,17 @@ static int fotg210_hcd_probe(struct platform_device *pdev) | |||
5838 | goto fail_create_hcd; | 5838 | goto fail_create_hcd; |
5839 | } | 5839 | } |
5840 | 5840 | ||
5841 | hcd->has_tt = 1; | ||
5842 | |||
5841 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 5843 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
5842 | if (!res) { | 5844 | hcd->regs = devm_ioremap_resource(&pdev->dev, res); |
5843 | dev_err(dev, | 5845 | if (IS_ERR(hcd->regs)) { |
5844 | "Found HC with no register addr. Check %s setup!\n", | 5846 | retval = PTR_ERR(hcd->regs); |
5845 | dev_name(dev)); | 5847 | goto failed; |
5846 | retval = -ENODEV; | ||
5847 | goto fail_request_resource; | ||
5848 | } | 5848 | } |
5849 | 5849 | ||
5850 | hcd->rsrc_start = res->start; | 5850 | hcd->rsrc_start = res->start; |
5851 | hcd->rsrc_len = resource_size(res); | 5851 | hcd->rsrc_len = resource_size(res); |
5852 | hcd->has_tt = 1; | ||
5853 | |||
5854 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, | ||
5855 | fotg210_fotg210_hc_driver.description)) { | ||
5856 | dev_dbg(dev, "controller already in use\n"); | ||
5857 | retval = -EBUSY; | ||
5858 | goto fail_request_resource; | ||
5859 | } | ||
5860 | |||
5861 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | ||
5862 | if (!res) { | ||
5863 | dev_err(dev, | ||
5864 | "Found HC with no register addr. Check %s setup!\n", | ||
5865 | dev_name(dev)); | ||
5866 | retval = -ENODEV; | ||
5867 | goto fail_request_resource; | ||
5868 | } | ||
5869 | |||
5870 | hcd->regs = ioremap_nocache(res->start, resource_size(res)); | ||
5871 | if (hcd->regs == NULL) { | ||
5872 | dev_dbg(dev, "error mapping memory\n"); | ||
5873 | retval = -EFAULT; | ||
5874 | goto fail_ioremap; | ||
5875 | } | ||
5876 | 5852 | ||
5877 | fotg210 = hcd_to_fotg210(hcd); | 5853 | fotg210 = hcd_to_fotg210(hcd); |
5878 | 5854 | ||
@@ -5880,24 +5856,20 @@ static int fotg210_hcd_probe(struct platform_device *pdev) | |||
5880 | 5856 | ||
5881 | retval = fotg210_setup(hcd); | 5857 | retval = fotg210_setup(hcd); |
5882 | if (retval) | 5858 | if (retval) |
5883 | goto fail_add_hcd; | 5859 | goto failed; |
5884 | 5860 | ||
5885 | fotg210_init(fotg210); | 5861 | fotg210_init(fotg210); |
5886 | 5862 | ||
5887 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); | 5863 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); |
5888 | if (retval) { | 5864 | if (retval) { |
5889 | dev_err(dev, "failed to add hcd with err %d\n", retval); | 5865 | dev_err(dev, "failed to add hcd with err %d\n", retval); |
5890 | goto fail_add_hcd; | 5866 | goto failed; |
5891 | } | 5867 | } |
5892 | device_wakeup_enable(hcd->self.controller); | 5868 | device_wakeup_enable(hcd->self.controller); |
5893 | 5869 | ||
5894 | return retval; | 5870 | return retval; |
5895 | 5871 | ||
5896 | fail_add_hcd: | 5872 | failed: |
5897 | iounmap(hcd->regs); | ||
5898 | fail_ioremap: | ||
5899 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
5900 | fail_request_resource: | ||
5901 | usb_put_hcd(hcd); | 5873 | usb_put_hcd(hcd); |
5902 | fail_create_hcd: | 5874 | fail_create_hcd: |
5903 | dev_err(dev, "init %s fail, %d\n", dev_name(dev), retval); | 5875 | dev_err(dev, "init %s fail, %d\n", dev_name(dev), retval); |
@@ -5918,8 +5890,6 @@ static int fotg210_hcd_remove(struct platform_device *pdev) | |||
5918 | return 0; | 5890 | return 0; |
5919 | 5891 | ||
5920 | usb_remove_hcd(hcd); | 5892 | usb_remove_hcd(hcd); |
5921 | iounmap(hcd->regs); | ||
5922 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
5923 | usb_put_hcd(hcd); | 5893 | usb_put_hcd(hcd); |
5924 | 5894 | ||
5925 | return 0; | 5895 | return 0; |