diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2012-11-08 10:07:59 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-11-14 15:15:20 -0500 |
commit | 98515e5923b1c8f982511eeec9d27014b05efebf (patch) | |
tree | 8d060a8abbb31702660861d0665bf9627ff16316 /drivers/usb/host/ehci-spear.c | |
parent | d8fd7d5ae3e0561920b38647793b1947e07c7acf (diff) |
usb: spear-ehci/ohci: Use devm_*() routines
This patch frees SPEAr ehci/ohci drivers from tension of freeing resources :)
devm_* derivatives of multiple routines are used while allocating resources,
which would be freed automatically by kernel.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host/ehci-spear.c')
-rw-r--r-- | drivers/usb/host/ehci-spear.c | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c index d08506af41ce..3fadff8f8d30 100644 --- a/drivers/usb/host/ehci-spear.c +++ b/drivers/usb/host/ehci-spear.c | |||
@@ -116,7 +116,7 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) | |||
116 | irq = platform_get_irq(pdev, 0); | 116 | irq = platform_get_irq(pdev, 0); |
117 | if (irq < 0) { | 117 | if (irq < 0) { |
118 | retval = irq; | 118 | retval = irq; |
119 | goto fail_irq_get; | 119 | goto fail; |
120 | } | 120 | } |
121 | 121 | ||
122 | /* | 122 | /* |
@@ -127,38 +127,38 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) | |||
127 | if (!pdev->dev.dma_mask) | 127 | if (!pdev->dev.dma_mask) |
128 | pdev->dev.dma_mask = &spear_ehci_dma_mask; | 128 | pdev->dev.dma_mask = &spear_ehci_dma_mask; |
129 | 129 | ||
130 | usbh_clk = clk_get(&pdev->dev, NULL); | 130 | usbh_clk = devm_clk_get(&pdev->dev, NULL); |
131 | if (IS_ERR(usbh_clk)) { | 131 | if (IS_ERR(usbh_clk)) { |
132 | dev_err(&pdev->dev, "Error getting interface clock\n"); | 132 | dev_err(&pdev->dev, "Error getting interface clock\n"); |
133 | retval = PTR_ERR(usbh_clk); | 133 | retval = PTR_ERR(usbh_clk); |
134 | goto fail_get_usbh_clk; | 134 | goto fail; |
135 | } | 135 | } |
136 | 136 | ||
137 | hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); | 137 | hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); |
138 | if (!hcd) { | 138 | if (!hcd) { |
139 | retval = -ENOMEM; | 139 | retval = -ENOMEM; |
140 | goto fail_create_hcd; | 140 | goto fail; |
141 | } | 141 | } |
142 | 142 | ||
143 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 143 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
144 | if (!res) { | 144 | if (!res) { |
145 | retval = -ENODEV; | 145 | retval = -ENODEV; |
146 | goto fail_request_resource; | 146 | goto err_put_hcd; |
147 | } | 147 | } |
148 | 148 | ||
149 | hcd->rsrc_start = res->start; | 149 | hcd->rsrc_start = res->start; |
150 | hcd->rsrc_len = resource_size(res); | 150 | hcd->rsrc_len = resource_size(res); |
151 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, | 151 | if (!devm_request_mem_region(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len, |
152 | driver->description)) { | 152 | driver->description)) { |
153 | retval = -EBUSY; | 153 | retval = -EBUSY; |
154 | goto fail_request_resource; | 154 | goto err_put_hcd; |
155 | } | 155 | } |
156 | 156 | ||
157 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | 157 | hcd->regs = devm_ioremap(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len); |
158 | if (hcd->regs == NULL) { | 158 | if (hcd->regs == NULL) { |
159 | dev_dbg(&pdev->dev, "error mapping memory\n"); | 159 | dev_dbg(&pdev->dev, "error mapping memory\n"); |
160 | retval = -ENOMEM; | 160 | retval = -ENOMEM; |
161 | goto fail_ioremap; | 161 | goto err_put_hcd; |
162 | } | 162 | } |
163 | 163 | ||
164 | ehci = (struct spear_ehci *)hcd_to_ehci(hcd); | 164 | ehci = (struct spear_ehci *)hcd_to_ehci(hcd); |
@@ -167,21 +167,15 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) | |||
167 | spear_start_ehci(ehci); | 167 | spear_start_ehci(ehci); |
168 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); | 168 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); |
169 | if (retval) | 169 | if (retval) |
170 | goto fail_add_hcd; | 170 | goto err_stop_ehci; |
171 | 171 | ||
172 | return retval; | 172 | return retval; |
173 | 173 | ||
174 | fail_add_hcd: | 174 | err_stop_ehci: |
175 | spear_stop_ehci(ehci); | 175 | spear_stop_ehci(ehci); |
176 | iounmap(hcd->regs); | 176 | err_put_hcd: |
177 | fail_ioremap: | ||
178 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
179 | fail_request_resource: | ||
180 | usb_put_hcd(hcd); | 177 | usb_put_hcd(hcd); |
181 | fail_create_hcd: | 178 | fail: |
182 | clk_put(usbh_clk); | ||
183 | fail_get_usbh_clk: | ||
184 | fail_irq_get: | ||
185 | dev_err(&pdev->dev, "init fail, %d\n", retval); | 179 | dev_err(&pdev->dev, "init fail, %d\n", retval); |
186 | 180 | ||
187 | return retval ; | 181 | return retval ; |
@@ -200,13 +194,8 @@ static int spear_ehci_hcd_drv_remove(struct platform_device *pdev) | |||
200 | 194 | ||
201 | if (ehci_p->clk) | 195 | if (ehci_p->clk) |
202 | spear_stop_ehci(ehci_p); | 196 | spear_stop_ehci(ehci_p); |
203 | iounmap(hcd->regs); | ||
204 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
205 | usb_put_hcd(hcd); | 197 | usb_put_hcd(hcd); |
206 | 198 | ||
207 | if (ehci_p->clk) | ||
208 | clk_put(ehci_p->clk); | ||
209 | |||
210 | return 0; | 199 | return 0; |
211 | } | 200 | } |
212 | 201 | ||