diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2012-07-29 15:46:08 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-10 15:01:33 -0400 |
commit | 436f271996a1925e506d5004dcbf62bce24e5777 (patch) | |
tree | 45ac9a2e3c07fae55d956a08231a7d2c873193ef /drivers | |
parent | f0675e2a99dd305114986d22e2572c72bd69804b (diff) |
drivers/usb/host/ehci-grlib.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')
-rw-r--r-- | drivers/usb/host/ehci-grlib.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/drivers/usb/host/ehci-grlib.c b/drivers/usb/host/ehci-grlib.c index 22ca45c079a4..3180cb3624d9 100644 --- a/drivers/usb/host/ehci-grlib.c +++ b/drivers/usb/host/ehci-grlib.c | |||
@@ -127,12 +127,6 @@ static int __devinit ehci_hcd_grlib_probe(struct platform_device *op) | |||
127 | hcd->rsrc_start = res.start; | 127 | hcd->rsrc_start = res.start; |
128 | hcd->rsrc_len = resource_size(&res); | 128 | hcd->rsrc_len = resource_size(&res); |
129 | 129 | ||
130 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
131 | printk(KERN_ERR "%s: request_mem_region failed\n", __FILE__); | ||
132 | rv = -EBUSY; | ||
133 | goto err_rmr; | ||
134 | } | ||
135 | |||
136 | irq = irq_of_parse_and_map(dn, 0); | 130 | irq = irq_of_parse_and_map(dn, 0); |
137 | if (irq == NO_IRQ) { | 131 | if (irq == NO_IRQ) { |
138 | printk(KERN_ERR "%s: irq_of_parse_and_map failed\n", __FILE__); | 132 | printk(KERN_ERR "%s: irq_of_parse_and_map failed\n", __FILE__); |
@@ -140,9 +134,9 @@ static int __devinit ehci_hcd_grlib_probe(struct platform_device *op) | |||
140 | goto err_irq; | 134 | goto err_irq; |
141 | } | 135 | } |
142 | 136 | ||
143 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | 137 | hcd->regs = devm_request_and_ioremap(&op->dev, &res); |
144 | if (!hcd->regs) { | 138 | if (!hcd->regs) { |
145 | printk(KERN_ERR "%s: ioremap failed\n", __FILE__); | 139 | pr_err("%s: devm_request_and_ioremap failed\n", __FILE__); |
146 | rv = -ENOMEM; | 140 | rv = -ENOMEM; |
147 | goto err_ioremap; | 141 | goto err_ioremap; |
148 | } | 142 | } |
@@ -161,17 +155,13 @@ static int __devinit ehci_hcd_grlib_probe(struct platform_device *op) | |||
161 | 155 | ||
162 | rv = usb_add_hcd(hcd, irq, 0); | 156 | rv = usb_add_hcd(hcd, irq, 0); |
163 | if (rv) | 157 | if (rv) |
164 | goto err_ehci; | 158 | goto err_ioremap; |
165 | 159 | ||
166 | return 0; | 160 | return 0; |
167 | 161 | ||
168 | err_ehci: | ||
169 | iounmap(hcd->regs); | ||
170 | err_ioremap: | 162 | err_ioremap: |
171 | irq_dispose_mapping(irq); | 163 | irq_dispose_mapping(irq); |
172 | err_irq: | 164 | err_irq: |
173 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
174 | err_rmr: | ||
175 | usb_put_hcd(hcd); | 165 | usb_put_hcd(hcd); |
176 | 166 | ||
177 | return rv; | 167 | return rv; |
@@ -188,9 +178,7 @@ static int ehci_hcd_grlib_remove(struct platform_device *op) | |||
188 | 178 | ||
189 | usb_remove_hcd(hcd); | 179 | usb_remove_hcd(hcd); |
190 | 180 | ||
191 | iounmap(hcd->regs); | ||
192 | irq_dispose_mapping(hcd->irq); | 181 | irq_dispose_mapping(hcd->irq); |
193 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
194 | 182 | ||
195 | usb_put_hcd(hcd); | 183 | usb_put_hcd(hcd); |
196 | 184 | ||