From: 柯飞雄 Date: Mon, 17 May 2010 08:44:06 +0000 (+0000) Subject: change i2c_transfer func X-Git-Tag: firefly_0821_release~11526 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=388f3e70aea2d839b87f55f123c37745c1f5fe97;p=firefly-linux-kernel-4.4.55.git change i2c_transfer func --- diff --git a/drivers/rtc/rtc-HYM8563.c b/drivers/rtc/rtc-HYM8563.c index 1356e748927b..a9434d98e395 100644 --- a/drivers/rtc/rtc-HYM8563.c +++ b/drivers/rtc/rtc-HYM8563.c @@ -29,6 +29,22 @@ static int hym8563_i2c_read_regs(struct i2c_client *client, u8 reg, u8 buf[], unsigned len) { int ret; + struct i2c_adapter *adap = client->adapter; + struct i2c_msg msgs[2]; + msgs[0].addr = client->addr; + msgs[0].buf = ® + msgs[0].flags = client->flags; + msgs[0].len = 1; + msgs[0].scl_rate = 400 * 1000; /* set 400kHz, but real is about 300kHz */ + + msgs[1].buf = buf; + msgs[1].addr = client->addr; + msgs[1].flags = client->flags | I2C_M_RD; + msgs[1].len = len; + msgs[1].scl_rate = 4000 * 1000; + + ret = i2c_transfer(adap, msgs, 2); + /* struct i2c_msg msgs[1] = { { client->addr, 1, len, buf }, }; @@ -40,13 +56,29 @@ static int hym8563_i2c_read_regs(struct i2c_client *client, u8 reg, u8 buf[], un ret = i2c_transfer(client->adapter, msgs, 1); if (ret > 0) ret = 0; - + */ return ret; } static int hym8563_i2c_set_regs(struct i2c_client *client, u8 reg, u8 const buf[], __u16 len) { int ret; + struct i2c_adapter *adap = client->adapter; + struct i2c_msg msg; + char tx_buf[len + 1]; + + tx_buf[0] = reg; + memcpy(tx_buf + 1, buf, len); + + msg.addr = client->addr; + msg.buf = tx_buf; + msg.len = len + 1; + msg.flags = client->flags; + msg.scl_rate = 400 * 1000; + + ret = i2c_transfer(adap, &msg, 1); + + /* u8 i2c_buf[HYM8563_REG_LEN + 1]; struct i2c_msg msgs[1] = { { client->addr, 0, len + 1, i2c_buf } @@ -62,7 +94,7 @@ static int hym8563_i2c_set_regs(struct i2c_client *client, u8 reg, u8 const buf[ ret = i2c_transfer(client->adapter, msgs, 1); if (ret > 0) ret = 0; - + */ return ret; }