aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/i2c-core.c64
1 files changed, 20 insertions, 44 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index ecf43b13fefc..f50342832d95 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -611,27 +611,16 @@ int i2c_master_send(struct i2c_client *client,const char *buf ,int count)
611 struct i2c_adapter *adap=client->adapter; 611 struct i2c_adapter *adap=client->adapter;
612 struct i2c_msg msg; 612 struct i2c_msg msg;
613 613
614 if (client->adapter->algo->master_xfer) { 614 msg.addr = client->addr;
615 msg.addr = client->addr; 615 msg.flags = client->flags & I2C_M_TEN;
616 msg.flags = client->flags & I2C_M_TEN; 616 msg.len = count;
617 msg.len = count; 617 msg.buf = (char *)buf;
618 msg.buf = (char *)buf;
619 618
620 dev_dbg(&client->adapter->dev, "master_send: writing %d bytes.\n", 619 ret = i2c_transfer(adap, &msg, 1);
621 count);
622
623 down(&adap->bus_lock);
624 ret = adap->algo->master_xfer(adap,&msg,1);
625 up(&adap->bus_lock);
626 620
627 /* if everything went ok (i.e. 1 msg transmitted), return #bytes 621 /* If everything went ok (i.e. 1 msg transmitted), return #bytes
628 * transmitted, else error code. 622 transmitted, else error code. */
629 */ 623 return (ret == 1) ? count : ret;
630 return (ret == 1 )? count : ret;
631 } else {
632 dev_err(&client->adapter->dev, "I2C level transfers not supported\n");
633 return -ENOSYS;
634 }
635} 624}
636 625
637int i2c_master_recv(struct i2c_client *client, char *buf ,int count) 626int i2c_master_recv(struct i2c_client *client, char *buf ,int count)
@@ -639,31 +628,18 @@ int i2c_master_recv(struct i2c_client *client, char *buf ,int count)
639 struct i2c_adapter *adap=client->adapter; 628 struct i2c_adapter *adap=client->adapter;
640 struct i2c_msg msg; 629 struct i2c_msg msg;
641 int ret; 630 int ret;
642 if (client->adapter->algo->master_xfer) { 631
643 msg.addr = client->addr; 632 msg.addr = client->addr;
644 msg.flags = client->flags & I2C_M_TEN; 633 msg.flags = client->flags & I2C_M_TEN;
645 msg.flags |= I2C_M_RD; 634 msg.flags |= I2C_M_RD;
646 msg.len = count; 635 msg.len = count;
647 msg.buf = buf; 636 msg.buf = buf;
648 637
649 dev_dbg(&client->adapter->dev, "master_recv: reading %d bytes.\n", 638 ret = i2c_transfer(adap, &msg, 1);
650 count); 639
651 640 /* If everything went ok (i.e. 1 msg transmitted), return #bytes
652 down(&adap->bus_lock); 641 transmitted, else error code. */
653 ret = adap->algo->master_xfer(adap,&msg,1); 642 return (ret == 1) ? count : ret;
654 up(&adap->bus_lock);
655
656 dev_dbg(&client->adapter->dev, "master_recv: return:%d (count:%d, addr:0x%02x)\n",
657 ret, count, client->addr);
658
659 /* if everything went ok (i.e. 1 msg transmitted), return #bytes
660 * transmitted, else error code.
661 */
662 return (ret == 1 )? count : ret;
663 } else {
664 dev_err(&client->adapter->dev, "I2C level transfers not supported\n");
665 return -ENOSYS;
666 }
667} 643}
668 644
669 645