aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/i2c/chips/max68752
-rw-r--r--Documentation/i2c/writing-clients2
-rw-r--r--drivers/i2c/busses/i2c-powermac.c3
-rw-r--r--drivers/i2c/busses/i2c-viapro.c2
-rw-r--r--drivers/i2c/busses/scx200_acb.c2
-rw-r--r--drivers/i2c/chips/eeprom.c6
-rw-r--r--drivers/i2c/chips/max6875.c1
-rw-r--r--drivers/i2c/i2c-core.c12
-rw-r--r--drivers/i2c/i2c-dev.c9
-rw-r--r--drivers/macintosh/windfarm_smu_sat.c28
-rw-r--r--include/linux/i2c.h5
11 files changed, 32 insertions, 40 deletions
diff --git a/Documentation/i2c/chips/max6875 b/Documentation/i2c/chips/max6875
index 96fec562a8e9..a0cd8af2f408 100644
--- a/Documentation/i2c/chips/max6875
+++ b/Documentation/i2c/chips/max6875
@@ -99,7 +99,7 @@ And then read the data
99 99
100 or 100 or
101 101
102 count = i2c_smbus_read_i2c_block_data(fd, 0x84, buffer); 102 count = i2c_smbus_read_i2c_block_data(fd, 0x84, 16, buffer);
103 103
104The block read should read 16 bytes. 104The block read should read 16 bytes.
1050x84 is the block read command. 1050x84 is the block read command.
diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients
index 3d8d36b0ad12..2c170032bf37 100644
--- a/Documentation/i2c/writing-clients
+++ b/Documentation/i2c/writing-clients
@@ -571,7 +571,7 @@ SMBus communication
571 u8 command, u8 length, 571 u8 command, u8 length,
572 u8 *values); 572 u8 *values);
573 extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client, 573 extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client,
574 u8 command, u8 *values); 574 u8 command, u8 length, u8 *values);
575 575
576These ones were removed in Linux 2.6.10 because they had no users, but could 576These ones were removed in Linux 2.6.10 because they had no users, but could
577be added back later if needed: 577be added back later if needed:
diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c
index 1425d2245c82..0ab4f2627c26 100644
--- a/drivers/i2c/busses/i2c-powermac.c
+++ b/drivers/i2c/busses/i2c-powermac.c
@@ -121,8 +121,7 @@ static s32 i2c_powermac_smbus_xfer( struct i2c_adapter* adap,
121 if (rc) 121 if (rc)
122 goto bail; 122 goto bail;
123 rc = pmac_i2c_xfer(bus, addrdir, 1, command, 123 rc = pmac_i2c_xfer(bus, addrdir, 1, command,
124 read ? data->block : &data->block[1], 124 &data->block[1], data->block[0]);
125 data->block[0]);
126 break; 125 break;
127 126
128 default: 127 default:
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
index 7a2bc06304fc..a0f7e4a303b5 100644
--- a/drivers/i2c/busses/i2c-viapro.c
+++ b/drivers/i2c/busses/i2c-viapro.c
@@ -235,7 +235,7 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr,
235 if (!(vt596_features & FEATURE_I2CBLOCK)) 235 if (!(vt596_features & FEATURE_I2CBLOCK))
236 goto exit_unsupported; 236 goto exit_unsupported;
237 if (read_write == I2C_SMBUS_READ) 237 if (read_write == I2C_SMBUS_READ)
238 outb_p(I2C_SMBUS_BLOCK_MAX, SMBHSTDAT0); 238 outb_p(data->block[0], SMBHSTDAT0);
239 /* Fall through */ 239 /* Fall through */
240 case I2C_SMBUS_BLOCK_DATA: 240 case I2C_SMBUS_BLOCK_DATA:
241 outb_p(command, SMBHSTCMD); 241 outb_p(command, SMBHSTCMD);
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
index dc64f8b6b24a..e6c4a2b762ec 100644
--- a/drivers/i2c/busses/scx200_acb.c
+++ b/drivers/i2c/busses/scx200_acb.c
@@ -310,8 +310,6 @@ static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter,
310 break; 310 break;
311 311
312 case I2C_SMBUS_I2C_BLOCK_DATA: 312 case I2C_SMBUS_I2C_BLOCK_DATA:
313 if (rw == I2C_SMBUS_READ)
314 data->block[0] = I2C_SMBUS_BLOCK_MAX; /* For now */
315 len = data->block[0]; 313 len = data->block[0];
316 if (len == 0 || len > I2C_SMBUS_BLOCK_MAX) 314 if (len == 0 || len > I2C_SMBUS_BLOCK_MAX)
317 return -EINVAL; 315 return -EINVAL;
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c
index bfce13c8f1ff..48f857ae8748 100644
--- a/drivers/i2c/chips/eeprom.c
+++ b/drivers/i2c/chips/eeprom.c
@@ -88,8 +88,10 @@ static void eeprom_update_client(struct i2c_client *client, u8 slice)
88 dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice); 88 dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice);
89 89
90 if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { 90 if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
91 for (i = slice << 5; i < (slice + 1) << 5; i += I2C_SMBUS_BLOCK_MAX) 91 for (i = slice << 5; i < (slice + 1) << 5; i += 32)
92 if (i2c_smbus_read_i2c_block_data(client, i, data->data + i) != I2C_SMBUS_BLOCK_MAX) 92 if (i2c_smbus_read_i2c_block_data(client, i,
93 32, data->data + i)
94 != 32)
93 goto exit; 95 goto exit;
94 } else { 96 } else {
95 if (i2c_smbus_write_byte(client, slice << 5)) { 97 if (i2c_smbus_write_byte(client, slice << 5)) {
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c
index 76645c142977..e9e9e5171b53 100644
--- a/drivers/i2c/chips/max6875.c
+++ b/drivers/i2c/chips/max6875.c
@@ -106,6 +106,7 @@ static void max6875_update_slice(struct i2c_client *client, int slice)
106 I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { 106 I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
107 if (i2c_smbus_read_i2c_block_data(client, 107 if (i2c_smbus_read_i2c_block_data(client,
108 MAX6875_CMD_BLK_READ, 108 MAX6875_CMD_BLK_READ,
109 SLICE_SIZE,
109 buf) != SLICE_SIZE) { 110 buf) != SLICE_SIZE) {
110 goto exit_up; 111 goto exit_up;
111 } 112 }
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index cccfa8678245..6971a62397db 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1344,10 +1344,14 @@ s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command,
1344EXPORT_SYMBOL(i2c_smbus_write_block_data); 1344EXPORT_SYMBOL(i2c_smbus_write_block_data);
1345 1345
1346/* Returns the number of read bytes */ 1346/* Returns the number of read bytes */
1347s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, u8 *values) 1347s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command,
1348 u8 length, u8 *values)
1348{ 1349{
1349 union i2c_smbus_data data; 1350 union i2c_smbus_data data;
1350 1351
1352 if (length > I2C_SMBUS_BLOCK_MAX)
1353 length = I2C_SMBUS_BLOCK_MAX;
1354 data.block[0] = length;
1351 if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, 1355 if (i2c_smbus_xfer(client->adapter,client->addr,client->flags,
1352 I2C_SMBUS_READ,command, 1356 I2C_SMBUS_READ,command,
1353 I2C_SMBUS_I2C_BLOCK_DATA,&data)) 1357 I2C_SMBUS_I2C_BLOCK_DATA,&data))
@@ -1468,7 +1472,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1468 break; 1472 break;
1469 case I2C_SMBUS_I2C_BLOCK_DATA: 1473 case I2C_SMBUS_I2C_BLOCK_DATA:
1470 if (read_write == I2C_SMBUS_READ) { 1474 if (read_write == I2C_SMBUS_READ) {
1471 msg[1].len = I2C_SMBUS_BLOCK_MAX; 1475 msg[1].len = data->block[0];
1472 } else { 1476 } else {
1473 msg[0].len = data->block[0] + 1; 1477 msg[0].len = data->block[0] + 1;
1474 if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 1) { 1478 if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 1) {
@@ -1524,9 +1528,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1524 data->word = msgbuf1[0] | (msgbuf1[1] << 8); 1528 data->word = msgbuf1[0] | (msgbuf1[1] << 8);
1525 break; 1529 break;
1526 case I2C_SMBUS_I2C_BLOCK_DATA: 1530 case I2C_SMBUS_I2C_BLOCK_DATA:
1527 /* fixed at 32 for now */ 1531 for (i = 0; i < data->block[0]; i++)
1528 data->block[0] = I2C_SMBUS_BLOCK_MAX;
1529 for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++)
1530 data->block[i+1] = msgbuf1[i]; 1532 data->block[i+1] = msgbuf1[i];
1531 break; 1533 break;
1532 case I2C_SMBUS_BLOCK_DATA: 1534 case I2C_SMBUS_BLOCK_DATA:
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index e7a709710592..64eee9551b22 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -283,6 +283,7 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file,
283 (data_arg.size != I2C_SMBUS_WORD_DATA) && 283 (data_arg.size != I2C_SMBUS_WORD_DATA) &&
284 (data_arg.size != I2C_SMBUS_PROC_CALL) && 284 (data_arg.size != I2C_SMBUS_PROC_CALL) &&
285 (data_arg.size != I2C_SMBUS_BLOCK_DATA) && 285 (data_arg.size != I2C_SMBUS_BLOCK_DATA) &&
286 (data_arg.size != I2C_SMBUS_I2C_BLOCK_BROKEN) &&
286 (data_arg.size != I2C_SMBUS_I2C_BLOCK_DATA) && 287 (data_arg.size != I2C_SMBUS_I2C_BLOCK_DATA) &&
287 (data_arg.size != I2C_SMBUS_BLOCK_PROC_CALL)) { 288 (data_arg.size != I2C_SMBUS_BLOCK_PROC_CALL)) {
288 dev_dbg(&client->adapter->dev, 289 dev_dbg(&client->adapter->dev,
@@ -329,10 +330,18 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file,
329 330
330 if ((data_arg.size == I2C_SMBUS_PROC_CALL) || 331 if ((data_arg.size == I2C_SMBUS_PROC_CALL) ||
331 (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) || 332 (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) ||
333 (data_arg.size == I2C_SMBUS_I2C_BLOCK_DATA) ||
332 (data_arg.read_write == I2C_SMBUS_WRITE)) { 334 (data_arg.read_write == I2C_SMBUS_WRITE)) {
333 if (copy_from_user(&temp, data_arg.data, datasize)) 335 if (copy_from_user(&temp, data_arg.data, datasize))
334 return -EFAULT; 336 return -EFAULT;
335 } 337 }
338 if (data_arg.size == I2C_SMBUS_I2C_BLOCK_BROKEN) {
339 /* Convert old I2C block commands to the new
340 convention. This preserves binary compatibility. */
341 data_arg.size = I2C_SMBUS_I2C_BLOCK_DATA;
342 if (data_arg.read_write == I2C_SMBUS_READ)
343 temp.block[0] = I2C_SMBUS_BLOCK_MAX;
344 }
336 res = i2c_smbus_xfer(client->adapter,client->addr,client->flags, 345 res = i2c_smbus_xfer(client->adapter,client->addr,client->flags,
337 data_arg.read_write, 346 data_arg.read_write,
338 data_arg.command,data_arg.size,&temp); 347 data_arg.command,data_arg.size,&temp);
diff --git a/drivers/macintosh/windfarm_smu_sat.c b/drivers/macintosh/windfarm_smu_sat.c
index 1043b39aa123..351982bcec1b 100644
--- a/drivers/macintosh/windfarm_smu_sat.c
+++ b/drivers/macintosh/windfarm_smu_sat.c
@@ -67,26 +67,6 @@ static struct i2c_driver wf_sat_driver = {
67 .detach_client = wf_sat_detach, 67 .detach_client = wf_sat_detach,
68}; 68};
69 69
70/*
71 * XXX i2c_smbus_read_i2c_block_data doesn't pass the requested
72 * length down to the low-level driver, so we use this, which
73 * works well enough with the SMU i2c driver code...
74 */
75static int sat_read_block(struct i2c_client *client, u8 command,
76 u8 *values, int len)
77{
78 union i2c_smbus_data data;
79 int err;
80
81 data.block[0] = len;
82 err = i2c_smbus_xfer(client->adapter, client->addr, client->flags,
83 I2C_SMBUS_READ, command, I2C_SMBUS_I2C_BLOCK_DATA,
84 &data);
85 if (!err)
86 memcpy(values, data.block, len);
87 return err;
88}
89
90struct smu_sdbp_header *smu_sat_get_sdb_partition(unsigned int sat_id, int id, 70struct smu_sdbp_header *smu_sat_get_sdb_partition(unsigned int sat_id, int id,
91 unsigned int *size) 71 unsigned int *size)
92{ 72{
@@ -124,8 +104,8 @@ struct smu_sdbp_header *smu_sat_get_sdb_partition(unsigned int sat_id, int id,
124 return NULL; 104 return NULL;
125 105
126 for (i = 0; i < len; i += 4) { 106 for (i = 0; i < len; i += 4) {
127 err = sat_read_block(&sat->i2c, 0xa, data, 4); 107 err = i2c_smbus_read_i2c_block_data(&sat->i2c, 0xa, 4, data);
128 if (err) { 108 if (err < 0) {
129 printk(KERN_ERR "smu_sat_get_sdb_part rd err %d\n", 109 printk(KERN_ERR "smu_sat_get_sdb_part rd err %d\n",
130 err); 110 err);
131 goto fail; 111 goto fail;
@@ -157,8 +137,8 @@ static int wf_sat_read_cache(struct wf_sat *sat)
157{ 137{
158 int err; 138 int err;
159 139
160 err = sat_read_block(&sat->i2c, 0x3f, sat->cache, 16); 140 err = i2c_smbus_read_i2c_block_data(&sat->i2c, 0x3f, 16, sat->cache);
161 if (err) 141 if (err < 0)
162 return err; 142 return err;
163 sat->last_read = jiffies; 143 sat->last_read = jiffies;
164#ifdef LOTSA_DEBUG 144#ifdef LOTSA_DEBUG
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 44f2ecf47d9f..2eaba21b9b1a 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -90,7 +90,7 @@ extern s32 i2c_smbus_write_block_data(struct i2c_client * client,
90 const u8 *values); 90 const u8 *values);
91/* Returns the number of read bytes */ 91/* Returns the number of read bytes */
92extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client, 92extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client,
93 u8 command, u8 *values); 93 u8 command, u8 length, u8 *values);
94extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client, 94extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client,
95 u8 command, u8 length, 95 u8 command, u8 length,
96 const u8 *values); 96 const u8 *values);
@@ -524,8 +524,9 @@ union i2c_smbus_data {
524#define I2C_SMBUS_WORD_DATA 3 524#define I2C_SMBUS_WORD_DATA 3
525#define I2C_SMBUS_PROC_CALL 4 525#define I2C_SMBUS_PROC_CALL 4
526#define I2C_SMBUS_BLOCK_DATA 5 526#define I2C_SMBUS_BLOCK_DATA 5
527#define I2C_SMBUS_I2C_BLOCK_DATA 6 527#define I2C_SMBUS_I2C_BLOCK_BROKEN 6
528#define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */ 528#define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */
529#define I2C_SMBUS_I2C_BLOCK_DATA 8
529 530
530 531
531/* ----- commands for the ioctl like i2c_command call: 532/* ----- commands for the ioctl like i2c_command call: