aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/ohci-spear.c
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/ohci-spear.c
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/ohci-spear.c')
-rw-r--r--drivers/usb/host/ohci-spear.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/drivers/usb/host/ohci-spear.c b/drivers/usb/host/ohci-spear.c
index 974770833653..c69725d9f0cd 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}