Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 83542
b: refs/heads/master
c: fcd8db0
h: refs/heads/master
v: v3
  • Loading branch information
frederic Rodo authored and Linus Torvalds committed Feb 6, 2008
1 parent 1898bc5 commit a620f0f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 75b6102257874a4ea796af686de2f72cfa0452f9
refs/heads/master: fcd8db002f784706e9aa190d0b6350f868e61c32
27 changes: 20 additions & 7 deletions trunk/drivers/rtc/rtc-ds1307.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ ds1307_nvram_read(struct kobject *kobj, struct bin_attribute *attr,
struct i2c_msg msg[2];
int result;

client = to_i2c_client(container_of(kobj, struct device, kobj));
client = kobj_to_i2c_client(kobj);
ds1307 = i2c_get_clientdata(client);

if (unlikely(off >= NVRAM_SIZE))
Expand Down Expand Up @@ -294,7 +294,7 @@ ds1307_nvram_write(struct kobject *kobj, struct bin_attribute *attr,
u8 buffer[NVRAM_SIZE + 1];
int ret;

client = to_i2c_client(container_of(kobj, struct device, kobj));
client = kobj_to_i2c_client(kobj);

if (unlikely(off >= NVRAM_SIZE))
return -EFBIG;
Expand Down Expand Up @@ -412,11 +412,6 @@ static int __devinit ds1307_probe(struct i2c_client *client)
*/
tmp = ds1307->regs[DS1307_REG_SECS];
switch (ds1307->type) {
case ds_1340:
/* FIXME read register with DS1340_BIT_OSF, use that to
* trigger the "set time" warning (*after* restarting the
* oscillator!) instead of this weaker ds1307/m41t00 test.
*/
case ds_1307:
case m41t00:
/* clock halted? turn it on, so clock can tick. */
Expand All @@ -440,6 +435,24 @@ static int __devinit ds1307_probe(struct i2c_client *client)
goto read_rtc;
}
break;
case ds_1340:
/* clock halted? turn it on, so clock can tick. */
if (tmp & DS1340_BIT_nEOSC)
i2c_smbus_write_byte_data(client, DS1307_REG_SECS, 0);

tmp = i2c_smbus_read_byte_data(client, DS1340_REG_FLAG);
if (tmp < 0) {
pr_debug("read error %d\n", tmp);
err = -EIO;
goto exit_free;
}

/* oscillator fault? clear flag, and warn */
if (tmp & DS1340_BIT_OSF) {
i2c_smbus_write_byte_data(client, DS1340_REG_FLAG, 0);
dev_warn(&client->dev, "SET TIME!\n");
}
break;
case ds_1337:
case ds_1339:
break;
Expand Down

0 comments on commit a620f0f

Please sign in to comment.