diff options
author | Jingoo Han <jg1.han@samsung.com> | 2013-04-29 19:20:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 21:28:37 -0400 |
commit | c40dcf6e8ce477ba8c1c21b949b28e03b1700902 (patch) | |
tree | ab06854ec7bc18cf3913f3a2414ea173dccc1492 /drivers/rtc/rtc-msm6242.c | |
parent | a379fd2458d78d3286c8103aa479839b073c89fe (diff) |
rtc: rtc-msm6242: use devm_*() functions
Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-msm6242.c')
-rw-r--r-- | drivers/rtc/rtc-msm6242.c | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/drivers/rtc/rtc-msm6242.c b/drivers/rtc/rtc-msm6242.c index 3ac1e8eca89d..771f86a05d14 100644 --- a/drivers/rtc/rtc-msm6242.c +++ b/drivers/rtc/rtc-msm6242.c | |||
@@ -194,30 +194,28 @@ static const struct rtc_class_ops msm6242_rtc_ops = { | |||
194 | .set_time = msm6242_set_time, | 194 | .set_time = msm6242_set_time, |
195 | }; | 195 | }; |
196 | 196 | ||
197 | static int __init msm6242_rtc_probe(struct platform_device *dev) | 197 | static int __init msm6242_rtc_probe(struct platform_device *pdev) |
198 | { | 198 | { |
199 | struct resource *res; | 199 | struct resource *res; |
200 | struct msm6242_priv *priv; | 200 | struct msm6242_priv *priv; |
201 | struct rtc_device *rtc; | 201 | struct rtc_device *rtc; |
202 | int error; | 202 | int error; |
203 | 203 | ||
204 | res = platform_get_resource(dev, IORESOURCE_MEM, 0); | 204 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
205 | if (!res) | 205 | if (!res) |
206 | return -ENODEV; | 206 | return -ENODEV; |
207 | 207 | ||
208 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | 208 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); |
209 | if (!priv) | 209 | if (!priv) |
210 | return -ENOMEM; | 210 | return -ENOMEM; |
211 | 211 | ||
212 | priv->regs = ioremap(res->start, resource_size(res)); | 212 | priv->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res)); |
213 | if (!priv->regs) { | 213 | if (!priv->regs) |
214 | error = -ENOMEM; | 214 | return -ENOMEM; |
215 | goto out_free_priv; | 215 | platform_set_drvdata(pdev, priv); |
216 | } | ||
217 | platform_set_drvdata(dev, priv); | ||
218 | 216 | ||
219 | rtc = rtc_device_register("rtc-msm6242", &dev->dev, &msm6242_rtc_ops, | 217 | rtc = devm_rtc_device_register(&pdev->dev, "rtc-msm6242", |
220 | THIS_MODULE); | 218 | &msm6242_rtc_ops, THIS_MODULE); |
221 | if (IS_ERR(rtc)) { | 219 | if (IS_ERR(rtc)) { |
222 | error = PTR_ERR(rtc); | 220 | error = PTR_ERR(rtc); |
223 | goto out_unmap; | 221 | goto out_unmap; |
@@ -227,20 +225,12 @@ static int __init msm6242_rtc_probe(struct platform_device *dev) | |||
227 | return 0; | 225 | return 0; |
228 | 226 | ||
229 | out_unmap: | 227 | out_unmap: |
230 | platform_set_drvdata(dev, NULL); | 228 | platform_set_drvdata(pdev, NULL); |
231 | iounmap(priv->regs); | ||
232 | out_free_priv: | ||
233 | kfree(priv); | ||
234 | return error; | 229 | return error; |
235 | } | 230 | } |
236 | 231 | ||
237 | static int __exit msm6242_rtc_remove(struct platform_device *dev) | 232 | static int __exit msm6242_rtc_remove(struct platform_device *pdev) |
238 | { | 233 | { |
239 | struct msm6242_priv *priv = platform_get_drvdata(dev); | ||
240 | |||
241 | rtc_device_unregister(priv->rtc); | ||
242 | iounmap(priv->regs); | ||
243 | kfree(priv); | ||
244 | return 0; | 234 | return 0; |
245 | } | 235 | } |
246 | 236 | ||