aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/ohci-exynos.c
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2012-06-28 03:30:30 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-07-06 13:42:21 -0400
commit390a0a78067c487609ba5bd18c264f7d5b6f4e96 (patch)
treed4caaf950d91c805f204ea9d94a4ed5018804490 /drivers/usb/host/ohci-exynos.c
parente864abed546f9f4b76a3580fb3c53cd389e0c015 (diff)
USB: ohci-exynos: use devm_ functions
The devm_ functions allocate memory that is released when a driver detaches. This makes the code smaller and a bit simpler. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host/ohci-exynos.c')
-rw-r--r--drivers/usb/host/ohci-exynos.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index fedb0eff35d..8bcbdb5ade2 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -87,7 +87,8 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
87 return -EINVAL; 87 return -EINVAL;
88 } 88 }
89 89
90 exynos_ohci = kzalloc(sizeof(struct exynos_ohci_hcd), GFP_KERNEL); 90 exynos_ohci = devm_kzalloc(&pdev->dev, sizeof(struct exynos_ohci_hcd),
91 GFP_KERNEL);
91 if (!exynos_ohci) 92 if (!exynos_ohci)
92 return -ENOMEM; 93 return -ENOMEM;
93 94
@@ -97,8 +98,7 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
97 dev_name(&pdev->dev)); 98 dev_name(&pdev->dev));
98 if (!hcd) { 99 if (!hcd) {
99 dev_err(&pdev->dev, "Unable to create HCD\n"); 100 dev_err(&pdev->dev, "Unable to create HCD\n");
100 err = -ENOMEM; 101 return -ENOMEM;
101 goto fail_hcd;
102 } 102 }
103 103
104 exynos_ohci->hcd = hcd; 104 exynos_ohci->hcd = hcd;
@@ -123,7 +123,7 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
123 123
124 hcd->rsrc_start = res->start; 124 hcd->rsrc_start = res->start;
125 hcd->rsrc_len = resource_size(res); 125 hcd->rsrc_len = resource_size(res);
126 hcd->regs = ioremap(res->start, resource_size(res)); 126 hcd->regs = devm_ioremap(&pdev->dev, res->start, hcd->rsrc_len);
127 if (!hcd->regs) { 127 if (!hcd->regs) {
128 dev_err(&pdev->dev, "Failed to remap I/O memory\n"); 128 dev_err(&pdev->dev, "Failed to remap I/O memory\n");
129 err = -ENOMEM; 129 err = -ENOMEM;
@@ -134,7 +134,7 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
134 if (!irq) { 134 if (!irq) {
135 dev_err(&pdev->dev, "Failed to get IRQ\n"); 135 dev_err(&pdev->dev, "Failed to get IRQ\n");
136 err = -ENODEV; 136 err = -ENODEV;
137 goto fail; 137 goto fail_io;
138 } 138 }
139 139
140 if (pdata->phy_init) 140 if (pdata->phy_init)
@@ -146,23 +146,19 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
146 err = usb_add_hcd(hcd, irq, IRQF_SHARED); 146 err = usb_add_hcd(hcd, irq, IRQF_SHARED);
147 if (err) { 147 if (err) {
148 dev_err(&pdev->dev, "Failed to add USB HCD\n"); 148 dev_err(&pdev->dev, "Failed to add USB HCD\n");
149 goto fail; 149 goto fail_io;
150 } 150 }
151 151
152 platform_set_drvdata(pdev, exynos_ohci); 152 platform_set_drvdata(pdev, exynos_ohci);
153 153
154 return 0; 154 return 0;
155 155
156fail:
157 iounmap(hcd->regs);
158fail_io: 156fail_io:
159 clk_disable(exynos_ohci->clk); 157 clk_disable(exynos_ohci->clk);
160fail_clken: 158fail_clken:
161 clk_put(exynos_ohci->clk); 159 clk_put(exynos_ohci->clk);
162fail_clk: 160fail_clk:
163 usb_put_hcd(hcd); 161 usb_put_hcd(hcd);
164fail_hcd:
165 kfree(exynos_ohci);
166 return err; 162 return err;
167} 163}
168 164
@@ -177,13 +173,10 @@ static int __devexit exynos_ohci_remove(struct platform_device *pdev)
177 if (pdata && pdata->phy_exit) 173 if (pdata && pdata->phy_exit)
178 pdata->phy_exit(pdev, S5P_USB_PHY_HOST); 174 pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
179 175
180 iounmap(hcd->regs);
181
182 clk_disable(exynos_ohci->clk); 176 clk_disable(exynos_ohci->clk);
183 clk_put(exynos_ohci->clk); 177 clk_put(exynos_ohci->clk);
184 178
185 usb_put_hcd(hcd); 179 usb_put_hcd(hcd);
186 kfree(exynos_ohci);
187 180
188 return 0; 181 return 0;
189} 182}