aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2008-07-14 16:38:25 -0400
committerJean Delvare <khali@mahadeva.delvare>2008-07-14 16:38:25 -0400
commitac7fc4fb2b6a126af8d07f46500440c9641976cf (patch)
tree1ba7a6b229699f6d69cfe3f1bd74c020e952e16b /drivers/i2c
parentfa63cd56d2f09806169307d761e8f430e23bc09b (diff)
i2c: Consistently reject unsupported transactions
Many PC SMBus host controller drivers don't properly handle the case where they are requested to achieve a transaction they do not support. Update them so that the consistently print a warning message and return a single error value in this case. Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-ali1535.c8
-rw-r--r--drivers/i2c/busses/i2c-ali1563.c8
-rw-r--r--drivers/i2c/busses/i2c-ali15x3.c6
-rw-r--r--drivers/i2c/busses/i2c-amd756.c8
-rw-r--r--drivers/i2c/busses/i2c-i801.c1
-rw-r--r--drivers/i2c/busses/i2c-piix4.c6
-rw-r--r--drivers/i2c/busses/i2c-sis630.c5
-rw-r--r--drivers/i2c/busses/i2c-sis96x.c8
-rw-r--r--drivers/i2c/busses/i2c-taos-evm.c5
-rw-r--r--drivers/i2c/busses/i2c-viapro.c2
10 files changed, 23 insertions, 34 deletions
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c
index c21e4d96382e..704436cdec8e 100644
--- a/drivers/i2c/busses/i2c-ali1535.c
+++ b/drivers/i2c/busses/i2c-ali1535.c
@@ -357,10 +357,6 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
357 outb_p(0xFF, SMBHSTSTS); 357 outb_p(0xFF, SMBHSTSTS);
358 358
359 switch (size) { 359 switch (size) {
360 case I2C_SMBUS_PROC_CALL:
361 dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
362 result = -EOPNOTSUPP;
363 goto EXIT;
364 case I2C_SMBUS_QUICK: 360 case I2C_SMBUS_QUICK:
365 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), 361 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
366 SMBHSTADD); 362 SMBHSTADD);
@@ -418,6 +414,10 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
418 outb_p(data->block[i], SMBBLKDAT); 414 outb_p(data->block[i], SMBBLKDAT);
419 } 415 }
420 break; 416 break;
417 default:
418 dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
419 result = -EOPNOTSUPP;
420 goto EXIT;
421 } 421 }
422 422
423 result = ali1535_transaction(adap); 423 result = ali1535_transaction(adap);
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c
index 30bd3ee70386..da5a382eee93 100644
--- a/drivers/i2c/busses/i2c-ali1563.c
+++ b/drivers/i2c/busses/i2c-ali1563.c
@@ -246,10 +246,6 @@ static s32 ali1563_access(struct i2c_adapter * a, u16 addr,
246 246
247 /* Map the size to what the chip understands */ 247 /* Map the size to what the chip understands */
248 switch (size) { 248 switch (size) {
249 case I2C_SMBUS_PROC_CALL:
250 dev_err(&a->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
251 error = -EINVAL;
252 break;
253 case I2C_SMBUS_QUICK: 249 case I2C_SMBUS_QUICK:
254 size = HST_CNTL2_QUICK; 250 size = HST_CNTL2_QUICK;
255 break; 251 break;
@@ -265,6 +261,10 @@ static s32 ali1563_access(struct i2c_adapter * a, u16 addr,
265 case I2C_SMBUS_BLOCK_DATA: 261 case I2C_SMBUS_BLOCK_DATA:
266 size = HST_CNTL2_BLOCK; 262 size = HST_CNTL2_BLOCK;
267 break; 263 break;
264 default:
265 dev_warn(&a->dev, "Unsupported transaction %d\n", size);
266 error = -EOPNOTSUPP;
267 goto Done;
268 } 268 }
269 269
270 outb_p(((addr & 0x7f) << 1) | (rw & 0x01), SMB_HST_ADD); 270 outb_p(((addr & 0x7f) << 1) | (rw & 0x01), SMB_HST_ADD);
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c
index 3d752561dc37..7b029b147a8e 100644
--- a/drivers/i2c/busses/i2c-ali15x3.c
+++ b/drivers/i2c/busses/i2c-ali15x3.c
@@ -362,9 +362,6 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
362 } 362 }
363 363
364 switch (size) { 364 switch (size) {
365 case I2C_SMBUS_PROC_CALL:
366 dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
367 return -EOPNOTSUPP;
368 case I2C_SMBUS_QUICK: 365 case I2C_SMBUS_QUICK:
369 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), 366 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
370 SMBHSTADD); 367 SMBHSTADD);
@@ -417,6 +414,9 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
417 } 414 }
418 size = ALI15X3_BLOCK_DATA; 415 size = ALI15X3_BLOCK_DATA;
419 break; 416 break;
417 default:
418 dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
419 return -EOPNOTSUPP;
420 } 420 }
421 421
422 outb_p(size, SMBHSTCNT); /* output command */ 422 outb_p(size, SMBHSTCNT); /* output command */
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c
index 3d5bcb65e9e0..f0baea62067d 100644
--- a/drivers/i2c/busses/i2c-amd756.c
+++ b/drivers/i2c/busses/i2c-amd756.c
@@ -200,12 +200,7 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
200 int i, len; 200 int i, len;
201 int status; 201 int status;
202 202
203 /** TODO: Should I supporte the 10-bit transfers? */
204 switch (size) { 203 switch (size) {
205 case I2C_SMBUS_PROC_CALL:
206 dev_dbg(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
207 /* TODO: Well... It is supported, I'm just not sure what to do here... */
208 return -EOPNOTSUPP;
209 case I2C_SMBUS_QUICK: 204 case I2C_SMBUS_QUICK:
210 outw_p(((addr & 0x7f) << 1) | (read_write & 0x01), 205 outw_p(((addr & 0x7f) << 1) | (read_write & 0x01),
211 SMB_HOST_ADDRESS); 206 SMB_HOST_ADDRESS);
@@ -252,6 +247,9 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
252 } 247 }
253 size = AMD756_BLOCK_DATA; 248 size = AMD756_BLOCK_DATA;
254 break; 249 break;
250 default:
251 dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
252 return -EOPNOTSUPP;
255 } 253 }
256 254
257 /* How about enabling interrupts... */ 255 /* How about enabling interrupts... */
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 7d6d9dfcc58a..213119211e58 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -513,7 +513,6 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr,
513 outb_p(command, SMBHSTCMD); 513 outb_p(command, SMBHSTCMD);
514 block = 1; 514 block = 1;
515 break; 515 break;
516 case I2C_SMBUS_PROC_CALL:
517 default: 516 default:
518 dev_err(&I801_dev->dev, "Unsupported transaction %d\n", size); 517 dev_err(&I801_dev->dev, "Unsupported transaction %d\n", size);
519 return -EOPNOTSUPP; 518 return -EOPNOTSUPP;
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index 77aaa5fe5e38..2bde47509e1a 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -307,9 +307,6 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
307 int status; 307 int status;
308 308
309 switch (size) { 309 switch (size) {
310 case I2C_SMBUS_PROC_CALL:
311 dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
312 return -EOPNOTSUPP;
313 case I2C_SMBUS_QUICK: 310 case I2C_SMBUS_QUICK:
314 outb_p((addr << 1) | read_write, 311 outb_p((addr << 1) | read_write,
315 SMBHSTADD); 312 SMBHSTADD);
@@ -355,6 +352,9 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
355 } 352 }
356 size = PIIX4_BLOCK_DATA; 353 size = PIIX4_BLOCK_DATA;
357 break; 354 break;
355 default:
356 dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
357 return -EOPNOTSUPP;
358 } 358 }
359 359
360 outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT); 360 outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT);
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c
index c4cc5eddf50d..d7e6ff3e0187 100644
--- a/drivers/i2c/busses/i2c-sis630.c
+++ b/drivers/i2c/busses/i2c-sis630.c
@@ -356,7 +356,8 @@ static s32 sis630_access(struct i2c_adapter *adap, u16 addr,
356 size = SIS630_BLOCK_DATA; 356 size = SIS630_BLOCK_DATA;
357 return sis630_block_data(adap, data, read_write); 357 return sis630_block_data(adap, data, read_write);
358 default: 358 default:
359 printk("Unsupported SMBus operation\n"); 359 dev_warn(&adap->dev, "Unsupported transaction %d\n",
360 size);
360 return -EOPNOTSUPP; 361 return -EOPNOTSUPP;
361 } 362 }
362 363
@@ -378,8 +379,6 @@ static s32 sis630_access(struct i2c_adapter *adap, u16 addr,
378 case SIS630_WORD_DATA: 379 case SIS630_WORD_DATA:
379 data->word = sis630_read(SMB_BYTE) + (sis630_read(SMB_BYTE + 1) << 8); 380 data->word = sis630_read(SMB_BYTE) + (sis630_read(SMB_BYTE + 1) << 8);
380 break; 381 break;
381 default:
382 return -EOPNOTSUPP;
383 } 382 }
384 383
385 return 0; 384 return 0;
diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c
index 29757b2e11dd..cde8e5880368 100644
--- a/drivers/i2c/busses/i2c-sis96x.c
+++ b/drivers/i2c/busses/i2c-sis96x.c
@@ -201,14 +201,8 @@ static s32 sis96x_access(struct i2c_adapter * adap, u16 addr,
201 SIS96x_PROC_CALL : SIS96x_WORD_DATA); 201 SIS96x_PROC_CALL : SIS96x_WORD_DATA);
202 break; 202 break;
203 203
204 case I2C_SMBUS_BLOCK_DATA:
205 /* TO DO: */
206 dev_info(&adap->dev, "SMBus block not implemented!\n");
207 return -EOPNOTSUPP;
208 break;
209
210 default: 204 default:
211 dev_info(&adap->dev, "Unsupported SMBus operation\n"); 205 dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
212 return -EOPNOTSUPP; 206 return -EOPNOTSUPP;
213 } 207 }
214 208
diff --git a/drivers/i2c/busses/i2c-taos-evm.c b/drivers/i2c/busses/i2c-taos-evm.c
index de9db49e54d9..224aa12ee7c8 100644
--- a/drivers/i2c/busses/i2c-taos-evm.c
+++ b/drivers/i2c/busses/i2c-taos-evm.c
@@ -96,9 +96,8 @@ static int taos_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
96 sprintf(p, "$%02X", command); 96 sprintf(p, "$%02X", command);
97 break; 97 break;
98 default: 98 default:
99 dev_dbg(&adapter->dev, "Unsupported transaction size %d\n", 99 dev_warn(&adapter->dev, "Unsupported transaction %d\n", size);
100 size); 100 return -EOPNOTSUPP;
101 return -EINVAL;
102 } 101 }
103 102
104 /* Send the transaction to the TAOS EVM */ 103 /* Send the transaction to the TAOS EVM */
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
index 7628fe8e0946..c611905df009 100644
--- a/drivers/i2c/busses/i2c-viapro.c
+++ b/drivers/i2c/busses/i2c-viapro.c
@@ -287,7 +287,7 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr,
287 return 0; 287 return 0;
288 288
289exit_unsupported: 289exit_unsupported:
290 dev_warn(&vt596_adapter.dev, "Unsupported command invoked! (0x%02x)\n", 290 dev_warn(&vt596_adapter.dev, "Unsupported transaction %d\n",
291 size); 291 size);
292 return -EOPNOTSUPP; 292 return -EOPNOTSUPP;
293} 293}