aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2007-07-12 08:12:29 -0400
committerJean Delvare <khali@hyperion.delvare>2007-07-12 08:12:29 -0400
commit4b2643d7d9bdcd776749e17f73c168ddf02e93cb (patch)
tree1642900ea1c196cc27d120f0af4de44fff30633e /drivers/i2c/busses
parentba7fbb723f50ab2607989a282af655fb0fab0492 (diff)
i2c: Fix the i2c_smbus_read_i2c_block_data() prototype
Let the drivers specify how many bytes they want to read with i2c_smbus_read_i2c_block_data(). So far, the block count was hard-coded to I2C_SMBUS_BLOCK_MAX (32), which did not make much sense. Many driver authors complained about this before, and I believe it's about time to fix it. Right now, authors have to do technically stupid things, such as individual byte reads or full-fledged I2C messaging, to work around the problem. We do not want to encourage that. I even found that some bus drivers (e.g. i2c-amd8111) already implemented I2C block read the "right" way, that is, they didn't follow the old, broken standard. The fact that it was never noticed before just shows how little i2c_smbus_read_i2c_block_data() was used, which isn't that surprising given how broken its prototype was so far. There are some obvious compatiblity considerations: * This changes the i2c_smbus_read_i2c_block_data() prototype. Users outside the kernel tree will notice at compilation time, and will have to update their code. * User-space has access to i2c_smbus_xfer() directly using i2c-dev, so the changed expectations would affect tools such as i2cdump. In order to preserve binary compatibility, we give I2C_SMBUS_I2C_BLOCK_DATA a new numeric value, and define I2C_SMBUS_I2C_BLOCK_BROKEN with the old numeric value. When i2c-dev receives a transaction with the old value, it can convert it to the new format on the fly. Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/i2c/busses')
-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
3 files changed, 2 insertions, 5 deletions
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;