diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2012-07-29 15:46:07 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-10 15:01:33 -0400 |
commit | f0675e2a99dd305114986d22e2572c72bd69804b (patch) | |
tree | f5693f2b27cf5120ab5145cbe5ecfb487557d9c5 | |
parent | 8ca41ae35f5567280eac787a9cc9bcd5988b9f82 (diff) |
drivers/usb/host/ehci-cns3xxx.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-cns3xxx.c | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/drivers/usb/host/ehci-cns3xxx.c b/drivers/usb/host/ehci-cns3xxx.c index caaa3e5be334..d91708d2e729 100644 --- a/drivers/usb/host/ehci-cns3xxx.c +++ b/drivers/usb/host/ehci-cns3xxx.c | |||
@@ -105,27 +105,17 @@ static int cns3xxx_ehci_probe(struct platform_device *pdev) | |||
105 | hcd->rsrc_start = res->start; | 105 | hcd->rsrc_start = res->start; |
106 | hcd->rsrc_len = resource_size(res); | 106 | hcd->rsrc_len = resource_size(res); |
107 | 107 | ||
108 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, | 108 | hcd->regs = devm_request_and_ioremap(&pdev->dev, res); |
109 | driver->description)) { | ||
110 | dev_dbg(dev, "controller already in use\n"); | ||
111 | retval = -EBUSY; | ||
112 | goto err1; | ||
113 | } | ||
114 | |||
115 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
116 | if (hcd->regs == NULL) { | 109 | if (hcd->regs == NULL) { |
117 | dev_dbg(dev, "error mapping memory\n"); | 110 | dev_dbg(dev, "error mapping memory\n"); |
118 | retval = -EFAULT; | 111 | retval = -EFAULT; |
119 | goto err2; | 112 | goto err1; |
120 | } | 113 | } |
121 | 114 | ||
122 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); | 115 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); |
123 | if (retval == 0) | 116 | if (retval == 0) |
124 | return retval; | 117 | return retval; |
125 | 118 | ||
126 | iounmap(hcd->regs); | ||
127 | err2: | ||
128 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
129 | err1: | 119 | err1: |
130 | usb_put_hcd(hcd); | 120 | usb_put_hcd(hcd); |
131 | 121 | ||
@@ -137,8 +127,6 @@ static int cns3xxx_ehci_remove(struct platform_device *pdev) | |||
137 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 127 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
138 | 128 | ||
139 | usb_remove_hcd(hcd); | 129 | usb_remove_hcd(hcd); |
140 | iounmap(hcd->regs); | ||
141 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
142 | 130 | ||
143 | /* | 131 | /* |
144 | * EHCI and OHCI share the same clock and power, | 132 | * EHCI and OHCI share the same clock and power, |