diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2012-07-30 10:43:39 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-10 15:04:10 -0400 |
commit | 6df471ea04bd65603b67d821f2df359cc2cfac68 (patch) | |
tree | f64731852ac0212d44dd80d4750d2d6463a3e126 /drivers/usb/host/ehci-xilinx-of.c | |
parent | f1d4eb788a007e3816132e6d1d28c25a64e86d24 (diff) |
drivers/usb/host/ehci-xilinx-of.c: use devm_ functions
The various devm_ functions allocate memory that is released when a driver
detaches. This patch uses these functions for data that is allocated in
the probe function of a platform device and is only freed in the remove
function.
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host/ehci-xilinx-of.c')
-rw-r--r-- | drivers/usb/host/ehci-xilinx-of.c | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/drivers/usb/host/ehci-xilinx-of.c b/drivers/usb/host/ehci-xilinx-of.c index 39f24fa37ebe..6a3f921a5d76 100644 --- a/drivers/usb/host/ehci-xilinx-of.c +++ b/drivers/usb/host/ehci-xilinx-of.c | |||
@@ -152,12 +152,6 @@ static int __devinit ehci_hcd_xilinx_of_probe(struct platform_device *op) | |||
152 | hcd->rsrc_start = res.start; | 152 | hcd->rsrc_start = res.start; |
153 | hcd->rsrc_len = resource_size(&res); | 153 | hcd->rsrc_len = resource_size(&res); |
154 | 154 | ||
155 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
156 | printk(KERN_ERR "%s: request_mem_region failed\n", __FILE__); | ||
157 | rv = -EBUSY; | ||
158 | goto err_rmr; | ||
159 | } | ||
160 | |||
161 | irq = irq_of_parse_and_map(dn, 0); | 155 | irq = irq_of_parse_and_map(dn, 0); |
162 | if (!irq) { | 156 | if (!irq) { |
163 | printk(KERN_ERR "%s: irq_of_parse_and_map failed\n", __FILE__); | 157 | printk(KERN_ERR "%s: irq_of_parse_and_map failed\n", __FILE__); |
@@ -165,11 +159,11 @@ static int __devinit ehci_hcd_xilinx_of_probe(struct platform_device *op) | |||
165 | goto err_irq; | 159 | goto err_irq; |
166 | } | 160 | } |
167 | 161 | ||
168 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | 162 | hcd->regs = devm_request_and_ioremap(&op->dev, &res); |
169 | if (!hcd->regs) { | 163 | if (!hcd->regs) { |
170 | printk(KERN_ERR "%s: ioremap failed\n", __FILE__); | 164 | pr_err("%s: devm_request_and_ioremap failed\n", __FILE__); |
171 | rv = -ENOMEM; | 165 | rv = -ENOMEM; |
172 | goto err_ioremap; | 166 | goto err_irq; |
173 | } | 167 | } |
174 | 168 | ||
175 | ehci = hcd_to_ehci(hcd); | 169 | ehci = hcd_to_ehci(hcd); |
@@ -200,12 +194,7 @@ static int __devinit ehci_hcd_xilinx_of_probe(struct platform_device *op) | |||
200 | if (rv == 0) | 194 | if (rv == 0) |
201 | return 0; | 195 | return 0; |
202 | 196 | ||
203 | iounmap(hcd->regs); | ||
204 | |||
205 | err_ioremap: | ||
206 | err_irq: | 197 | err_irq: |
207 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
208 | err_rmr: | ||
209 | usb_put_hcd(hcd); | 198 | usb_put_hcd(hcd); |
210 | 199 | ||
211 | return rv; | 200 | return rv; |
@@ -227,9 +216,6 @@ static int ehci_hcd_xilinx_of_remove(struct platform_device *op) | |||
227 | 216 | ||
228 | usb_remove_hcd(hcd); | 217 | usb_remove_hcd(hcd); |
229 | 218 | ||
230 | iounmap(hcd->regs); | ||
231 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
232 | |||
233 | usb_put_hcd(hcd); | 219 | usb_put_hcd(hcd); |
234 | 220 | ||
235 | return 0; | 221 | return 0; |