|
@@ -79,7 +79,7 @@ static int ds13307_write_bytes(struct i2c_client *client,
|
|
|
memmove(buf + 1, bytes, length);
|
|
|
msg.addr = client->addr;
|
|
|
msg.len = length + 1;
|
|
|
- msg.buf = addr;
|
|
|
+ msg.buf = buf;
|
|
|
r = i2c_transfer(client->adapter, &msg, 1);
|
|
|
kfree(buf);
|
|
|
if (r == 1) {
|
|
@@ -232,7 +232,12 @@ static int ds13307_nvram_read(void *priv, unsigned int offset, void *buf, size_t
|
|
|
}
|
|
|
|
|
|
static int ds13307_nvram_write(void *priv, unsigned int offset, void *buf, size_t count) {
|
|
|
- return 0;
|
|
|
+ struct i2c_client *client = priv;
|
|
|
+ u8 addr = DS1307_NVRAM_BASE + offset;
|
|
|
+ if (!ds13307_write_bytes(client, &addr, buf, count)) {
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+ return -EIO;
|
|
|
}
|
|
|
|
|
|
static int ds13307_probe(struct i2c_client *client,
|
|
@@ -252,6 +257,7 @@ static int ds13307_probe(struct i2c_client *client,
|
|
|
ds1307_nvmem.word_size = 1;
|
|
|
ds1307_nvmem.size = 56;
|
|
|
ds1307_nvmem.reg_read = ds13307_nvram_read;
|
|
|
+ ds1307_nvmem.reg_write = ds13307_nvram_write;
|
|
|
ds1307_nvmem.priv = client;
|
|
|
rtc->nvmem_config = &ds1307_nvmem;
|
|
|
}
|