diff mbox

rtc: ds1307: Register offset moved to chip description

Message ID 1340749442.3241.4046.camel@pc786-ubu.gnet.global.vpn
State Rejected
Headers show

Commit Message

Austin Boyle June 26, 2012, 10:24 p.m. UTC
rtc: ds1307: Register offset moved to chip description

From: Austin Boyle <Austin.Boyle@aviatnet.com>

Register offset is added to chip description instead of being hard-coded
into probe function.

Based on v3.5-rc4

Cc: Wolfram Sang <w.sang@pengutronix.de>
Cc: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Austin Boyle <Austin.Boyle@aviatnet.com>

---

Comments

Wolfram Sang June 27, 2012, 1:33 p.m. UTC | #1
On Wed, Jun 27, 2012 at 10:24:02AM +1200, Austin Boyle wrote:
> rtc: ds1307: Register offset moved to chip description
> 
> From: Austin Boyle <Austin.Boyle@aviatnet.com>
> 
> Register offset is added to chip description instead of being hard-coded
> into probe function.
> 
> Based on v3.5-rc4
> 
> Cc: Wolfram Sang <w.sang@pengutronix.de>
> Cc: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
> Cc: Alessandro Zummo <a.zummo@towertech.it>
> Signed-off-by: Austin Boyle <Austin.Boyle@aviatnet.com>

I would ack this patch immediately if it added another type using this
feature. But only changing already working code doesn't seem necessary
to me.

Regards,

    Wolfram
Joakim Tjernlund June 27, 2012, 1:42 p.m. UTC | #2
> 
> On Wed, Jun 27, 2012 at 10:24:02AM +1200, Austin Boyle wrote:
> > rtc: ds1307: Register offset moved to chip description
> > 
> > From: Austin Boyle <Austin.Boyle@aviatnet.com>
> > 
> > Register offset is added to chip description instead of being hard-coded
> > into probe function.
> > 
> > Based on v3.5-rc4
> > 
> > Cc: Wolfram Sang <w.sang@pengutronix.de>
> > Cc: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
> > Cc: Alessandro Zummo <a.zummo@towertech.it>
> > Signed-off-by: Austin Boyle <Austin.Boyle@aviatnet.com>
> 
> I would ack this patch immediately if it added another type using this
> feature. But only changing already working code doesn't seem necessary
> to me.
> 
> Regards,
> 
>     Wolfram
> 

That was my gut feeling too.

  Jocke
diff mbox

Patch

diff --git a/a/drivers/rtc/rtc-ds1307.c b/b/drivers/rtc/rtc-ds1307.c
index 836710c..abf837b 100644
--- a/a/drivers/rtc/rtc-ds1307.c
+++ b/b/drivers/rtc/rtc-ds1307.c
@@ -122,6 +122,7 @@  struct ds1307 {
 
 struct chip_desc {
 	unsigned		alarm:1;
+	u8			offset;
 	u16			nvram_offset;
 	u16			nvram_size;
 	u16			trickle_charger_reg;
@@ -149,6 +150,9 @@  static const struct chip_desc chips[last_ds_type] = {
 	[ds_1388] = {
 		.trickle_charger_reg = 0x0a,
 	},
+	[ds_1388] = {
+		.offset		= 1, /* seconds field starts at 1 */
+	},
 	[ds_3231] = {
 		.alarm		= 1,
 	},
@@ -646,6 +650,7 @@  static int __devinit ds1307_probe(struct i2c_client *client,
 
 	ds1307->client	= client;
 	ds1307->type	= id->driver_data;
+	ds1307->offset	= chip->offset;
 
 	if (pdata && pdata->trickle_charger_setup && chip->trickle_charger_reg)
 		i2c_smbus_write_byte_data(client, chip->trickle_charger_reg,
@@ -768,9 +773,6 @@  static int __devinit ds1307_probe(struct i2c_client *client,
 						  hour);
 		}
 		break;
-	case ds_1388:
-		ds1307->offset = 1; /* Seconds starts at 1 */
-		break;
 	default:
 		break;
 	}