rtc-pcf8583.c (c1f3ee120bb61045b1c0a3ead620d1d65af47130) rtc-pcf8583.c (037e291cc77a4beb0379a8c74e3d82e49a476b84)
1/*
2 * drivers/rtc/rtc-pcf8583.c
3 *
4 * Copyright (C) 2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.

--- 149 unchanged lines hidden (view full) ---

158
159 addr[0] = mem->loc;
160
161 return i2c_transfer(client->adapter, msgs, 2) == 2 ? 0 : -EIO;
162}
163
164static int pcf8583_write_mem(struct i2c_client *client, struct rtc_mem *mem)
165{
1/*
2 * drivers/rtc/rtc-pcf8583.c
3 *
4 * Copyright (C) 2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.

--- 149 unchanged lines hidden (view full) ---

158
159 addr[0] = mem->loc;
160
161 return i2c_transfer(client->adapter, msgs, 2) == 2 ? 0 : -EIO;
162}
163
164static int pcf8583_write_mem(struct i2c_client *client, struct rtc_mem *mem)
165{
166 unsigned char addr[1];
167 struct i2c_msg msgs[2] = {
168 {
169 .addr = client->addr,
170 .flags = 0,
171 .len = 1,
172 .buf = addr,
173 }, {
174 .addr = client->addr,
175 .flags = I2C_M_NOSTART,
176 .len = mem->nr,
177 .buf = mem->data,
178 }
179 };
166 unsigned char buf[9];
167 int ret;
180
168
181 if (mem->loc < 8)
169 if (mem->loc < 8 || mem->nr > 8)
182 return -EINVAL;
183
170 return -EINVAL;
171
184 addr[0] = mem->loc;
172 buf[0] = mem->loc;
173 memcpy(buf + 1, mem->data, mem->nr);
185
174
186 return i2c_transfer(client->adapter, msgs, 2) == 2 ? 0 : -EIO;
175 ret = i2c_master_send(client, buf, mem->nr + 1);
176 return ret == mem->nr + 1 ? 0 : -EIO;
187}
188
189static int pcf8583_rtc_read_time(struct device *dev, struct rtc_time *tm)
190{
191 struct i2c_client *client = to_i2c_client(dev);
192 unsigned char ctrl, year[2];
193 struct rtc_mem mem = { CMOS_YEAR, sizeof(year), year };
194 int real_year, year_offset, err;

--- 204 unchanged lines hidden ---
177}
178
179static int pcf8583_rtc_read_time(struct device *dev, struct rtc_time *tm)
180{
181 struct i2c_client *client = to_i2c_client(dev);
182 unsigned char ctrl, year[2];
183 struct rtc_mem mem = { CMOS_YEAR, sizeof(year), year };
184 int real_year, year_offset, err;

--- 204 unchanged lines hidden ---