From: Andrew Morton <akpm@linux-foundation.org>
To: Sergey Yanovich <ynvich@gmail.com>
Cc: rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org,
Marc Zyngier <maz@misterjones.org>,
Alessandro Zummo <a.zummo@towertech.it>,
Sachin Kamat <sachin.kamat@linaro.org>,
Jingoo Han <jg1.han@samsung.com>
Subject: Re: [PATCH] rtc-ds1302: handle write protection
Date: Wed, 29 May 2013 15:53:11 -0700 [thread overview]
Message-ID: <20130529155311.9e35e847968f3923bc83f4cd@linux-foundation.org> (raw)
In-Reply-To: <1369092090-5384-1-git-send-email-ynvich@gmail.com>
On Tue, 21 May 2013 03:21:30 +0400 Sergey Yanovich <ynvich@gmail.com> wrote:
> This chip has a control register and can prevent altering saved clock.
> Without this patch we could have:
> ----8<----
> (arm)root@pac14:~# date
> Tue May 21 03:08:27 MSK 2013
> (arm)root@pac14:~# /etc/init.d/hwclock.sh show
> Tue May 21 11:13:58 2013 -0.067322 seconds
> (arm)root@pac14:~# /etc/init.d/hwclock.sh stop
> [info] Saving the system clock.
> [info] Hardware Clock updated to Tue May 21 03:09:01 MSK 2013.
> (arm)root@pac14:~# /etc/init.d/hwclock.sh show
> Tue May 21 11:14:15 2013 -0.624272 seconds
> ----8<----
>
> ...
>
> --- a/drivers/rtc/rtc-ds1302.c
> +++ b/drivers/rtc/rtc-ds1302.c
> @@ -23,8 +23,12 @@
> #define RTC_CMD_READ 0x81 /* Read command */
> #define RTC_CMD_WRITE 0x80 /* Write command */
>
> +#define RTC_CMD_WRITE_ENABLE 0x00 /* Write enable */
> +#define RTC_CMD_WRITE_DISABLE 0x80 /* Write disable */
> +
> #define RTC_ADDR_RAM0 0x20 /* Address of RAM0 */
> #define RTC_ADDR_TCR 0x08 /* Address of trickle charge register */
> +#define RTC_ADDR_CTRL 0x07 /* Address of control register */
> #define RTC_ADDR_YEAR 0x06 /* Address of year register */
> #define RTC_ADDR_DAY 0x05 /* Address of day of week register */
> #define RTC_ADDR_MON 0x04 /* Address of month register */
> @@ -313,6 +317,7 @@ static int __init ds1302_rtc_probe(struct platform_device *pdev)
> return PTR_ERR(rtc);
>
> platform_set_drvdata(pdev, rtc);
> + ds1302_writebyte(RTC_ADDR_CTRL, RTC_CMD_WRITE_ENABLE);
>
> return 0;
> }
> @@ -321,6 +326,7 @@ static int ds1302_rtc_remove(struct platform_device *pdev)
> {
> struct rtc_device *rtc = platform_get_drvdata(pdev);
>
> + ds1302_writebyte(RTC_ADDR_CTRL, RTC_CMD_WRITE_DISABLE);
> rtc_device_unregister(rtc);
> platform_set_drvdata(pdev, NULL);
ds1302_rtc_remove() no longer exists in my tree - it got whittled away
to nothing by
http://ozlabs.org/~akpm/mmots/broken-out/rtc-rtc-ds1302-remove-unnecessary-platform_set_drvdata.patch
and
http://ozlabs.org/~akpm/mmots/broken-out/drivers-rtc-rtc-ds1302c-remove-empty-function.patch
Perhaps it should be re-added for this?
next prev parent reply other threads:[~2013-05-29 22:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-20 23:21 Sergey Yanovich
2013-05-29 22:53 ` Andrew Morton [this message]
2013-05-30 10:14 ` Sergey Yanovich
2013-05-30 10:20 ` Marc Zyngier
2013-05-30 16:04 ` Sergey Yanovich
2013-05-31 12:48 ` Marc Zyngier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130529155311.9e35e847968f3923bc83f4cd@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=a.zummo@towertech.it \
--cc=jg1.han@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@misterjones.org \
--cc=rtc-linux@googlegroups.com \
--cc=sachin.kamat@linaro.org \
--cc=ynvich@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®