diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2012-07-29 15:46:11 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-10 15:01:33 -0400 |
commit | df5eb3ffa8bfd23be8189cb0c58ed0c4902b6bfd (patch) | |
tree | debc2726c0dd052fbd0ee9813396e302c8dca75c /drivers/usb/host/ehci-msm.c | |
parent | 84b79838b9bcf7a9c2c09f4de930b8d476f1e70b (diff) |
drivers/usb/host/ehci-msm.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.
The original code was also missing a call to iounmap(hcd->regs); in the
remove function, so this patch also implicitly fixes a bug.
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host/ehci-msm.c')
-rw-r--r-- | drivers/usb/host/ehci-msm.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c index 17dd9e94001e..4af4dc5b618c 100644 --- a/drivers/usb/host/ehci-msm.c +++ b/drivers/usb/host/ehci-msm.c | |||
@@ -133,7 +133,7 @@ static int ehci_msm_probe(struct platform_device *pdev) | |||
133 | 133 | ||
134 | hcd->rsrc_start = res->start; | 134 | hcd->rsrc_start = res->start; |
135 | hcd->rsrc_len = resource_size(res); | 135 | hcd->rsrc_len = resource_size(res); |
136 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | 136 | hcd->regs = devm_ioremap(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len); |
137 | if (!hcd->regs) { | 137 | if (!hcd->regs) { |
138 | dev_err(&pdev->dev, "ioremap failed\n"); | 138 | dev_err(&pdev->dev, "ioremap failed\n"); |
139 | ret = -ENOMEM; | 139 | ret = -ENOMEM; |
@@ -145,17 +145,17 @@ static int ehci_msm_probe(struct platform_device *pdev) | |||
145 | * powering up VBUS, mapping of registers address space and power | 145 | * powering up VBUS, mapping of registers address space and power |
146 | * management. | 146 | * management. |
147 | */ | 147 | */ |
148 | phy = usb_get_phy(USB_PHY_TYPE_USB2); | 148 | phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); |
149 | if (IS_ERR_OR_NULL(phy)) { | 149 | if (IS_ERR_OR_NULL(phy)) { |
150 | dev_err(&pdev->dev, "unable to find transceiver\n"); | 150 | dev_err(&pdev->dev, "unable to find transceiver\n"); |
151 | ret = -ENODEV; | 151 | ret = -ENODEV; |
152 | goto unmap; | 152 | goto put_hcd; |
153 | } | 153 | } |
154 | 154 | ||
155 | ret = otg_set_host(phy->otg, &hcd->self); | 155 | ret = otg_set_host(phy->otg, &hcd->self); |
156 | if (ret < 0) { | 156 | if (ret < 0) { |
157 | dev_err(&pdev->dev, "unable to register with transceiver\n"); | 157 | dev_err(&pdev->dev, "unable to register with transceiver\n"); |
158 | goto put_transceiver; | 158 | goto put_hcd; |
159 | } | 159 | } |
160 | 160 | ||
161 | device_init_wakeup(&pdev->dev, 1); | 161 | device_init_wakeup(&pdev->dev, 1); |
@@ -168,10 +168,6 @@ static int ehci_msm_probe(struct platform_device *pdev) | |||
168 | 168 | ||
169 | return 0; | 169 | return 0; |
170 | 170 | ||
171 | put_transceiver: | ||
172 | usb_put_phy(phy); | ||
173 | unmap: | ||
174 | iounmap(hcd->regs); | ||
175 | put_hcd: | 171 | put_hcd: |
176 | usb_put_hcd(hcd); | 172 | usb_put_hcd(hcd); |
177 | 173 | ||
@@ -187,7 +183,6 @@ static int __devexit ehci_msm_remove(struct platform_device *pdev) | |||
187 | pm_runtime_set_suspended(&pdev->dev); | 183 | pm_runtime_set_suspended(&pdev->dev); |
188 | 184 | ||
189 | otg_set_host(phy->otg, NULL); | 185 | otg_set_host(phy->otg, NULL); |
190 | usb_put_phy(phy); | ||
191 | 186 | ||
192 | usb_put_hcd(hcd); | 187 | usb_put_hcd(hcd); |
193 | 188 | ||