Received: from milmhbs0.lsil.com (147.145.1.30) by coscas01.lsi.com
 (172.21.36.60) with Microsoft SMTP Server id 8.1.393.1; Wed, 23 Sep 2009
 01:10:08 -0600
Received: from exch1.onstor.com ([10.0.0.225])	by milmhbs0.lsil.com
 (8.12.11/8.12.11) with ESMTP id n8N7ADcL010675	for <andy.sharp@lsi.com>; Wed,
 23 Sep 2009 00:10:13 -0700
Received: from mail.onstor.com (66.201.51.107) by exch1.onstor.net
 (10.0.0.225) with Microsoft SMTP Server id 8.1.358.0; Wed, 23 Sep 2009
 00:10:07 -0700
Received: from psmtp.com ([64.18.0.47]) by mail.onstor.com with Microsoft
 SMTPSVC(6.0.3790.3959);	 Wed, 23 Sep 2009 00:10:06 -0700
Received: from source ([80.232.32.139]) (using TLSv1) by
 exprod5mx252.postini.com ([64.18.4.13]) with SMTP;	Wed, 23 Sep 2009 00:10:07
 PDT
Received: from hcegtvedt.norway.atmel.com (dhcp-252-083.norway.atmel.com
 [10.191.252.83])	by relay.atmel.no (8.13.4/8.13.4) with ESMTP id
 n8N77pU3022193;	Wed, 23 Sep 2009 09:07:51 +0200 (CEST)	(envelope-from
 hans-christian.egtvedt@atmel.com)
From: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
To: Alessandro Zummo <alessandro.zummo@towertech.it>
CC: Andrew Morton <akpm@linux-foundation.org>, Hans-Christian Egtvedt
	<hcegtvedt@atmel.com>, Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Andrew Sharp <andy.sharp@onstor.com>, Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	Alexander Bigga <ab@mycable.de>, Mark Zhan <rongkai.zhan@windriver.com>,
	Thomas Hommel <thomas.hommel@gefanuc.com>, Paul Mundt <lethal@linux-sh.org>,
	Raphael Assenat <raph@8d.com>, Russell King <rmk@arm.linux.org.uk>,
	"rtc-linux@googlegroups.com" <rtc-linux@googlegroups.com>
Date: Wed, 23 Sep 2009 01:09:08 -0600
Subject: Re: [PATCH] fix driver data issues in several rtc drivers
Thread-Topic: [PATCH] fix driver data issues in several rtc drivers
Thread-Index: Aco8HOS3VphbnmjNSF2lvZNd1Gs9aA==
Message-ID: <20090923090908.7347fdf4@hcegtvedt.norway.atmel.com>
References: <20090922223610.1195b9ab@i1501.lan.towertech.it>
In-Reply-To: <20090922223610.1195b9ab@i1501.lan.towertech.it>
Accept-Language: en-US
Content-Language: en-US
X-MS-Exchange-Organization-AuthAs: Anonymous
X-MS-Exchange-Organization-AuthSource: coscas01.lsi.com
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-originalarrivaltime: 23 Sep 2009 07:10:06.0850 (UTC)
 FILETIME=[E133CE20:01CA3C1C]
x-scanned-by: MIMEDefang 2.39
x-pstn-neptune: 1/1/1.00/74
x-pstn-levels: (S:98.96219/99.90000 CV:99.9000 FC:95.5390 LC:95.5390
 R:95.9108 P:95.9108 M:97.0282 C:98.6951 )
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

On Tue, 22 Sep 2009 22:36:10 +0200
Alessandro Zummo <alessandro.zummo@towertech.it> wrote:

>=20
>  Herton Ronaldo Krzesinski recently raised up, and fixed,
>  an issue with the rtc_cmos driver, which was referring
>  to an inconsistent driver data.
>=20
>  I have checked every single driver and fixed similar
>  bugs. Driver authors are advised to verify my corrections.
>

Thanks for the fix for at32ap700x rtc, I've modified it a bit to also
include a quick cleanup if a later call fails.

>  While the bug it's not easy to trigger, it would be fine
>  if we can get this fix in the kernel asap. The patch is against
>  latest git.
>=20
>  Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>

<snipp diff>

From 42d244ca330c2f2e1e20407ea9d9212c78e05a83 Mon Sep 17 00:00:00 2001
From: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
Date: Wed, 23 Sep 2009 09:03:17 +0200
Subject: [PATCH 1/1] fix driver data issues in at32ap700x rtc driver

Register the rtc struct in platform driver data before registering the rtc.

Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
---
 drivers/rtc/rtc-at32ap700x.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/rtc/rtc-at32ap700x.c b/drivers/rtc/rtc-at32ap700x.c
index e1ec33e..8825695 100644
--- a/drivers/rtc/rtc-at32ap700x.c
+++ b/drivers/rtc/rtc-at32ap700x.c
@@ -256,6 +256,8 @@ static int __init at32_rtc_probe(struct platform_device=
 *pdev)
 		goto out_iounmap;
 	}
=20
+	platform_set_drvdata(pdev, rtc);
+
 	rtc->rtc =3D rtc_device_register(pdev->name, &pdev->dev,
 				&at32_rtc_ops, THIS_MODULE);
 	if (IS_ERR(rtc->rtc)) {
@@ -264,7 +266,6 @@ static int __init at32_rtc_probe(struct platform_device=
 *pdev)
 		goto out_free_irq;
 	}
=20
-	platform_set_drvdata(pdev, rtc);
 	device_init_wakeup(&pdev->dev, 1);
=20
 	dev_info(&pdev->dev, "Atmel RTC for AT32AP700x at %08lx irq %ld\n",
@@ -273,6 +274,7 @@ static int __init at32_rtc_probe(struct platform_device=
 *pdev)
 	return 0;
=20
 out_free_irq:
+	platform_set_drvdata(pdev, NULL);
 	free_irq(irq, rtc);
 out_iounmap:
 	iounmap(rtc->regs);
--=20
1.6.0.4

--=20
Best regards,
Hans-Christian Egtvedt
