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>
This commit is contained in:
Julia Lawall 2012-07-29 21:46:08 +02:00 коммит произвёл Greg Kroah-Hartman
Родитель f0675e2a99
Коммит 436f271996
1 изменённых файлов: 3 добавлений и 15 удалений

Просмотреть файл

@ -127,12 +127,6 @@ static int __devinit ehci_hcd_grlib_probe(struct platform_device *op)
hcd->rsrc_start = res.start; hcd->rsrc_start = res.start;
hcd->rsrc_len = resource_size(&res); hcd->rsrc_len = resource_size(&res);
if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
printk(KERN_ERR "%s: request_mem_region failed\n", __FILE__);
rv = -EBUSY;
goto err_rmr;
}
irq = irq_of_parse_and_map(dn, 0); irq = irq_of_parse_and_map(dn, 0);
if (irq == NO_IRQ) { if (irq == NO_IRQ) {
printk(KERN_ERR "%s: irq_of_parse_and_map failed\n", __FILE__); 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)
goto err_irq; goto err_irq;
} }
hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); hcd->regs = devm_request_and_ioremap(&op->dev, &res);
if (!hcd->regs) { if (!hcd->regs) {
printk(KERN_ERR "%s: ioremap failed\n", __FILE__); pr_err("%s: devm_request_and_ioremap failed\n", __FILE__);
rv = -ENOMEM; rv = -ENOMEM;
goto err_ioremap; goto err_ioremap;
} }
@ -161,17 +155,13 @@ static int __devinit ehci_hcd_grlib_probe(struct platform_device *op)
rv = usb_add_hcd(hcd, irq, 0); rv = usb_add_hcd(hcd, irq, 0);
if (rv) if (rv)
goto err_ehci; goto err_ioremap;
return 0; return 0;
err_ehci:
iounmap(hcd->regs);
err_ioremap: err_ioremap:
irq_dispose_mapping(irq); irq_dispose_mapping(irq);
err_irq: err_irq:
release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
err_rmr:
usb_put_hcd(hcd); usb_put_hcd(hcd);
return rv; return rv;
@ -188,9 +178,7 @@ static int ehci_hcd_grlib_remove(struct platform_device *op)
usb_remove_hcd(hcd); usb_remove_hcd(hcd);
iounmap(hcd->regs);
irq_dispose_mapping(hcd->irq); irq_dispose_mapping(hcd->irq);
release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
usb_put_hcd(hcd); usb_put_hcd(hcd);