From: Wolfram Sang <w.sang@pengutronix.de>
To: Austin Boyle <Austin.Boyle@aviatnet.com>
Cc: rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] rtc: ds1307: generalise ram size and offset
Date: Wed, 11 Jan 2012 12:06:50 +0100 [thread overview]
Message-ID: <20120111110650.GC2605@pengutronix.de> (raw)
In-Reply-To: <1326144071.3096.25.camel@pc786-ubu.gnet.global.vpn>
[-- Attachment #1: Type: text/plain, Size: 2352 bytes --]
Austin,
> --- a/drivers/rtc/rtc-ds1307.c 2011-10-10 11:22:22.674690998 +1300
> +++ b/drivers/rtc/rtc-ds1307.c 2011-11-04 10:02:27.859155009 +1300
> @@ -104,6 +104,8 @@ enum ds_type {
>
> struct ds1307 {
> u8 offset; /* register's offset */
> + u16 nvram_offset;
> + u16 nvram_size;
I'd put them further down in the struct, at least after regs.
> u8 regs[11];
> enum ds_type type;
> unsigned long flags;
> @@ -119,26 +121,37 @@ struct ds1307 {
> };
>
> struct chip_desc {
> - unsigned nvram56:1;
> unsigned alarm:1;
> + u8 offset;
I think the stuff related to 'offset' should be in a separate patch with
specific commit-msg.
> + u16 nvram_offset;
> + u16 nvram_size;
> };
>
> static const struct chip_desc chips[last_ds_type] = {
> [ds_1307] = {
> - .nvram56 = 1,
> + .nvram_offset = 8,
> + .nvram_size = 56, /* 56 bytes NVRAM */
Skip the comment, should be obvious.
> },
> [ds_1337] = {
> .alarm = 1,
> },
> [ds_1338] = {
> - .nvram56 = 1,
> + .nvram_offset = 8,
> + .nvram_size = 56, /* 56 bytes NVRAM */
> },
> [ds_1339] = {
> .alarm = 1,
> },
> + [ds_1388] = {
> + .offset = 1, /* seconds starts at 1 */
> + },
> [ds_3231] = {
> .alarm = 1,
> },
> + [mcp7941x] = {
> + .nvram_offset = 0x20,
> + .nvram_size = 64, /* 64 bytes SRAM */
Minor: hex value for size, too? Comment should probably emphasize that
this is SRAM not NVRAM, the size is obvious again.
> + },
> };
>
...
> @@ -638,7 +650,19 @@ static int __devinit ds1307_probe(struct
>
> ds1307->client = client;
> ds1307->type = id->driver_data;
> - ds1307->offset = 0;
> +
> + if (chip && chip->offset)
> + ds1307->offset = chip->offset;
> + else
> + ds1307->offset = 0;
> + if (chip && chip->nvram_size)
> + ds1307->nvram_size = chip->nvram_size;
> + else
> + ds1307->nvram_size = 0;
> + if (chip && chip->nvram_offset)
> + ds1307->nvram_offset = chip->nvram_offset;
> + else
> + ds1307->nvram_offset = 0;
ds1307 is kzalloced, so you can simplify this. Then, you also need to
check only once if chip != NULL.
Regards,
Wolfram
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2012-01-11 11:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-09 21:21 [PATCH v3] rtc: ds1307: generalise ram size and offset Austin Boyle
2012-01-09 22:17 ` Wolfram Sang
2012-01-10 0:33 ` Austin Boyle
2012-01-11 11:06 ` Wolfram Sang [this message]
2012-01-11 22:21 ` Austin Boyle
2012-01-18 21:41 ` Wolfram Sang
2012-01-19 19:45 ` Wolfram Sang
2012-02-02 0:37 ` Austin Boyle
2012-02-02 14:53 ` [rtc-linux] " Wolfram Sang
2012-02-02 22:28 ` Austin Boyle
2012-02-07 14:56 ` Wolfram Sang
2012-02-07 21:45 ` Austin Boyle
2012-02-08 22:23 ` [PATCH v4] " Austin Boyle
2012-02-08 22:36 ` Andrew Morton
2012-02-13 14:36 ` Wolfram Sang
2012-02-14 4:23 ` Austin Boyle
2012-02-21 14:00 ` Wolfram Sang
-- strict thread matches above, loose matches on Subject: below --
2011-11-03 21:07 [PATCH v3] " Austin Boyle
2011-11-03 21:25 ` David Anders
2011-12-19 1:24 ` Austin Boyle
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=20120111110650.GC2605@pengutronix.de \
--to=w.sang@pengutronix.de \
--cc=Austin.Boyle@aviatnet.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rtc-linux@googlegroups.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;
as well as URLs for NNTP newsgroup(s).