aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2012-11-08 10:07:59 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-11-14 15:15:20 -0500
commit98515e5923b1c8f982511eeec9d27014b05efebf (patch)
tree8d060a8abbb31702660861d0665bf9627ff16316 /drivers/usb/host
parentd8fd7d5ae3e0561920b38647793b1947e07c7acf (diff)
usb: spear-ehci/ohci: Use devm_*() routines
This patch frees SPEAr ehci/ohci drivers from tension of freeing resources :) devm_* derivatives of multiple routines are used while allocating resources, which would be freed automatically by kernel. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/ehci-spear.c37
-rw-r--r--drivers/usb/host/ohci-spear.c33
2 files changed, 25 insertions, 45 deletions
diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c
index d08506af41c..3fadff8f8d3 100644
--- a/drivers/usb/host/ehci-spear.c
+++ b/drivers/usb/host/ehci-spear.c
@@ -116,7 +116,7 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
116 irq = platform_get_irq(pdev, 0); 116 irq = platform_get_irq(pdev, 0);
117 if (irq < 0) { 117 if (irq < 0) {
118 retval = irq; 118 retval = irq;
119 goto fail_irq_get; 119 goto fail;
120 } 120 }
121 121
122 /* 122 /*
@@ -127,38 +127,38 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
127 if (!pdev->dev.dma_mask) 127 if (!pdev->dev.dma_mask)
128 pdev->dev.dma_mask = &spear_ehci_dma_mask; 128 pdev->dev.dma_mask = &spear_ehci_dma_mask;
129 129
130 usbh_clk = clk_get(&pdev->dev, NULL); 130 usbh_clk = devm_clk_get(&pdev->dev, NULL);
131 if (IS_ERR(usbh_clk)) { 131 if (IS_ERR(usbh_clk)) {
132 dev_err(&pdev->dev, "Error getting interface clock\n"); 132 dev_err(&pdev->dev, "Error getting interface clock\n");
133 retval = PTR_ERR(usbh_clk); 133 retval = PTR_ERR(usbh_clk);
134 goto fail_get_usbh_clk; 134 goto fail;
135 } 135 }
136 136
137 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); 137 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
138 if (!hcd) { 138 if (!hcd) {
139 retval = -ENOMEM; 139 retval = -ENOMEM;
140 goto fail_create_hcd; 140 goto fail;
141 } 141 }
142 142
143 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 143 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
144 if (!res) { 144 if (!res) {
145 retval = -ENODEV; 145 retval = -ENODEV;
146 goto fail_request_resource; 146 goto err_put_hcd;
147 } 147 }
148 148
149 hcd->rsrc_start = res->start; 149 hcd->rsrc_start = res->start;
150 hcd->rsrc_len = resource_size(res); 150 hcd->rsrc_len = resource_size(res);
151 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, 151 if (!devm_request_mem_region(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len,
152 driver->description)) { 152 driver->description)) {
153 retval = -EBUSY; 153 retval = -EBUSY;
154 goto fail_request_resource; 154 goto err_put_hcd;
155 } 155 }
156 156
157 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 157 hcd->regs = devm_ioremap(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len);
158 if (hcd->regs == NULL) { 158 if (hcd->regs == NULL) {
159 dev_dbg(&pdev->dev, "error mapping memory\n"); 159 dev_dbg(&pdev->dev, "error mapping memory\n");
160 retval = -ENOMEM; 160 retval = -ENOMEM;
161 goto fail_ioremap; 161 goto err_put_hcd;
162 } 162 }
163 163
164 ehci = (struct spear_ehci *)hcd_to_ehci(hcd); 164 ehci = (struct spear_ehci *)hcd_to_ehci(hcd);
@@ -167,21 +167,15 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
167 spear_start_ehci(ehci); 167 spear_start_ehci(ehci);
168 retval = usb_add_hcd(hcd, irq, IRQF_SHARED); 168 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
169 if (retval) 169 if (retval)
170 goto fail_add_hcd; 170 goto err_stop_ehci;
171 171
172 return retval; 172 return retval;
173 173
174fail_add_hcd: 174err_stop_ehci:
175 spear_stop_ehci(ehci); 175 spear_stop_ehci(ehci);
176 iounmap(hcd->regs); 176err_put_hcd:
177fail_ioremap:
178 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
179fail_request_resource:
180 usb_put_hcd(hcd); 177 usb_put_hcd(hcd);
181fail_create_hcd: 178fail:
182 clk_put(usbh_clk);
183fail_get_usbh_clk:
184fail_irq_get:
185 dev_err(&pdev->dev, "init fail, %d\n", retval); 179 dev_err(&pdev->dev, "init fail, %d\n", retval);
186 180
187 return retval ; 181 return retval ;
@@ -200,13 +194,8 @@ static int spear_ehci_hcd_drv_remove(struct platform_device *pdev)
200 194
201 if (ehci_p->clk) 195 if (ehci_p->clk)
202 spear_stop_ehci(ehci_p); 196 spear_stop_ehci(ehci_p);
203 iounmap(hcd->regs);
204 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
205 usb_put_hcd(hcd); 197 usb_put_hcd(hcd);
206 198
207 if (ehci_p->clk)
208 clk_put(ehci_p->clk);
209
210 return 0; 199 return 0;
211} 200}
212 201
diff --git a/drivers/usb/host/ohci-spear.c b/drivers/usb/host/ohci-spear.c
index 97477083365..c69725d9f0c 100644
--- a/drivers/usb/host/ohci-spear.c
+++ b/drivers/usb/host/ohci-spear.c
@@ -105,7 +105,7 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev)
105 irq = platform_get_irq(pdev, 0); 105 irq = platform_get_irq(pdev, 0);
106 if (irq < 0) { 106 if (irq < 0) {
107 retval = irq; 107 retval = irq;
108 goto fail_irq_get; 108 goto fail;
109 } 109 }
110 110
111 /* 111 /*
@@ -116,38 +116,39 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev)
116 if (!pdev->dev.dma_mask) 116 if (!pdev->dev.dma_mask)
117 pdev->dev.dma_mask = &spear_ohci_dma_mask; 117 pdev->dev.dma_mask = &spear_ohci_dma_mask;
118 118
119 usbh_clk = clk_get(&pdev->dev, NULL); 119 usbh_clk = devm_clk_get(&pdev->dev, NULL);
120 if (IS_ERR(usbh_clk)) { 120 if (IS_ERR(usbh_clk)) {
121 dev_err(&pdev->dev, "Error getting interface clock\n"); 121 dev_err(&pdev->dev, "Error getting interface clock\n");
122 retval = PTR_ERR(usbh_clk); 122 retval = PTR_ERR(usbh_clk);
123 goto fail_get_usbh_clk; 123 goto fail;
124 } 124 }
125 125
126 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); 126 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
127 if (!hcd) { 127 if (!hcd) {
128 retval = -ENOMEM; 128 retval = -ENOMEM;
129 goto fail_create_hcd; 129 goto fail;
130 } 130 }
131 131
132 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 132 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
133 if (!res) { 133 if (!res) {
134 retval = -ENODEV; 134 retval = -ENODEV;
135 goto fail_request_resource; 135 goto err_put_hcd;
136 } 136 }
137 137
138 hcd->rsrc_start = pdev->resource[0].start; 138 hcd->rsrc_start = pdev->resource[0].start;
139 hcd->rsrc_len = resource_size(res); 139 hcd->rsrc_len = resource_size(res);
140 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 140 if (!devm_request_mem_region(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len,
141 hcd_name)) {
141 dev_dbg(&pdev->dev, "request_mem_region failed\n"); 142 dev_dbg(&pdev->dev, "request_mem_region failed\n");
142 retval = -EBUSY; 143 retval = -EBUSY;
143 goto fail_request_resource; 144 goto err_put_hcd;
144 } 145 }
145 146
146 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 147 hcd->regs = devm_ioremap(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len);
147 if (!hcd->regs) { 148 if (!hcd->regs) {
148 dev_dbg(&pdev->dev, "ioremap failed\n"); 149 dev_dbg(&pdev->dev, "ioremap failed\n");
149 retval = -ENOMEM; 150 retval = -ENOMEM;
150 goto fail_ioremap; 151 goto err_put_hcd;
151 } 152 }
152 153
153 ohci_p = (struct spear_ohci *)hcd_to_ohci(hcd); 154 ohci_p = (struct spear_ohci *)hcd_to_ohci(hcd);
@@ -160,15 +161,9 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev)
160 return retval; 161 return retval;
161 162
162 spear_stop_ohci(ohci_p); 163 spear_stop_ohci(ohci_p);
163 iounmap(hcd->regs); 164err_put_hcd:
164fail_ioremap:
165 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
166fail_request_resource:
167 usb_put_hcd(hcd); 165 usb_put_hcd(hcd);
168fail_create_hcd: 166fail:
169 clk_put(usbh_clk);
170fail_get_usbh_clk:
171fail_irq_get:
172 dev_err(&pdev->dev, "init fail, %d\n", retval); 167 dev_err(&pdev->dev, "init fail, %d\n", retval);
173 168
174 return retval; 169 return retval;
@@ -183,12 +178,8 @@ static int spear_ohci_hcd_drv_remove(struct platform_device *pdev)
183 if (ohci_p->clk) 178 if (ohci_p->clk)
184 spear_stop_ohci(ohci_p); 179 spear_stop_ohci(ohci_p);
185 180
186 iounmap(hcd->regs);
187 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
188 usb_put_hcd(hcd); 181 usb_put_hcd(hcd);
189 182
190 if (ohci_p->clk)
191 clk_put(ohci_p->clk);
192 platform_set_drvdata(pdev, NULL); 183 platform_set_drvdata(pdev, NULL);
193 return 0; 184 return 0;
194} 185}