diff options
Diffstat (limited to 'drivers/rtc/rtc-mxc.c')
| -rw-r--r-- | drivers/rtc/rtc-mxc.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c index 8710f9415d98..d71fe61db1d6 100644 --- a/drivers/rtc/rtc-mxc.c +++ b/drivers/rtc/rtc-mxc.c | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include <linux/io.h> | 12 | #include <linux/io.h> |
| 13 | #include <linux/rtc.h> | 13 | #include <linux/rtc.h> |
| 14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
| 15 | #include <linux/slab.h> | ||
| 15 | #include <linux/interrupt.h> | 16 | #include <linux/interrupt.h> |
| 16 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
| 17 | #include <linux/clk.h> | 18 | #include <linux/clk.h> |
| @@ -383,21 +384,26 @@ static int __init mxc_rtc_probe(struct platform_device *pdev) | |||
| 383 | struct rtc_device *rtc; | 384 | struct rtc_device *rtc; |
| 384 | struct rtc_plat_data *pdata = NULL; | 385 | struct rtc_plat_data *pdata = NULL; |
| 385 | u32 reg; | 386 | u32 reg; |
| 386 | int ret, rate; | 387 | unsigned long rate; |
| 388 | int ret; | ||
| 387 | 389 | ||
| 388 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 390 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 389 | if (!res) | 391 | if (!res) |
| 390 | return -ENODEV; | 392 | return -ENODEV; |
| 391 | 393 | ||
| 392 | pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); | 394 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); |
| 393 | if (!pdata) | 395 | if (!pdata) |
| 394 | return -ENOMEM; | 396 | return -ENOMEM; |
| 395 | 397 | ||
| 396 | pdata->ioaddr = ioremap(res->start, resource_size(res)); | 398 | if (!devm_request_mem_region(&pdev->dev, res->start, |
| 399 | resource_size(res), pdev->name)) | ||
| 400 | return -EBUSY; | ||
| 401 | |||
| 402 | pdata->ioaddr = devm_ioremap(&pdev->dev, res->start, | ||
| 403 | resource_size(res)); | ||
| 397 | 404 | ||
| 398 | clk = clk_get(&pdev->dev, "ckil"); | 405 | clk = clk_get(&pdev->dev, "ckil"); |
| 399 | if (IS_ERR(clk)) { | 406 | if (IS_ERR(clk)) { |
| 400 | iounmap(pdata->ioaddr); | ||
| 401 | ret = PTR_ERR(clk); | 407 | ret = PTR_ERR(clk); |
| 402 | goto exit_free_pdata; | 408 | goto exit_free_pdata; |
| 403 | } | 409 | } |
| @@ -412,8 +418,7 @@ static int __init mxc_rtc_probe(struct platform_device *pdev) | |||
| 412 | else if (rate == 38400) | 418 | else if (rate == 38400) |
| 413 | reg = RTC_INPUT_CLK_38400HZ; | 419 | reg = RTC_INPUT_CLK_38400HZ; |
| 414 | else { | 420 | else { |
| 415 | dev_err(&pdev->dev, "rtc clock is not valid (%lu)\n", | 421 | dev_err(&pdev->dev, "rtc clock is not valid (%lu)\n", rate); |
| 416 | clk_get_rate(clk)); | ||
| 417 | ret = -EINVAL; | 422 | ret = -EINVAL; |
| 418 | goto exit_free_pdata; | 423 | goto exit_free_pdata; |
| 419 | } | 424 | } |
| @@ -449,8 +454,8 @@ static int __init mxc_rtc_probe(struct platform_device *pdev) | |||
| 449 | pdata->irq = platform_get_irq(pdev, 0); | 454 | pdata->irq = platform_get_irq(pdev, 0); |
| 450 | 455 | ||
| 451 | if (pdata->irq >= 0 && | 456 | if (pdata->irq >= 0 && |
| 452 | request_irq(pdata->irq, mxc_rtc_interrupt, IRQF_SHARED, | 457 | devm_request_irq(&pdev->dev, pdata->irq, mxc_rtc_interrupt, |
| 453 | pdev->name, pdev) < 0) { | 458 | IRQF_SHARED, pdev->name, pdev) < 0) { |
| 454 | dev_warn(&pdev->dev, "interrupt not available.\n"); | 459 | dev_warn(&pdev->dev, "interrupt not available.\n"); |
| 455 | pdata->irq = -1; | 460 | pdata->irq = -1; |
| 456 | } | 461 | } |
| @@ -458,10 +463,10 @@ static int __init mxc_rtc_probe(struct platform_device *pdev) | |||
| 458 | return 0; | 463 | return 0; |
| 459 | 464 | ||
| 460 | exit_put_clk: | 465 | exit_put_clk: |
| 466 | clk_disable(pdata->clk); | ||
| 461 | clk_put(pdata->clk); | 467 | clk_put(pdata->clk); |
| 462 | 468 | ||
| 463 | exit_free_pdata: | 469 | exit_free_pdata: |
| 464 | kfree(pdata); | ||
| 465 | 470 | ||
| 466 | return ret; | 471 | return ret; |
| 467 | } | 472 | } |
| @@ -472,12 +477,8 @@ static int __exit mxc_rtc_remove(struct platform_device *pdev) | |||
| 472 | 477 | ||
| 473 | rtc_device_unregister(pdata->rtc); | 478 | rtc_device_unregister(pdata->rtc); |
| 474 | 479 | ||
| 475 | if (pdata->irq >= 0) | ||
| 476 | free_irq(pdata->irq, pdev); | ||
| 477 | |||
| 478 | clk_disable(pdata->clk); | 480 | clk_disable(pdata->clk); |
| 479 | clk_put(pdata->clk); | 481 | clk_put(pdata->clk); |
| 480 | kfree(pdata); | ||
| 481 | platform_set_drvdata(pdev, NULL); | 482 | platform_set_drvdata(pdev, NULL); |
| 482 | 483 | ||
| 483 | return 0; | 484 | return 0; |
