rtc/at91sam9: use ioremap and iounmap

Submitted by Jean-Christophe PLAGNIOL-VILLARD on Dec. 8, 2011, 3:40 p.m.

Details

Message ID 1323358829-22132-1-git-send-email-plagnioj@jcrosoft.com
State Superseded
Headers show

Commit Message

Jean-Christophe PLAGNIOL-VILLARD Dec. 8, 2011, 3:40 p.m.
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 drivers/rtc/rtc-at91sam9.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

Comments

Andrew Morton Dec. 17, 2011, 12:44 a.m.
On Thu,  8 Dec 2011 16:40:29 +0100
Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote:

> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>

Please always write chagnelogs for your patches.

The changelog for this patch should briefly describe the change and then
should exhaustively describe the reasons for making the change.

As it stands, I don't know if this is a little cleanup or if it fixes a
tremendous instantaneous kernel crash.  I and others will want to know
this information, so please provide it.
Jean-Christophe PLAGNIOL-VILLARD Dec. 18, 2011, 12:47 p.m.
On 16:44 Fri 16 Dec     , Andrew Morton wrote:
> On Thu,  8 Dec 2011 16:40:29 +0100
> Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote:
> 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> 
> Please always write chagnelogs for your patches.
> 
> The changelog for this patch should briefly describe the change and then
> should exhaustively describe the reasons for making the change.
> 
> As it stands, I don't know if this is a little cleanup or if it fixes a
> tremendous instantaneous kernel crash.  I and others will want to know
> this information, so please provide it.
just a cleanup am currently cleanning up the AT91 to use generic ioremap
and make it soc independant

Best Regards,
J.

Patch hide | download patch | download mbox

diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c
index a3ad957..ee3c122 100644
--- a/drivers/rtc/rtc-at91sam9.c
+++ b/drivers/rtc/rtc-at91sam9.c
@@ -307,8 +307,12 @@  static int __init at91_rtc_probe(struct platform_device *pdev)
 		device_init_wakeup(&pdev->dev, 1);
 
 	platform_set_drvdata(pdev, rtc);
-	rtc->rtt = (void __force __iomem *) (AT91_VA_BASE_SYS - AT91_BASE_SYS);
-	rtc->rtt += r->start;
+	rtc->rtt = ioremap(r->start, resource_size(r));
+	if (!rtc->rtt) {
+		dev_err(&pdev->dev, "failed to map registers, aborting.\n");
+		ret = -ENOMEM;
+		goto fail;
+	}
 
 	mr = rtt_readl(rtc, MR);
 
@@ -326,7 +330,7 @@  static int __init at91_rtc_probe(struct platform_device *pdev)
 				&at91_rtc_ops, THIS_MODULE);
 	if (IS_ERR(rtc->rtcdev)) {
 		ret = PTR_ERR(rtc->rtcdev);
-		goto fail;
+		goto fail_register;
 	}
 
 	/* register irq handler after we know what name we'll use */
@@ -351,6 +355,8 @@  static int __init at91_rtc_probe(struct platform_device *pdev)
 
 	return 0;
 
+fail_register:
+	iounmap(rtc->rtt);
 fail:
 	platform_set_drvdata(pdev, NULL);
 	kfree(rtc);
@@ -371,6 +377,7 @@  static int __exit at91_rtc_remove(struct platform_device *pdev)
 
 	rtc_device_unregister(rtc->rtcdev);
 
+	iounmap(rtc->rtt);
 	platform_set_drvdata(pdev, NULL);
 	kfree(rtc);
 	return 0;