Commit ddd94257 authored by Himangi Saraogi's avatar Himangi Saraogi Committed by Greg Kroah-Hartman

usb: host: uhci-grlib.c : use devm_ functions

The various devm_ functions allocate memory that is released when a
driver detaches. This patch uses devm_ioremap_resource for data
that is allocated in the probe function of a platform device and
is only freed in the remove function. The corresponding free functions
are removed and two labels are done away with. Also, linux/device.h
is added to make sure the devm_*() routine declarations are
unambiguously available.
Signed-off-by: default avatarHimangi Saraogi <himangi774@gmail.com>
Acked-by: default avatarAndreas Larsson <andreas@gaisler.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6a70b621
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
* (C) Copyright 2004-2007 Alan Stern, stern@rowland.harvard.edu * (C) Copyright 2004-2007 Alan Stern, stern@rowland.harvard.edu
*/ */
#include <linux/device.h>
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
...@@ -113,24 +114,17 @@ static int uhci_hcd_grlib_probe(struct platform_device *op) ...@@ -113,24 +114,17 @@ static int uhci_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__);
rv = -EBUSY; rv = -EBUSY;
goto err_irq; goto err_usb;
} }
hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); hcd->regs = devm_ioremap_resource(&op->dev, &res);
if (!hcd->regs) { if (IS_ERR(hcd->regs)) {
printk(KERN_ERR "%s: ioremap failed\n", __FILE__); rv = PTR_ERR(hcd->regs);
rv = -ENOMEM; goto err_irq;
goto err_ioremap;
} }
uhci = hcd_to_uhci(hcd); uhci = hcd_to_uhci(hcd);
...@@ -139,18 +133,14 @@ static int uhci_hcd_grlib_probe(struct platform_device *op) ...@@ -139,18 +133,14 @@ static int uhci_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_uhci; goto err_irq;
device_wakeup_enable(hcd->self.controller); device_wakeup_enable(hcd->self.controller);
return 0; return 0;
err_uhci:
iounmap(hcd->regs);
err_ioremap:
irq_dispose_mapping(irq);
err_irq: err_irq:
release_mem_region(hcd->rsrc_start, hcd->rsrc_len); irq_dispose_mapping(irq);
err_rmr: err_usb:
usb_put_hcd(hcd); usb_put_hcd(hcd);
return rv; return rv;
...@@ -164,10 +154,7 @@ static int uhci_hcd_grlib_remove(struct platform_device *op) ...@@ -164,10 +154,7 @@ static int uhci_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);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment