aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2012-06-28 03:29:46 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-07-06 13:42:21 -0400
commit9cb07563721cb05f91b517aefd70b57ba8a1d5aa (patch)
tree7c27a69df6b6c49fbe34478c6bae0c11ca364729 /drivers
parent390a0a78067c487609ba5bd18c264f7d5b6f4e96 (diff)
USB: ehci-s5p: 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')
-rw-r--r--drivers/usb/host/ehci-s5p.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
index c474cec064e4..1e483f052ff7 100644
--- a/drivers/usb/host/ehci-s5p.c
+++ b/drivers/usb/host/ehci-s5p.c
@@ -79,7 +79,8 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
79 return -EINVAL; 79 return -EINVAL;
80 } 80 }
81 81
82 s5p_ehci = kzalloc(sizeof(struct s5p_ehci_hcd), GFP_KERNEL); 82 s5p_ehci = devm_kzalloc(&pdev->dev, sizeof(struct s5p_ehci_hcd),
83 GFP_KERNEL);
83 if (!s5p_ehci) 84 if (!s5p_ehci)
84 return -ENOMEM; 85 return -ENOMEM;
85 86
@@ -89,8 +90,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
89 dev_name(&pdev->dev)); 90 dev_name(&pdev->dev));
90 if (!hcd) { 91 if (!hcd) {
91 dev_err(&pdev->dev, "Unable to create HCD\n"); 92 dev_err(&pdev->dev, "Unable to create HCD\n");
92 err = -ENOMEM; 93 return -ENOMEM;
93 goto fail_hcd;
94 } 94 }
95 95
96 s5p_ehci->hcd = hcd; 96 s5p_ehci->hcd = hcd;
@@ -115,7 +115,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
115 115
116 hcd->rsrc_start = res->start; 116 hcd->rsrc_start = res->start;
117 hcd->rsrc_len = resource_size(res); 117 hcd->rsrc_len = resource_size(res);
118 hcd->regs = ioremap(res->start, resource_size(res)); 118 hcd->regs = devm_ioremap(&pdev->dev, res->start, hcd->rsrc_len);
119 if (!hcd->regs) { 119 if (!hcd->regs) {
120 dev_err(&pdev->dev, "Failed to remap I/O memory\n"); 120 dev_err(&pdev->dev, "Failed to remap I/O memory\n");
121 err = -ENOMEM; 121 err = -ENOMEM;
@@ -126,7 +126,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
126 if (!irq) { 126 if (!irq) {
127 dev_err(&pdev->dev, "Failed to get IRQ\n"); 127 dev_err(&pdev->dev, "Failed to get IRQ\n");
128 err = -ENODEV; 128 err = -ENODEV;
129 goto fail; 129 goto fail_io;
130 } 130 }
131 131
132 if (pdata->phy_init) 132 if (pdata->phy_init)
@@ -151,23 +151,19 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
151 err = usb_add_hcd(hcd, irq, IRQF_SHARED); 151 err = usb_add_hcd(hcd, irq, IRQF_SHARED);
152 if (err) { 152 if (err) {
153 dev_err(&pdev->dev, "Failed to add USB HCD\n"); 153 dev_err(&pdev->dev, "Failed to add USB HCD\n");
154 goto fail; 154 goto fail_io;
155 } 155 }
156 156
157 platform_set_drvdata(pdev, s5p_ehci); 157 platform_set_drvdata(pdev, s5p_ehci);
158 158
159 return 0; 159 return 0;
160 160
161fail:
162 iounmap(hcd->regs);
163fail_io: 161fail_io:
164 clk_disable(s5p_ehci->clk); 162 clk_disable(s5p_ehci->clk);
165fail_clken: 163fail_clken:
166 clk_put(s5p_ehci->clk); 164 clk_put(s5p_ehci->clk);
167fail_clk: 165fail_clk:
168 usb_put_hcd(hcd); 166 usb_put_hcd(hcd);
169fail_hcd:
170 kfree(s5p_ehci);
171 return err; 167 return err;
172} 168}
173 169
@@ -182,13 +178,10 @@ static int __devexit s5p_ehci_remove(struct platform_device *pdev)
182 if (pdata && pdata->phy_exit) 178 if (pdata && pdata->phy_exit)
183 pdata->phy_exit(pdev, S5P_USB_PHY_HOST); 179 pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
184 180
185 iounmap(hcd->regs);
186
187 clk_disable(s5p_ehci->clk); 181 clk_disable(s5p_ehci->clk);
188 clk_put(s5p_ehci->clk); 182 clk_put(s5p_ehci->clk);
189 183
190 usb_put_hcd(hcd); 184 usb_put_hcd(hcd);
191 kfree(s5p_ehci);
192 185
193 return 0; 186 return 0;
194} 187}