diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2012-07-30 10:43:45 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-10 15:04:09 -0400 |
commit | 1c5404f7abd250ce71849c2687d266073b54e1d4 (patch) | |
tree | dc117a101f79ed57dcea2262797df6c791018df2 | |
parent | af09c060895b9c9137c02943c71302ac0fc9555a (diff) |
drivers/usb/host/ehci-ppc-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>
-rw-r--r-- | drivers/usb/host/ehci-ppc-of.c | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/drivers/usb/host/ehci-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c index bbbe89dfd886..fa937d05a02b 100644 --- a/drivers/usb/host/ehci-ppc-of.c +++ b/drivers/usb/host/ehci-ppc-of.c | |||
@@ -114,12 +114,6 @@ static int __devinit ehci_hcd_ppc_of_probe(struct platform_device *op) | |||
114 | hcd->rsrc_start = res.start; | 114 | hcd->rsrc_start = res.start; |
115 | hcd->rsrc_len = resource_size(&res); | 115 | hcd->rsrc_len = resource_size(&res); |
116 | 116 | ||
117 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
118 | printk(KERN_ERR "%s: request_mem_region failed\n", __FILE__); | ||
119 | rv = -EBUSY; | ||
120 | goto err_rmr; | ||
121 | } | ||
122 | |||
123 | irq = irq_of_parse_and_map(dn, 0); | 117 | irq = irq_of_parse_and_map(dn, 0); |
124 | if (irq == NO_IRQ) { | 118 | if (irq == NO_IRQ) { |
125 | printk(KERN_ERR "%s: irq_of_parse_and_map failed\n", __FILE__); | 119 | printk(KERN_ERR "%s: irq_of_parse_and_map failed\n", __FILE__); |
@@ -127,9 +121,9 @@ static int __devinit ehci_hcd_ppc_of_probe(struct platform_device *op) | |||
127 | goto err_irq; | 121 | goto err_irq; |
128 | } | 122 | } |
129 | 123 | ||
130 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | 124 | hcd->regs = devm_request_and_ioremap(&op->dev, &res); |
131 | if (!hcd->regs) { | 125 | if (!hcd->regs) { |
132 | printk(KERN_ERR "%s: ioremap failed\n", __FILE__); | 126 | pr_err("%s: devm_request_and_ioremap failed\n", __FILE__); |
133 | rv = -ENOMEM; | 127 | rv = -ENOMEM; |
134 | goto err_ioremap; | 128 | goto err_ioremap; |
135 | } | 129 | } |
@@ -139,8 +133,10 @@ static int __devinit ehci_hcd_ppc_of_probe(struct platform_device *op) | |||
139 | if (np != NULL) { | 133 | if (np != NULL) { |
140 | /* claim we really affected by usb23 erratum */ | 134 | /* claim we really affected by usb23 erratum */ |
141 | if (!of_address_to_resource(np, 0, &res)) | 135 | if (!of_address_to_resource(np, 0, &res)) |
142 | ehci->ohci_hcctrl_reg = ioremap(res.start + | 136 | ehci->ohci_hcctrl_reg = |
143 | OHCI_HCCTRL_OFFSET, OHCI_HCCTRL_LEN); | 137 | devm_ioremap(&op->dev, |
138 | res.start + OHCI_HCCTRL_OFFSET, | ||
139 | OHCI_HCCTRL_LEN); | ||
144 | else | 140 | else |
145 | pr_debug("%s: no ohci offset in fdt\n", __FILE__); | 141 | pr_debug("%s: no ohci offset in fdt\n", __FILE__); |
146 | if (!ehci->ohci_hcctrl_reg) { | 142 | if (!ehci->ohci_hcctrl_reg) { |
@@ -169,19 +165,13 @@ static int __devinit ehci_hcd_ppc_of_probe(struct platform_device *op) | |||
169 | 165 | ||
170 | rv = usb_add_hcd(hcd, irq, 0); | 166 | rv = usb_add_hcd(hcd, irq, 0); |
171 | if (rv) | 167 | if (rv) |
172 | goto err_ehci; | 168 | goto err_ioremap; |
173 | 169 | ||
174 | return 0; | 170 | return 0; |
175 | 171 | ||
176 | err_ehci: | ||
177 | if (ehci->has_amcc_usb23) | ||
178 | iounmap(ehci->ohci_hcctrl_reg); | ||
179 | iounmap(hcd->regs); | ||
180 | err_ioremap: | 172 | err_ioremap: |
181 | irq_dispose_mapping(irq); | 173 | irq_dispose_mapping(irq); |
182 | err_irq: | 174 | err_irq: |
183 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
184 | err_rmr: | ||
185 | usb_put_hcd(hcd); | 175 | usb_put_hcd(hcd); |
186 | 176 | ||
187 | return rv; | 177 | return rv; |
@@ -202,9 +192,7 @@ static int ehci_hcd_ppc_of_remove(struct platform_device *op) | |||
202 | 192 | ||
203 | usb_remove_hcd(hcd); | 193 | usb_remove_hcd(hcd); |
204 | 194 | ||
205 | iounmap(hcd->regs); | ||
206 | irq_dispose_mapping(hcd->irq); | 195 | irq_dispose_mapping(hcd->irq); |
207 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
208 | 196 | ||
209 | /* use request_mem_region to test if the ohci driver is loaded. if so | 197 | /* use request_mem_region to test if the ohci driver is loaded. if so |
210 | * ensure the ohci core is operational. | 198 | * ensure the ohci core is operational. |
@@ -222,8 +210,6 @@ static int ehci_hcd_ppc_of_remove(struct platform_device *op) | |||
222 | pr_debug("%s: no ohci offset in fdt\n", __FILE__); | 210 | pr_debug("%s: no ohci offset in fdt\n", __FILE__); |
223 | of_node_put(np); | 211 | of_node_put(np); |
224 | } | 212 | } |
225 | |||
226 | iounmap(ehci->ohci_hcctrl_reg); | ||
227 | } | 213 | } |
228 | usb_put_hcd(hcd); | 214 | usb_put_hcd(hcd); |
229 | 215 | ||