aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/i2c/algos/i2c-algo-bit.c4
-rw-r--r--drivers/i2c/busses/i2c-ali1535.c22
-rw-r--r--drivers/i2c/busses/i2c-ali1563.c23
-rw-r--r--drivers/i2c/busses/i2c-ali15x3.c19
-rw-r--r--drivers/i2c/busses/i2c-amd756-s4882.c4
-rw-r--r--drivers/i2c/busses/i2c-amd756.c18
-rw-r--r--drivers/i2c/busses/i2c-amd8111.c47
-rw-r--r--drivers/i2c/busses/i2c-i801.c44
-rw-r--r--drivers/i2c/busses/i2c-nforce2.c25
-rw-r--r--drivers/i2c/busses/i2c-piix4.c20
-rw-r--r--drivers/i2c/busses/i2c-sis5595.c19
-rw-r--r--drivers/i2c/busses/i2c-sis630.c47
-rw-r--r--drivers/i2c/busses/i2c-sis96x.c23
-rw-r--r--drivers/i2c/busses/i2c-stub.c4
-rw-r--r--drivers/i2c/busses/i2c-viapro.c20
15 files changed, 191 insertions, 148 deletions
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
index 35812823787b..eb8f72ca02f4 100644
--- a/drivers/i2c/algos/i2c-algo-bit.c
+++ b/drivers/i2c/algos/i2c-algo-bit.c
@@ -320,7 +320,7 @@ static int try_address(struct i2c_adapter *i2c_adap,
320 unsigned char addr, int retries) 320 unsigned char addr, int retries)
321{ 321{
322 struct i2c_algo_bit_data *adap = i2c_adap->algo_data; 322 struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
323 int i, ret = -1; 323 int i, ret = 0;
324 324
325 for (i = 0; i <= retries; i++) { 325 for (i = 0; i <= retries; i++) {
326 ret = i2c_outb(i2c_adap, addr); 326 ret = i2c_outb(i2c_adap, addr);
@@ -508,7 +508,7 @@ static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
508 addr ^= 1; 508 addr ^= 1;
509 ret = try_address(i2c_adap, addr, retries); 509 ret = try_address(i2c_adap, addr, retries);
510 if ((ret != 1) && !nak_ok) 510 if ((ret != 1) && !nak_ok)
511 return -EREMOTEIO; 511 return -ENXIO;
512 } 512 }
513 513
514 return 0; 514 return 0;
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c
index f14372ac2fc5..c21e4d96382e 100644
--- a/drivers/i2c/busses/i2c-ali1535.c
+++ b/drivers/i2c/busses/i2c-ali1535.c
@@ -259,7 +259,7 @@ static int ali1535_transaction(struct i2c_adapter *adap)
259 dev_err(&adap->dev, 259 dev_err(&adap->dev,
260 "SMBus reset failed! (0x%02x) - controller or " 260 "SMBus reset failed! (0x%02x) - controller or "
261 "device on bus is probably hung\n", temp); 261 "device on bus is probably hung\n", temp);
262 return -1; 262 return -EBUSY;
263 } 263 }
264 } else { 264 } else {
265 /* check and clear done bit */ 265 /* check and clear done bit */
@@ -281,12 +281,12 @@ static int ali1535_transaction(struct i2c_adapter *adap)
281 281
282 /* If the SMBus is still busy, we give up */ 282 /* If the SMBus is still busy, we give up */
283 if (timeout >= MAX_TIMEOUT) { 283 if (timeout >= MAX_TIMEOUT) {
284 result = -1; 284 result = -ETIMEDOUT;
285 dev_err(&adap->dev, "SMBus Timeout!\n"); 285 dev_err(&adap->dev, "SMBus Timeout!\n");
286 } 286 }
287 287
288 if (temp & ALI1535_STS_FAIL) { 288 if (temp & ALI1535_STS_FAIL) {
289 result = -1; 289 result = -EIO;
290 dev_dbg(&adap->dev, "Error: Failed bus transaction\n"); 290 dev_dbg(&adap->dev, "Error: Failed bus transaction\n");
291 } 291 }
292 292
@@ -295,7 +295,7 @@ static int ali1535_transaction(struct i2c_adapter *adap)
295 * do a printk. This means that bus collisions go unreported. 295 * do a printk. This means that bus collisions go unreported.
296 */ 296 */
297 if (temp & ALI1535_STS_BUSERR) { 297 if (temp & ALI1535_STS_BUSERR) {
298 result = -1; 298 result = -ENXIO;
299 dev_dbg(&adap->dev, 299 dev_dbg(&adap->dev,
300 "Error: no response or bus collision ADD=%02x\n", 300 "Error: no response or bus collision ADD=%02x\n",
301 inb_p(SMBHSTADD)); 301 inb_p(SMBHSTADD));
@@ -303,13 +303,13 @@ static int ali1535_transaction(struct i2c_adapter *adap)
303 303
304 /* haven't ever seen this */ 304 /* haven't ever seen this */
305 if (temp & ALI1535_STS_DEV) { 305 if (temp & ALI1535_STS_DEV) {
306 result = -1; 306 result = -EIO;
307 dev_err(&adap->dev, "Error: device error\n"); 307 dev_err(&adap->dev, "Error: device error\n");
308 } 308 }
309 309
310 /* check to see if the "command complete" indication is set */ 310 /* check to see if the "command complete" indication is set */
311 if (!(temp & ALI1535_STS_DONE)) { 311 if (!(temp & ALI1535_STS_DONE)) {
312 result = -1; 312 result = -ETIMEDOUT;
313 dev_err(&adap->dev, "Error: command never completed\n"); 313 dev_err(&adap->dev, "Error: command never completed\n");
314 } 314 }
315 315
@@ -332,7 +332,7 @@ static int ali1535_transaction(struct i2c_adapter *adap)
332 return result; 332 return result;
333} 333}
334 334
335/* Return -1 on error. */ 335/* Return negative errno on error. */
336static s32 ali1535_access(struct i2c_adapter *adap, u16 addr, 336static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
337 unsigned short flags, char read_write, u8 command, 337 unsigned short flags, char read_write, u8 command,
338 int size, union i2c_smbus_data *data) 338 int size, union i2c_smbus_data *data)
@@ -359,7 +359,7 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
359 switch (size) { 359 switch (size) {
360 case I2C_SMBUS_PROC_CALL: 360 case I2C_SMBUS_PROC_CALL:
361 dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n"); 361 dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
362 result = -1; 362 result = -EOPNOTSUPP;
363 goto EXIT; 363 goto EXIT;
364 case I2C_SMBUS_QUICK: 364 case I2C_SMBUS_QUICK:
365 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), 365 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
@@ -420,11 +420,9 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
420 break; 420 break;
421 } 421 }
422 422
423 if (ali1535_transaction(adap)) { 423 result = ali1535_transaction(adap);
424 /* Error in transaction */ 424 if (result)
425 result = -1;
426 goto EXIT; 425 goto EXIT;
427 }
428 426
429 if ((read_write == I2C_SMBUS_WRITE) || (size == ALI1535_QUICK)) { 427 if ((read_write == I2C_SMBUS_WRITE) || (size == ALI1535_QUICK)) {
430 result = 0; 428 result = 0;
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c
index 6b68074e518a..30bd3ee70386 100644
--- a/drivers/i2c/busses/i2c-ali1563.c
+++ b/drivers/i2c/busses/i2c-ali1563.c
@@ -67,6 +67,7 @@ static int ali1563_transaction(struct i2c_adapter * a, int size)
67{ 67{
68 u32 data; 68 u32 data;
69 int timeout; 69 int timeout;
70 int status = -EIO;
70 71
71 dev_dbg(&a->dev, "Transaction (pre): STS=%02x, CNTL1=%02x, " 72 dev_dbg(&a->dev, "Transaction (pre): STS=%02x, CNTL1=%02x, "
72 "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", 73 "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n",
@@ -103,13 +104,15 @@ static int ali1563_transaction(struct i2c_adapter * a, int size)
103 /* Issue 'kill' to host controller */ 104 /* Issue 'kill' to host controller */
104 outb_p(HST_CNTL2_KILL,SMB_HST_CNTL2); 105 outb_p(HST_CNTL2_KILL,SMB_HST_CNTL2);
105 data = inb_p(SMB_HST_STS); 106 data = inb_p(SMB_HST_STS);
107 status = -ETIMEDOUT;
106 } 108 }
107 109
108 /* device error - no response, ignore the autodetection case */ 110 /* device error - no response, ignore the autodetection case */
109 if ((data & HST_STS_DEVERR) && (size != HST_CNTL2_QUICK)) { 111 if (data & HST_STS_DEVERR) {
110 dev_err(&a->dev, "Device error!\n"); 112 if (size != HST_CNTL2_QUICK)
113 dev_err(&a->dev, "Device error!\n");
114 status = -ENXIO;
111 } 115 }
112
113 /* bus collision */ 116 /* bus collision */
114 if (data & HST_STS_BUSERR) { 117 if (data & HST_STS_BUSERR) {
115 dev_err(&a->dev, "Bus collision!\n"); 118 dev_err(&a->dev, "Bus collision!\n");
@@ -122,13 +125,14 @@ static int ali1563_transaction(struct i2c_adapter * a, int size)
122 outb_p(0x0,SMB_HST_CNTL2); 125 outb_p(0x0,SMB_HST_CNTL2);
123 } 126 }
124 127
125 return -1; 128 return status;
126} 129}
127 130
128static int ali1563_block_start(struct i2c_adapter * a) 131static int ali1563_block_start(struct i2c_adapter * a)
129{ 132{
130 u32 data; 133 u32 data;
131 int timeout; 134 int timeout;
135 int status = -EIO;
132 136
133 dev_dbg(&a->dev, "Block (pre): STS=%02x, CNTL1=%02x, " 137 dev_dbg(&a->dev, "Block (pre): STS=%02x, CNTL1=%02x, "
134 "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", 138 "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n",
@@ -164,13 +168,20 @@ static int ali1563_block_start(struct i2c_adapter * a)
164 168
165 if (timeout && !(data & HST_STS_BAD)) 169 if (timeout && !(data & HST_STS_BAD))
166 return 0; 170 return 0;
171
172 if (timeout == 0)
173 status = -ETIMEDOUT;
174
175 if (data & HST_STS_DEVERR)
176 status = -ENXIO;
177
167 dev_err(&a->dev, "SMBus Error: %s%s%s%s%s\n", 178 dev_err(&a->dev, "SMBus Error: %s%s%s%s%s\n",
168 timeout ? "Timeout " : "", 179 timeout ? "" : "Timeout ",
169 data & HST_STS_FAIL ? "Transaction Failed " : "", 180 data & HST_STS_FAIL ? "Transaction Failed " : "",
170 data & HST_STS_BUSERR ? "No response or Bus Collision " : "", 181 data & HST_STS_BUSERR ? "No response or Bus Collision " : "",
171 data & HST_STS_DEVERR ? "Device Error " : "", 182 data & HST_STS_DEVERR ? "Device Error " : "",
172 !(data & HST_STS_DONE) ? "Transaction Never Finished " : ""); 183 !(data & HST_STS_DONE) ? "Transaction Never Finished " : "");
173 return -1; 184 return status;
174} 185}
175 186
176static int ali1563_block(struct i2c_adapter * a, union i2c_smbus_data * data, u8 rw) 187static int ali1563_block(struct i2c_adapter * a, union i2c_smbus_data * data, u8 rw)
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c
index 93bf87d70961..3d752561dc37 100644
--- a/drivers/i2c/busses/i2c-ali15x3.c
+++ b/drivers/i2c/busses/i2c-ali15x3.c
@@ -282,7 +282,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
282 dev_err(&adap->dev, "SMBus reset failed! (0x%02x) - " 282 dev_err(&adap->dev, "SMBus reset failed! (0x%02x) - "
283 "controller or device on bus is probably hung\n", 283 "controller or device on bus is probably hung\n",
284 temp); 284 temp);
285 return -1; 285 return -EBUSY;
286 } 286 }
287 } else { 287 } else {
288 /* check and clear done bit */ 288 /* check and clear done bit */
@@ -304,12 +304,12 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
304 304
305 /* If the SMBus is still busy, we give up */ 305 /* If the SMBus is still busy, we give up */
306 if (timeout >= MAX_TIMEOUT) { 306 if (timeout >= MAX_TIMEOUT) {
307 result = -1; 307 result = -ETIMEDOUT;
308 dev_err(&adap->dev, "SMBus Timeout!\n"); 308 dev_err(&adap->dev, "SMBus Timeout!\n");
309 } 309 }
310 310
311 if (temp & ALI15X3_STS_TERM) { 311 if (temp & ALI15X3_STS_TERM) {
312 result = -1; 312 result = -EIO;
313 dev_dbg(&adap->dev, "Error: Failed bus transaction\n"); 313 dev_dbg(&adap->dev, "Error: Failed bus transaction\n");
314 } 314 }
315 315
@@ -320,7 +320,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
320 This means that bus collisions go unreported. 320 This means that bus collisions go unreported.
321 */ 321 */
322 if (temp & ALI15X3_STS_COLL) { 322 if (temp & ALI15X3_STS_COLL) {
323 result = -1; 323 result = -ENXIO;
324 dev_dbg(&adap->dev, 324 dev_dbg(&adap->dev,
325 "Error: no response or bus collision ADD=%02x\n", 325 "Error: no response or bus collision ADD=%02x\n",
326 inb_p(SMBHSTADD)); 326 inb_p(SMBHSTADD));
@@ -328,7 +328,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
328 328
329 /* haven't ever seen this */ 329 /* haven't ever seen this */
330 if (temp & ALI15X3_STS_DEV) { 330 if (temp & ALI15X3_STS_DEV) {
331 result = -1; 331 result = -EIO;
332 dev_err(&adap->dev, "Error: device error\n"); 332 dev_err(&adap->dev, "Error: device error\n");
333 } 333 }
334 dev_dbg(&adap->dev, "Transaction (post): STS=%02x, CNT=%02x, CMD=%02x, " 334 dev_dbg(&adap->dev, "Transaction (post): STS=%02x, CNT=%02x, CMD=%02x, "
@@ -338,7 +338,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
338 return result; 338 return result;
339} 339}
340 340
341/* Return -1 on error. */ 341/* Return negative errno on error. */
342static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, 342static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
343 unsigned short flags, char read_write, u8 command, 343 unsigned short flags, char read_write, u8 command,
344 int size, union i2c_smbus_data * data) 344 int size, union i2c_smbus_data * data)
@@ -364,7 +364,7 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
364 switch (size) { 364 switch (size) {
365 case I2C_SMBUS_PROC_CALL: 365 case I2C_SMBUS_PROC_CALL:
366 dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n"); 366 dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
367 return -1; 367 return -EOPNOTSUPP;
368 case I2C_SMBUS_QUICK: 368 case I2C_SMBUS_QUICK:
369 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), 369 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
370 SMBHSTADD); 370 SMBHSTADD);
@@ -421,8 +421,9 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
421 421
422 outb_p(size, SMBHSTCNT); /* output command */ 422 outb_p(size, SMBHSTCNT); /* output command */
423 423
424 if (ali15x3_transaction(adap)) /* Error in transaction */ 424 temp = ali15x3_transaction(adap);
425 return -1; 425 if (temp)
426 return temp;
426 427
427 if ((read_write == I2C_SMBUS_WRITE) || (size == ALI15X3_QUICK)) 428 if ((read_write == I2C_SMBUS_WRITE) || (size == ALI15X3_QUICK))
428 return 0; 429 return 0;
diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
index c38a0a112208..2f150e33c74c 100644
--- a/drivers/i2c/busses/i2c-amd756-s4882.c
+++ b/drivers/i2c/busses/i2c-amd756-s4882.c
@@ -58,7 +58,7 @@ static s32 amd756_access_virt0(struct i2c_adapter * adap, u16 addr,
58 /* We exclude the multiplexed addresses */ 58 /* We exclude the multiplexed addresses */
59 if (addr == 0x4c || (addr & 0xfc) == 0x50 || (addr & 0xfc) == 0x30 59 if (addr == 0x4c || (addr & 0xfc) == 0x50 || (addr & 0xfc) == 0x30
60 || addr == 0x18) 60 || addr == 0x18)
61 return -1; 61 return -ENXIO;
62 62
63 mutex_lock(&amd756_lock); 63 mutex_lock(&amd756_lock);
64 64
@@ -86,7 +86,7 @@ static inline s32 amd756_access_channel(struct i2c_adapter * adap, u16 addr,
86 86
87 /* We exclude the non-multiplexed addresses */ 87 /* We exclude the non-multiplexed addresses */
88 if (addr != 0x4c && (addr & 0xfc) != 0x50 && (addr & 0xfc) != 0x30) 88 if (addr != 0x4c && (addr & 0xfc) != 0x50 && (addr & 0xfc) != 0x30)
89 return -1; 89 return -ENXIO;
90 90
91 mutex_lock(&amd756_lock); 91 mutex_lock(&amd756_lock);
92 92
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c
index 43508d61eb7c..3d5bcb65e9e0 100644
--- a/drivers/i2c/busses/i2c-amd756.c
+++ b/drivers/i2c/busses/i2c-amd756.c
@@ -151,17 +151,17 @@ static int amd756_transaction(struct i2c_adapter *adap)
151 } 151 }
152 152
153 if (temp & GS_PRERR_STS) { 153 if (temp & GS_PRERR_STS) {
154 result = -1; 154 result = -ENXIO;
155 dev_dbg(&adap->dev, "SMBus Protocol error (no response)!\n"); 155 dev_dbg(&adap->dev, "SMBus Protocol error (no response)!\n");
156 } 156 }
157 157
158 if (temp & GS_COL_STS) { 158 if (temp & GS_COL_STS) {
159 result = -1; 159 result = -EIO;
160 dev_warn(&adap->dev, "SMBus collision!\n"); 160 dev_warn(&adap->dev, "SMBus collision!\n");
161 } 161 }
162 162
163 if (temp & GS_TO_STS) { 163 if (temp & GS_TO_STS) {
164 result = -1; 164 result = -ETIMEDOUT;
165 dev_dbg(&adap->dev, "SMBus protocol timeout!\n"); 165 dev_dbg(&adap->dev, "SMBus protocol timeout!\n");
166 } 166 }
167 167
@@ -189,22 +189,23 @@ static int amd756_transaction(struct i2c_adapter *adap)
189 outw_p(inw(SMB_GLOBAL_ENABLE) | GE_ABORT, SMB_GLOBAL_ENABLE); 189 outw_p(inw(SMB_GLOBAL_ENABLE) | GE_ABORT, SMB_GLOBAL_ENABLE);
190 msleep(100); 190 msleep(100);
191 outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS); 191 outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS);
192 return -1; 192 return -EIO;
193} 193}
194 194
195/* Return -1 on error. */ 195/* Return negative errno on error. */
196static s32 amd756_access(struct i2c_adapter * adap, u16 addr, 196static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
197 unsigned short flags, char read_write, 197 unsigned short flags, char read_write,
198 u8 command, int size, union i2c_smbus_data * data) 198 u8 command, int size, union i2c_smbus_data * data)
199{ 199{
200 int i, len; 200 int i, len;
201 int status;
201 202
202 /** TODO: Should I supporte the 10-bit transfers? */ 203 /** TODO: Should I supporte the 10-bit transfers? */
203 switch (size) { 204 switch (size) {
204 case I2C_SMBUS_PROC_CALL: 205 case I2C_SMBUS_PROC_CALL:
205 dev_dbg(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n"); 206 dev_dbg(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
206 /* TODO: Well... It is supported, I'm just not sure what to do here... */ 207 /* TODO: Well... It is supported, I'm just not sure what to do here... */
207 return -1; 208 return -EOPNOTSUPP;
208 case I2C_SMBUS_QUICK: 209 case I2C_SMBUS_QUICK:
209 outw_p(((addr & 0x7f) << 1) | (read_write & 0x01), 210 outw_p(((addr & 0x7f) << 1) | (read_write & 0x01),
210 SMB_HOST_ADDRESS); 211 SMB_HOST_ADDRESS);
@@ -256,8 +257,9 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
256 /* How about enabling interrupts... */ 257 /* How about enabling interrupts... */
257 outw_p(size & GE_CYC_TYPE_MASK, SMB_GLOBAL_ENABLE); 258 outw_p(size & GE_CYC_TYPE_MASK, SMB_GLOBAL_ENABLE);
258 259
259 if (amd756_transaction(adap)) /* Error in transaction */ 260 status = amd756_transaction(adap);
260 return -1; 261 if (status)
262 return status;
261 263
262 if ((read_write == I2C_SMBUS_WRITE) || (size == AMD756_QUICK)) 264 if ((read_write == I2C_SMBUS_WRITE) || (size == AMD756_QUICK))
263 return 0; 265 return 0;
diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c
index 5d1a27ef2504..a4f687915de1 100644
--- a/drivers/i2c/busses/i2c-amd8111.c
+++ b/drivers/i2c/busses/i2c-amd8111.c
@@ -77,7 +77,7 @@ static unsigned int amd_ec_wait_write(struct amd_smbus *smbus)
77 if (!timeout) { 77 if (!timeout) {
78 dev_warn(&smbus->dev->dev, 78 dev_warn(&smbus->dev->dev,
79 "Timeout while waiting for IBF to clear\n"); 79 "Timeout while waiting for IBF to clear\n");
80 return -1; 80 return -ETIMEDOUT;
81 } 81 }
82 82
83 return 0; 83 return 0;
@@ -93,7 +93,7 @@ static unsigned int amd_ec_wait_read(struct amd_smbus *smbus)
93 if (!timeout) { 93 if (!timeout) {
94 dev_warn(&smbus->dev->dev, 94 dev_warn(&smbus->dev->dev,
95 "Timeout while waiting for OBF to set\n"); 95 "Timeout while waiting for OBF to set\n");
96 return -1; 96 return -ETIMEDOUT;
97 } 97 }
98 98
99 return 0; 99 return 0;
@@ -102,16 +102,21 @@ static unsigned int amd_ec_wait_read(struct amd_smbus *smbus)
102static unsigned int amd_ec_read(struct amd_smbus *smbus, unsigned char address, 102static unsigned int amd_ec_read(struct amd_smbus *smbus, unsigned char address,
103 unsigned char *data) 103 unsigned char *data)
104{ 104{
105 if (amd_ec_wait_write(smbus)) 105 int status;
106 return -1; 106
107 status = amd_ec_wait_write(smbus);
108 if (status)
109 return status;
107 outb(AMD_EC_CMD_RD, smbus->base + AMD_EC_CMD); 110 outb(AMD_EC_CMD_RD, smbus->base + AMD_EC_CMD);
108 111
109 if (amd_ec_wait_write(smbus)) 112 status = amd_ec_wait_write(smbus);
110 return -1; 113 if (status)
114 return status;
111 outb(address, smbus->base + AMD_EC_DATA); 115 outb(address, smbus->base + AMD_EC_DATA);
112 116
113 if (amd_ec_wait_read(smbus)) 117 status = amd_ec_wait_read(smbus);
114 return -1; 118 if (status)
119 return status;
115 *data = inb(smbus->base + AMD_EC_DATA); 120 *data = inb(smbus->base + AMD_EC_DATA);
116 121
117 return 0; 122 return 0;
@@ -120,16 +125,21 @@ static unsigned int amd_ec_read(struct amd_smbus *smbus, unsigned char address,
120static unsigned int amd_ec_write(struct amd_smbus *smbus, unsigned char address, 125static unsigned int amd_ec_write(struct amd_smbus *smbus, unsigned char address,
121 unsigned char data) 126 unsigned char data)
122{ 127{
123 if (amd_ec_wait_write(smbus)) 128 int status;
124 return -1; 129
130 status = amd_ec_wait_write(smbus);
131 if (status)
132 return status;
125 outb(AMD_EC_CMD_WR, smbus->base + AMD_EC_CMD); 133 outb(AMD_EC_CMD_WR, smbus->base + AMD_EC_CMD);
126 134
127 if (amd_ec_wait_write(smbus)) 135 status = amd_ec_wait_write(smbus);
128 return -1; 136 if (status)
137 return status;
129 outb(address, smbus->base + AMD_EC_DATA); 138 outb(address, smbus->base + AMD_EC_DATA);
130 139
131 if (amd_ec_wait_write(smbus)) 140 status = amd_ec_wait_write(smbus);
132 return -1; 141 if (status)
142 return status;
133 outb(data, smbus->base + AMD_EC_DATA); 143 outb(data, smbus->base + AMD_EC_DATA);
134 144
135 return 0; 145 return 0;
@@ -267,12 +277,17 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr,
267 277
268 default: 278 default:
269 dev_warn(&adap->dev, "Unsupported transaction %d\n", size); 279 dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
270 return -1; 280 return -EOPNOTSUPP;
271 } 281 }
272 282
273 amd_ec_write(smbus, AMD_SMB_ADDR, addr << 1); 283 amd_ec_write(smbus, AMD_SMB_ADDR, addr << 1);
274 amd_ec_write(smbus, AMD_SMB_PRTCL, protocol); 284 amd_ec_write(smbus, AMD_SMB_PRTCL, protocol);
275 285
286 /* FIXME this discards status from ec_read(); so temp[0] will
287 * hold stack garbage ... the rest of this routine will act
288 * nonsensically. Ignored ec_write() status might explain
289 * some such failures...
290 */
276 amd_ec_read(smbus, AMD_SMB_STS, temp + 0); 291 amd_ec_read(smbus, AMD_SMB_STS, temp + 0);
277 292
278 if (~temp[0] & AMD_SMB_STS_DONE) { 293 if (~temp[0] & AMD_SMB_STS_DONE) {
@@ -286,7 +301,7 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr,
286 } 301 }
287 302
288 if ((~temp[0] & AMD_SMB_STS_DONE) || (temp[0] & AMD_SMB_STS_STATUS)) 303 if ((~temp[0] & AMD_SMB_STS_DONE) || (temp[0] & AMD_SMB_STS_STATUS))
289 return -1; 304 return -EIO;
290 305
291 if (read_write == I2C_SMBUS_WRITE) 306 if (read_write == I2C_SMBUS_WRITE)
292 return 0; 307 return 0;
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index b0f771fe4326..7d6d9dfcc58a 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -151,7 +151,7 @@ static int i801_transaction(int xact)
151 outb_p(temp, SMBHSTSTS); 151 outb_p(temp, SMBHSTSTS);
152 if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) { 152 if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) {
153 dev_dbg(&I801_dev->dev, "Failed! (%02x)\n", temp); 153 dev_dbg(&I801_dev->dev, "Failed! (%02x)\n", temp);
154 return -1; 154 return -EBUSY;
155 } else { 155 } else {
156 dev_dbg(&I801_dev->dev, "Successful!\n"); 156 dev_dbg(&I801_dev->dev, "Successful!\n");
157 } 157 }
@@ -170,7 +170,7 @@ static int i801_transaction(int xact)
170 /* If the SMBus is still busy, we give up */ 170 /* If the SMBus is still busy, we give up */
171 if (timeout >= MAX_TIMEOUT) { 171 if (timeout >= MAX_TIMEOUT) {
172 dev_dbg(&I801_dev->dev, "SMBus Timeout!\n"); 172 dev_dbg(&I801_dev->dev, "SMBus Timeout!\n");
173 result = -1; 173 result = -ETIMEDOUT;
174 /* try to stop the current command */ 174 /* try to stop the current command */
175 dev_dbg(&I801_dev->dev, "Terminating the current operation\n"); 175 dev_dbg(&I801_dev->dev, "Terminating the current operation\n");
176 outb_p(inb_p(SMBHSTCNT) | SMBHSTCNT_KILL, SMBHSTCNT); 176 outb_p(inb_p(SMBHSTCNT) | SMBHSTCNT_KILL, SMBHSTCNT);
@@ -179,19 +179,19 @@ static int i801_transaction(int xact)
179 } 179 }
180 180
181 if (temp & SMBHSTSTS_FAILED) { 181 if (temp & SMBHSTSTS_FAILED) {
182 result = -1; 182 result = -EIO;
183 dev_dbg(&I801_dev->dev, "Error: Failed bus transaction\n"); 183 dev_dbg(&I801_dev->dev, "Error: Failed bus transaction\n");
184 } 184 }
185 185
186 if (temp & SMBHSTSTS_BUS_ERR) { 186 if (temp & SMBHSTSTS_BUS_ERR) {
187 result = -1; 187 result = -EIO;
188 dev_err(&I801_dev->dev, "Bus collision! SMBus may be locked " 188 dev_err(&I801_dev->dev, "Bus collision! SMBus may be locked "
189 "until next hard reset. (sorry!)\n"); 189 "until next hard reset. (sorry!)\n");
190 /* Clock stops and slave is stuck in mid-transmission */ 190 /* Clock stops and slave is stuck in mid-transmission */
191 } 191 }
192 192
193 if (temp & SMBHSTSTS_DEV_ERR) { 193 if (temp & SMBHSTSTS_DEV_ERR) {
194 result = -1; 194 result = -ENXIO;
195 dev_dbg(&I801_dev->dev, "Error: no response!\n"); 195 dev_dbg(&I801_dev->dev, "Error: no response!\n");
196 } 196 }
197 197
@@ -231,6 +231,7 @@ static int i801_block_transaction_by_block(union i2c_smbus_data *data,
231 char read_write, int hwpec) 231 char read_write, int hwpec)
232{ 232{
233 int i, len; 233 int i, len;
234 int status;
234 235
235 inb_p(SMBHSTCNT); /* reset the data buffer index */ 236 inb_p(SMBHSTCNT); /* reset the data buffer index */
236 237
@@ -242,14 +243,15 @@ static int i801_block_transaction_by_block(union i2c_smbus_data *data,
242 outb_p(data->block[i+1], SMBBLKDAT); 243 outb_p(data->block[i+1], SMBBLKDAT);
243 } 244 }
244 245
245 if (i801_transaction(I801_BLOCK_DATA | ENABLE_INT9 | 246 status = i801_transaction(I801_BLOCK_DATA | ENABLE_INT9 |
246 I801_PEC_EN * hwpec)) 247 I801_PEC_EN * hwpec);
247 return -1; 248 if (status)
249 return status;
248 250
249 if (read_write == I2C_SMBUS_READ) { 251 if (read_write == I2C_SMBUS_READ) {
250 len = inb_p(SMBHSTDAT0); 252 len = inb_p(SMBHSTDAT0);
251 if (len < 1 || len > I2C_SMBUS_BLOCK_MAX) 253 if (len < 1 || len > I2C_SMBUS_BLOCK_MAX)
252 return -1; 254 return -EPROTO;
253 255
254 data->block[0] = len; 256 data->block[0] = len;
255 for (i = 0; i < len; i++) 257 for (i = 0; i < len; i++)
@@ -314,11 +316,11 @@ static int i801_block_transaction_byte_by_byte(union i2c_smbus_data *data,
314 if (((temp = inb_p(SMBHSTSTS)) & errmask) != 0x00) { 316 if (((temp = inb_p(SMBHSTSTS)) & errmask) != 0x00) {
315 dev_err(&I801_dev->dev, 317 dev_err(&I801_dev->dev,
316 "Reset failed! (%02x)\n", temp); 318 "Reset failed! (%02x)\n", temp);
317 return -1; 319 return -EBUSY;
318 } 320 }
319 if (i != 1) 321 if (i != 1)
320 /* if die in middle of block transaction, fail */ 322 /* if die in middle of block transaction, fail */
321 return -1; 323 return -EIO;
322 } 324 }
323 325
324 if (i == 1) 326 if (i == 1)
@@ -342,19 +344,19 @@ static int i801_block_transaction_byte_by_byte(union i2c_smbus_data *data,
342 msleep(1); 344 msleep(1);
343 outb_p(inb_p(SMBHSTCNT) & (~SMBHSTCNT_KILL), 345 outb_p(inb_p(SMBHSTCNT) & (~SMBHSTCNT_KILL),
344 SMBHSTCNT); 346 SMBHSTCNT);
345 result = -1; 347 result = -ETIMEDOUT;
346 dev_dbg(&I801_dev->dev, "SMBus Timeout!\n"); 348 dev_dbg(&I801_dev->dev, "SMBus Timeout!\n");
347 } 349 }
348 350
349 if (temp & SMBHSTSTS_FAILED) { 351 if (temp & SMBHSTSTS_FAILED) {
350 result = -1; 352 result = -EIO;
351 dev_dbg(&I801_dev->dev, 353 dev_dbg(&I801_dev->dev,
352 "Error: Failed bus transaction\n"); 354 "Error: Failed bus transaction\n");
353 } else if (temp & SMBHSTSTS_BUS_ERR) { 355 } else if (temp & SMBHSTSTS_BUS_ERR) {
354 result = -1; 356 result = -EIO;
355 dev_err(&I801_dev->dev, "Bus collision!\n"); 357 dev_err(&I801_dev->dev, "Bus collision!\n");
356 } else if (temp & SMBHSTSTS_DEV_ERR) { 358 } else if (temp & SMBHSTSTS_DEV_ERR) {
357 result = -1; 359 result = -ENXIO;
358 dev_dbg(&I801_dev->dev, "Error: no response!\n"); 360 dev_dbg(&I801_dev->dev, "Error: no response!\n");
359 } 361 }
360 362
@@ -362,7 +364,7 @@ static int i801_block_transaction_byte_by_byte(union i2c_smbus_data *data,
362 && command != I2C_SMBUS_I2C_BLOCK_DATA) { 364 && command != I2C_SMBUS_I2C_BLOCK_DATA) {
363 len = inb_p(SMBHSTDAT0); 365 len = inb_p(SMBHSTDAT0);
364 if (len < 1 || len > I2C_SMBUS_BLOCK_MAX) 366 if (len < 1 || len > I2C_SMBUS_BLOCK_MAX)
365 return -1; 367 return -EPROTO;
366 data->block[0] = len; 368 data->block[0] = len;
367 } 369 }
368 370
@@ -394,7 +396,7 @@ static int i801_set_block_buffer_mode(void)
394{ 396{
395 outb_p(inb_p(SMBAUXCTL) | SMBAUXCTL_E32B, SMBAUXCTL); 397 outb_p(inb_p(SMBAUXCTL) | SMBAUXCTL_E32B, SMBAUXCTL);
396 if ((inb_p(SMBAUXCTL) & SMBAUXCTL_E32B) == 0) 398 if ((inb_p(SMBAUXCTL) & SMBAUXCTL_E32B) == 0)
397 return -1; 399 return -EIO;
398 return 0; 400 return 0;
399} 401}
400 402
@@ -414,7 +416,7 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
414 } else if (!(i801_features & FEATURE_I2C_BLOCK_READ)) { 416 } else if (!(i801_features & FEATURE_I2C_BLOCK_READ)) {
415 dev_err(&I801_dev->dev, 417 dev_err(&I801_dev->dev,
416 "I2C block read is unsupported!\n"); 418 "I2C block read is unsupported!\n");
417 return -1; 419 return -EOPNOTSUPP;
418 } 420 }
419 } 421 }
420 422
@@ -449,7 +451,7 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
449 return result; 451 return result;
450} 452}
451 453
452/* Return -1 on error. */ 454/* Return negative errno on error. */
453static s32 i801_access(struct i2c_adapter * adap, u16 addr, 455static s32 i801_access(struct i2c_adapter * adap, u16 addr,
454 unsigned short flags, char read_write, u8 command, 456 unsigned short flags, char read_write, u8 command,
455 int size, union i2c_smbus_data * data) 457 int size, union i2c_smbus_data * data)
@@ -514,7 +516,7 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr,
514 case I2C_SMBUS_PROC_CALL: 516 case I2C_SMBUS_PROC_CALL:
515 default: 517 default:
516 dev_err(&I801_dev->dev, "Unsupported transaction %d\n", size); 518 dev_err(&I801_dev->dev, "Unsupported transaction %d\n", size);
517 return -1; 519 return -EOPNOTSUPP;
518 } 520 }
519 521
520 if (hwpec) /* enable/disable hardware PEC */ 522 if (hwpec) /* enable/disable hardware PEC */
@@ -537,7 +539,7 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr,
537 if(block) 539 if(block)
538 return ret; 540 return ret;
539 if(ret) 541 if(ret)
540 return -1; 542 return ret;
541 if ((read_write == I2C_SMBUS_WRITE) || (xact == I801_QUICK)) 543 if ((read_write == I2C_SMBUS_WRITE) || (xact == I801_QUICK))
542 return 0; 544 return 0;
543 545
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index f95efff9b3d1..081fdf3393f4 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -172,16 +172,16 @@ static int nforce2_check_status(struct i2c_adapter *adap)
172 dev_dbg(&adap->dev, "SMBus Timeout!\n"); 172 dev_dbg(&adap->dev, "SMBus Timeout!\n");
173 if (smbus->can_abort) 173 if (smbus->can_abort)
174 nforce2_abort(adap); 174 nforce2_abort(adap);
175 return -1; 175 return -ETIMEDOUT;
176 } 176 }
177 if (!(temp & NVIDIA_SMB_STS_DONE) || (temp & NVIDIA_SMB_STS_STATUS)) { 177 if (!(temp & NVIDIA_SMB_STS_DONE) || (temp & NVIDIA_SMB_STS_STATUS)) {
178 dev_dbg(&adap->dev, "Transaction failed (0x%02x)!\n", temp); 178 dev_dbg(&adap->dev, "Transaction failed (0x%02x)!\n", temp);
179 return -1; 179 return -EIO;
180 } 180 }
181 return 0; 181 return 0;
182} 182}
183 183
184/* Return -1 on error */ 184/* Return negative errno on error */
185static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, 185static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
186 unsigned short flags, char read_write, 186 unsigned short flags, char read_write,
187 u8 command, int size, union i2c_smbus_data * data) 187 u8 command, int size, union i2c_smbus_data * data)
@@ -189,7 +189,7 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
189 struct nforce2_smbus *smbus = adap->algo_data; 189 struct nforce2_smbus *smbus = adap->algo_data;
190 unsigned char protocol, pec; 190 unsigned char protocol, pec;
191 u8 len; 191 u8 len;
192 int i; 192 int i, status;
193 193
194 protocol = (read_write == I2C_SMBUS_READ) ? NVIDIA_SMB_PRTCL_READ : 194 protocol = (read_write == I2C_SMBUS_READ) ? NVIDIA_SMB_PRTCL_READ :
195 NVIDIA_SMB_PRTCL_WRITE; 195 NVIDIA_SMB_PRTCL_WRITE;
@@ -233,7 +233,7 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
233 "Transaction failed " 233 "Transaction failed "
234 "(requested block size: %d)\n", 234 "(requested block size: %d)\n",
235 len); 235 len);
236 return -1; 236 return -EINVAL;
237 } 237 }
238 outb_p(len, NVIDIA_SMB_BCNT); 238 outb_p(len, NVIDIA_SMB_BCNT);
239 for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++) 239 for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++)
@@ -245,14 +245,15 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
245 245
246 default: 246 default:
247 dev_err(&adap->dev, "Unsupported transaction %d\n", size); 247 dev_err(&adap->dev, "Unsupported transaction %d\n", size);
248 return -1; 248 return -EOPNOTSUPP;
249 } 249 }
250 250
251 outb_p((addr & 0x7f) << 1, NVIDIA_SMB_ADDR); 251 outb_p((addr & 0x7f) << 1, NVIDIA_SMB_ADDR);
252 outb_p(protocol, NVIDIA_SMB_PRTCL); 252 outb_p(protocol, NVIDIA_SMB_PRTCL);
253 253
254 if (nforce2_check_status(adap)) 254 status = nforce2_check_status(adap);
255 return -1; 255 if (status)
256 return status;
256 257
257 if (read_write == I2C_SMBUS_WRITE) 258 if (read_write == I2C_SMBUS_WRITE)
258 return 0; 259 return 0;
@@ -274,7 +275,7 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
274 dev_err(&adap->dev, "Transaction failed " 275 dev_err(&adap->dev, "Transaction failed "
275 "(received block size: 0x%02x)\n", 276 "(received block size: 0x%02x)\n",
276 len); 277 len);
277 return -1; 278 return -EPROTO;
278 } 279 }
279 for (i = 0; i < len; i++) 280 for (i = 0; i < len; i++)
280 data->block[i+1] = inb_p(NVIDIA_SMB_DATA + i); 281 data->block[i+1] = inb_p(NVIDIA_SMB_DATA + i);
@@ -335,7 +336,7 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar,
335 != PCIBIOS_SUCCESSFUL) { 336 != PCIBIOS_SUCCESSFUL) {
336 dev_err(&dev->dev, "Error reading PCI config for %s\n", 337 dev_err(&dev->dev, "Error reading PCI config for %s\n",
337 name); 338 name);
338 return -1; 339 return -EIO;
339 } 340 }
340 341
341 smbus->base = iobase & PCI_BASE_ADDRESS_IO_MASK; 342 smbus->base = iobase & PCI_BASE_ADDRESS_IO_MASK;
@@ -345,7 +346,7 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar,
345 if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) { 346 if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) {
346 dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n", 347 dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n",
347 smbus->base, smbus->base+smbus->size-1, name); 348 smbus->base, smbus->base+smbus->size-1, name);
348 return -1; 349 return -EBUSY;
349 } 350 }
350 smbus->adapter.owner = THIS_MODULE; 351 smbus->adapter.owner = THIS_MODULE;
351 smbus->adapter.id = I2C_HW_SMBUS_NFORCE2; 352 smbus->adapter.id = I2C_HW_SMBUS_NFORCE2;
@@ -360,7 +361,7 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar,
360 if (error) { 361 if (error) {
361 dev_err(&smbus->adapter.dev, "Failed to register adapter.\n"); 362 dev_err(&smbus->adapter.dev, "Failed to register adapter.\n");
362 release_region(smbus->base, smbus->size); 363 release_region(smbus->base, smbus->size);
363 return -1; 364 return error;
364 } 365 }
365 dev_info(&smbus->adapter.dev, "nForce2 SMBus adapter at %#x\n", smbus->base); 366 dev_info(&smbus->adapter.dev, "nForce2 SMBus adapter at %#x\n", smbus->base);
366 return 0; 367 return 0;
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index ac9165968587..dc76c0e2dc65 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -253,7 +253,7 @@ static int piix4_transaction(void)
253 outb_p(temp, SMBHSTSTS); 253 outb_p(temp, SMBHSTSTS);
254 if ((temp = inb_p(SMBHSTSTS)) != 0x00) { 254 if ((temp = inb_p(SMBHSTSTS)) != 0x00) {
255 dev_err(&piix4_adapter.dev, "Failed! (%02x)\n", temp); 255 dev_err(&piix4_adapter.dev, "Failed! (%02x)\n", temp);
256 return -1; 256 return -EBUSY;
257 } else { 257 } else {
258 dev_dbg(&piix4_adapter.dev, "Successful!\n"); 258 dev_dbg(&piix4_adapter.dev, "Successful!\n");
259 } 259 }
@@ -275,23 +275,23 @@ static int piix4_transaction(void)
275 /* If the SMBus is still busy, we give up */ 275 /* If the SMBus is still busy, we give up */
276 if (timeout >= MAX_TIMEOUT) { 276 if (timeout >= MAX_TIMEOUT) {
277 dev_err(&piix4_adapter.dev, "SMBus Timeout!\n"); 277 dev_err(&piix4_adapter.dev, "SMBus Timeout!\n");
278 result = -1; 278 result = -ETIMEDOUT;
279 } 279 }
280 280
281 if (temp & 0x10) { 281 if (temp & 0x10) {
282 result = -1; 282 result = -EIO;
283 dev_err(&piix4_adapter.dev, "Error: Failed bus transaction\n"); 283 dev_err(&piix4_adapter.dev, "Error: Failed bus transaction\n");
284 } 284 }
285 285
286 if (temp & 0x08) { 286 if (temp & 0x08) {
287 result = -1; 287 result = -EIO;
288 dev_dbg(&piix4_adapter.dev, "Bus collision! SMBus may be " 288 dev_dbg(&piix4_adapter.dev, "Bus collision! SMBus may be "
289 "locked until next hard reset. (sorry!)\n"); 289 "locked until next hard reset. (sorry!)\n");
290 /* Clock stops and slave is stuck in mid-transmission */ 290 /* Clock stops and slave is stuck in mid-transmission */
291 } 291 }
292 292
293 if (temp & 0x04) { 293 if (temp & 0x04) {
294 result = -1; 294 result = -ENXIO;
295 dev_dbg(&piix4_adapter.dev, "Error: no response!\n"); 295 dev_dbg(&piix4_adapter.dev, "Error: no response!\n");
296 } 296 }
297 297
@@ -309,17 +309,18 @@ static int piix4_transaction(void)
309 return result; 309 return result;
310} 310}
311 311
312/* Return -1 on error. */ 312/* Return negative errno on error. */
313static s32 piix4_access(struct i2c_adapter * adap, u16 addr, 313static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
314 unsigned short flags, char read_write, 314 unsigned short flags, char read_write,
315 u8 command, int size, union i2c_smbus_data * data) 315 u8 command, int size, union i2c_smbus_data * data)
316{ 316{
317 int i, len; 317 int i, len;
318 int status;
318 319
319 switch (size) { 320 switch (size) {
320 case I2C_SMBUS_PROC_CALL: 321 case I2C_SMBUS_PROC_CALL:
321 dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n"); 322 dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
322 return -1; 323 return -EOPNOTSUPP;
323 case I2C_SMBUS_QUICK: 324 case I2C_SMBUS_QUICK:
324 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), 325 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
325 SMBHSTADD); 326 SMBHSTADD);
@@ -371,8 +372,9 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
371 372
372 outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT); 373 outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT);
373 374
374 if (piix4_transaction()) /* Error in transaction */ 375 status = piix4_transaction();
375 return -1; 376 if (status)
377 return status;
376 378
377 if ((read_write == I2C_SMBUS_WRITE) || (size == PIIX4_QUICK)) 379 if ((read_write == I2C_SMBUS_WRITE) || (size == PIIX4_QUICK))
378 return 0; 380 return 0;
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c
index 9ca8f9155f95..328441bb5470 100644
--- a/drivers/i2c/busses/i2c-sis5595.c
+++ b/drivers/i2c/busses/i2c-sis5595.c
@@ -236,7 +236,7 @@ static int sis5595_transaction(struct i2c_adapter *adap)
236 sis5595_write(SMB_STS_HI, temp >> 8); 236 sis5595_write(SMB_STS_HI, temp >> 8);
237 if ((temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8)) != 0x00) { 237 if ((temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8)) != 0x00) {
238 dev_dbg(&adap->dev, "Failed! (%02x)\n", temp); 238 dev_dbg(&adap->dev, "Failed! (%02x)\n", temp);
239 return -1; 239 return -EBUSY;
240 } else { 240 } else {
241 dev_dbg(&adap->dev, "Successful!\n"); 241 dev_dbg(&adap->dev, "Successful!\n");
242 } 242 }
@@ -254,19 +254,19 @@ static int sis5595_transaction(struct i2c_adapter *adap)
254 /* If the SMBus is still busy, we give up */ 254 /* If the SMBus is still busy, we give up */
255 if (timeout >= MAX_TIMEOUT) { 255 if (timeout >= MAX_TIMEOUT) {
256 dev_dbg(&adap->dev, "SMBus Timeout!\n"); 256 dev_dbg(&adap->dev, "SMBus Timeout!\n");
257 result = -1; 257 result = -ETIMEDOUT;
258 } 258 }
259 259
260 if (temp & 0x10) { 260 if (temp & 0x10) {
261 dev_dbg(&adap->dev, "Error: Failed bus transaction\n"); 261 dev_dbg(&adap->dev, "Error: Failed bus transaction\n");
262 result = -1; 262 result = -ENXIO;
263 } 263 }
264 264
265 if (temp & 0x20) { 265 if (temp & 0x20) {
266 dev_err(&adap->dev, "Bus collision! SMBus may be locked until " 266 dev_err(&adap->dev, "Bus collision! SMBus may be locked until "
267 "next hard reset (or not...)\n"); 267 "next hard reset (or not...)\n");
268 /* Clock stops and slave is stuck in mid-transmission */ 268 /* Clock stops and slave is stuck in mid-transmission */
269 result = -1; 269 result = -EIO;
270 } 270 }
271 271
272 temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8); 272 temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8);
@@ -282,11 +282,13 @@ static int sis5595_transaction(struct i2c_adapter *adap)
282 return result; 282 return result;
283} 283}
284 284
285/* Return -1 on error. */ 285/* Return negative errno on error. */
286static s32 sis5595_access(struct i2c_adapter *adap, u16 addr, 286static s32 sis5595_access(struct i2c_adapter *adap, u16 addr,
287 unsigned short flags, char read_write, 287 unsigned short flags, char read_write,
288 u8 command, int size, union i2c_smbus_data *data) 288 u8 command, int size, union i2c_smbus_data *data)
289{ 289{
290 int status;
291
290 switch (size) { 292 switch (size) {
291 case I2C_SMBUS_QUICK: 293 case I2C_SMBUS_QUICK:
292 sis5595_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01)); 294 sis5595_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01));
@@ -318,13 +320,14 @@ static s32 sis5595_access(struct i2c_adapter *adap, u16 addr,
318 break; 320 break;
319 default: 321 default:
320 dev_warn(&adap->dev, "Unsupported transaction %d\n", size); 322 dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
321 return -1; 323 return -EOPNOTSUPP;
322 } 324 }
323 325
324 sis5595_write(SMB_CTL_LO, ((size & 0x0E))); 326 sis5595_write(SMB_CTL_LO, ((size & 0x0E)));
325 327
326 if (sis5595_transaction(adap)) 328 status = sis5595_transaction(adap);
327 return -1; 329 if (status)
330 return status;
328 331
329 if ((size != SIS5595_PROC_CALL) && 332 if ((size != SIS5595_PROC_CALL) &&
330 ((read_write == I2C_SMBUS_WRITE) || (size == SIS5595_QUICK))) 333 ((read_write == I2C_SMBUS_WRITE) || (size == SIS5595_QUICK)))
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c
index 3765dd7f450f..c4cc5eddf50d 100644
--- a/drivers/i2c/busses/i2c-sis630.c
+++ b/drivers/i2c/busses/i2c-sis630.c
@@ -134,7 +134,7 @@ static int sis630_transaction_start(struct i2c_adapter *adap, int size, u8 *oldc
134 134
135 if ((temp = sis630_read(SMB_CNT) & 0x03) != 0x00) { 135 if ((temp = sis630_read(SMB_CNT) & 0x03) != 0x00) {
136 dev_dbg(&adap->dev, "Failed! (%02x)\n", temp); 136 dev_dbg(&adap->dev, "Failed! (%02x)\n", temp);
137 return -1; 137 return -EBUSY;
138 } else { 138 } else {
139 dev_dbg(&adap->dev, "Successful!\n"); 139 dev_dbg(&adap->dev, "Successful!\n");
140 } 140 }
@@ -177,17 +177,17 @@ static int sis630_transaction_wait(struct i2c_adapter *adap, int size)
177 /* If the SMBus is still busy, we give up */ 177 /* If the SMBus is still busy, we give up */
178 if (timeout >= MAX_TIMEOUT) { 178 if (timeout >= MAX_TIMEOUT) {
179 dev_dbg(&adap->dev, "SMBus Timeout!\n"); 179 dev_dbg(&adap->dev, "SMBus Timeout!\n");
180 result = -1; 180 result = -ETIMEDOUT;
181 } 181 }
182 182
183 if (temp & 0x02) { 183 if (temp & 0x02) {
184 dev_dbg(&adap->dev, "Error: Failed bus transaction\n"); 184 dev_dbg(&adap->dev, "Error: Failed bus transaction\n");
185 result = -1; 185 result = -ENXIO;
186 } 186 }
187 187
188 if (temp & 0x04) { 188 if (temp & 0x04) {
189 dev_err(&adap->dev, "Bus collision!\n"); 189 dev_err(&adap->dev, "Bus collision!\n");
190 result = -1; 190 result = -EIO;
191 /* 191 /*
192 TBD: Datasheet say: 192 TBD: Datasheet say:
193 the software should clear this bit and restart SMBUS operation. 193 the software should clear this bit and restart SMBUS operation.
@@ -250,8 +250,10 @@ static int sis630_block_data(struct i2c_adapter *adap, union i2c_smbus_data *dat
250 if (i==8 || (len<8 && i==len)) { 250 if (i==8 || (len<8 && i==len)) {
251 dev_dbg(&adap->dev, "start trans len=%d i=%d\n",len ,i); 251 dev_dbg(&adap->dev, "start trans len=%d i=%d\n",len ,i);
252 /* first transaction */ 252 /* first transaction */
253 if (sis630_transaction_start(adap, SIS630_BLOCK_DATA, &oldclock)) 253 rc = sis630_transaction_start(adap,
254 return -1; 254 SIS630_BLOCK_DATA, &oldclock);
255 if (rc)
256 return rc;
255 } 257 }
256 else if ((i-1)%8 == 7 || i==len) { 258 else if ((i-1)%8 == 7 || i==len) {
257 dev_dbg(&adap->dev, "trans_wait len=%d i=%d\n",len,i); 259 dev_dbg(&adap->dev, "trans_wait len=%d i=%d\n",len,i);
@@ -264,9 +266,10 @@ static int sis630_block_data(struct i2c_adapter *adap, union i2c_smbus_data *dat
264 */ 266 */
265 sis630_write(SMB_STS,0x10); 267 sis630_write(SMB_STS,0x10);
266 } 268 }
267 if (sis630_transaction_wait(adap, SIS630_BLOCK_DATA)) { 269 rc = sis630_transaction_wait(adap,
270 SIS630_BLOCK_DATA);
271 if (rc) {
268 dev_dbg(&adap->dev, "trans_wait failed\n"); 272 dev_dbg(&adap->dev, "trans_wait failed\n");
269 rc = -1;
270 break; 273 break;
271 } 274 }
272 } 275 }
@@ -275,13 +278,14 @@ static int sis630_block_data(struct i2c_adapter *adap, union i2c_smbus_data *dat
275 else { 278 else {
276 /* read request */ 279 /* read request */
277 data->block[0] = len = 0; 280 data->block[0] = len = 0;
278 if (sis630_transaction_start(adap, SIS630_BLOCK_DATA, &oldclock)) { 281 rc = sis630_transaction_start(adap,
279 return -1; 282 SIS630_BLOCK_DATA, &oldclock);
280 } 283 if (rc)
284 return rc;
281 do { 285 do {
282 if (sis630_transaction_wait(adap, SIS630_BLOCK_DATA)) { 286 rc = sis630_transaction_wait(adap, SIS630_BLOCK_DATA);
287 if (rc) {
283 dev_dbg(&adap->dev, "trans_wait failed\n"); 288 dev_dbg(&adap->dev, "trans_wait failed\n");
284 rc = -1;
285 break; 289 break;
286 } 290 }
287 /* if this first transaction then read byte count */ 291 /* if this first transaction then read byte count */
@@ -311,11 +315,13 @@ static int sis630_block_data(struct i2c_adapter *adap, union i2c_smbus_data *dat
311 return rc; 315 return rc;
312} 316}
313 317
314/* Return -1 on error. */ 318/* Return negative errno on error. */
315static s32 sis630_access(struct i2c_adapter *adap, u16 addr, 319static s32 sis630_access(struct i2c_adapter *adap, u16 addr,
316 unsigned short flags, char read_write, 320 unsigned short flags, char read_write,
317 u8 command, int size, union i2c_smbus_data *data) 321 u8 command, int size, union i2c_smbus_data *data)
318{ 322{
323 int status;
324
319 switch (size) { 325 switch (size) {
320 case I2C_SMBUS_QUICK: 326 case I2C_SMBUS_QUICK:
321 sis630_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01)); 327 sis630_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01));
@@ -350,13 +356,13 @@ static s32 sis630_access(struct i2c_adapter *adap, u16 addr,
350 size = SIS630_BLOCK_DATA; 356 size = SIS630_BLOCK_DATA;
351 return sis630_block_data(adap, data, read_write); 357 return sis630_block_data(adap, data, read_write);
352 default: 358 default:
353 printk("Unsupported I2C size\n"); 359 printk("Unsupported SMBus operation\n");
354 return -1; 360 return -EOPNOTSUPP;
355 break;
356 } 361 }
357 362
358 if (sis630_transaction(adap, size)) 363 status = sis630_transaction(adap, size);
359 return -1; 364 if (status)
365 return status;
360 366
361 if ((size != SIS630_PCALL) && 367 if ((size != SIS630_PCALL) &&
362 ((read_write == I2C_SMBUS_WRITE) || (size == SIS630_QUICK))) { 368 ((read_write == I2C_SMBUS_WRITE) || (size == SIS630_QUICK))) {
@@ -373,8 +379,7 @@ static s32 sis630_access(struct i2c_adapter *adap, u16 addr,
373 data->word = sis630_read(SMB_BYTE) + (sis630_read(SMB_BYTE + 1) << 8); 379 data->word = sis630_read(SMB_BYTE) + (sis630_read(SMB_BYTE + 1) << 8);
374 break; 380 break;
375 default: 381 default:
376 return -1; 382 return -EOPNOTSUPP;
377 break;
378 } 383 }
379 384
380 return 0; 385 return 0;
diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c
index dc235bb8e24d..29757b2e11dd 100644
--- a/drivers/i2c/busses/i2c-sis96x.c
+++ b/drivers/i2c/busses/i2c-sis96x.c
@@ -111,7 +111,7 @@ static int sis96x_transaction(int size)
111 /* check it again */ 111 /* check it again */
112 if (((temp = sis96x_read(SMB_CNT)) & 0x03) != 0x00) { 112 if (((temp = sis96x_read(SMB_CNT)) & 0x03) != 0x00) {
113 dev_dbg(&sis96x_adapter.dev, "Failed (0x%02x)\n", temp); 113 dev_dbg(&sis96x_adapter.dev, "Failed (0x%02x)\n", temp);
114 return -1; 114 return -EBUSY;
115 } else { 115 } else {
116 dev_dbg(&sis96x_adapter.dev, "Successful\n"); 116 dev_dbg(&sis96x_adapter.dev, "Successful\n");
117 } 117 }
@@ -136,19 +136,19 @@ static int sis96x_transaction(int size)
136 /* If the SMBus is still busy, we give up */ 136 /* If the SMBus is still busy, we give up */
137 if (timeout >= MAX_TIMEOUT) { 137 if (timeout >= MAX_TIMEOUT) {
138 dev_dbg(&sis96x_adapter.dev, "SMBus Timeout! (0x%02x)\n", temp); 138 dev_dbg(&sis96x_adapter.dev, "SMBus Timeout! (0x%02x)\n", temp);
139 result = -1; 139 result = -ETIMEDOUT;
140 } 140 }
141 141
142 /* device error - probably missing ACK */ 142 /* device error - probably missing ACK */
143 if (temp & 0x02) { 143 if (temp & 0x02) {
144 dev_dbg(&sis96x_adapter.dev, "Failed bus transaction!\n"); 144 dev_dbg(&sis96x_adapter.dev, "Failed bus transaction!\n");
145 result = -1; 145 result = -ENXIO;
146 } 146 }
147 147
148 /* bus collision */ 148 /* bus collision */
149 if (temp & 0x04) { 149 if (temp & 0x04) {
150 dev_dbg(&sis96x_adapter.dev, "Bus collision!\n"); 150 dev_dbg(&sis96x_adapter.dev, "Bus collision!\n");
151 result = -1; 151 result = -EIO;
152 } 152 }
153 153
154 /* Finish up by resetting the bus */ 154 /* Finish up by resetting the bus */
@@ -161,11 +161,12 @@ static int sis96x_transaction(int size)
161 return result; 161 return result;
162} 162}
163 163
164/* Return -1 on error. */ 164/* Return negative errno on error. */
165static s32 sis96x_access(struct i2c_adapter * adap, u16 addr, 165static s32 sis96x_access(struct i2c_adapter * adap, u16 addr,
166 unsigned short flags, char read_write, 166 unsigned short flags, char read_write,
167 u8 command, int size, union i2c_smbus_data * data) 167 u8 command, int size, union i2c_smbus_data * data)
168{ 168{
169 int status;
169 170
170 switch (size) { 171 switch (size) {
171 case I2C_SMBUS_QUICK: 172 case I2C_SMBUS_QUICK:
@@ -203,17 +204,17 @@ static s32 sis96x_access(struct i2c_adapter * adap, u16 addr,
203 case I2C_SMBUS_BLOCK_DATA: 204 case I2C_SMBUS_BLOCK_DATA:
204 /* TO DO: */ 205 /* TO DO: */
205 dev_info(&adap->dev, "SMBus block not implemented!\n"); 206 dev_info(&adap->dev, "SMBus block not implemented!\n");
206 return -1; 207 return -EOPNOTSUPP;
207 break; 208 break;
208 209
209 default: 210 default:
210 dev_info(&adap->dev, "Unsupported I2C size\n"); 211 dev_info(&adap->dev, "Unsupported SMBus operation\n");
211 return -1; 212 return -EOPNOTSUPP;
212 break;
213 } 213 }
214 214
215 if (sis96x_transaction(size)) 215 status = sis96x_transaction(size);
216 return -1; 216 if (status)
217 return status;
217 218
218 if ((size != SIS96x_PROC_CALL) && 219 if ((size != SIS96x_PROC_CALL) &&
219 ((read_write == I2C_SMBUS_WRITE) || (size == SIS96x_QUICK))) 220 ((read_write == I2C_SMBUS_WRITE) || (size == SIS96x_QUICK)))
diff --git a/drivers/i2c/busses/i2c-stub.c b/drivers/i2c/busses/i2c-stub.c
index d08eeec53913..e37ccd80f77a 100644
--- a/drivers/i2c/busses/i2c-stub.c
+++ b/drivers/i2c/busses/i2c-stub.c
@@ -43,7 +43,7 @@ struct stub_chip {
43 43
44static struct stub_chip *stub_chips; 44static struct stub_chip *stub_chips;
45 45
46/* Return -1 on error. */ 46/* Return negative errno on error. */
47static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags, 47static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags,
48 char read_write, u8 command, int size, union i2c_smbus_data * data) 48 char read_write, u8 command, int size, union i2c_smbus_data * data)
49{ 49{
@@ -120,7 +120,7 @@ static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags,
120 120
121 default: 121 default:
122 dev_dbg(&adap->dev, "Unsupported I2C/SMBus command\n"); 122 dev_dbg(&adap->dev, "Unsupported I2C/SMBus command\n");
123 ret = -1; 123 ret = -EOPNOTSUPP;
124 break; 124 break;
125 } /* switch (size) */ 125 } /* switch (size) */
126 126
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
index 77b13d027f86..7628fe8e0946 100644
--- a/drivers/i2c/busses/i2c-viapro.c
+++ b/drivers/i2c/busses/i2c-viapro.c
@@ -152,7 +152,7 @@ static int vt596_transaction(u8 size)
152 if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { 152 if ((temp = inb_p(SMBHSTSTS)) & 0x1F) {
153 dev_err(&vt596_adapter.dev, "SMBus reset failed! " 153 dev_err(&vt596_adapter.dev, "SMBus reset failed! "
154 "(0x%02x)\n", temp); 154 "(0x%02x)\n", temp);
155 return -1; 155 return -EBUSY;
156 } 156 }
157 } 157 }
158 158
@@ -167,24 +167,24 @@ static int vt596_transaction(u8 size)
167 167
168 /* If the SMBus is still busy, we give up */ 168 /* If the SMBus is still busy, we give up */
169 if (timeout >= MAX_TIMEOUT) { 169 if (timeout >= MAX_TIMEOUT) {
170 result = -1; 170 result = -ETIMEDOUT;
171 dev_err(&vt596_adapter.dev, "SMBus timeout!\n"); 171 dev_err(&vt596_adapter.dev, "SMBus timeout!\n");
172 } 172 }
173 173
174 if (temp & 0x10) { 174 if (temp & 0x10) {
175 result = -1; 175 result = -EIO;
176 dev_err(&vt596_adapter.dev, "Transaction failed (0x%02x)\n", 176 dev_err(&vt596_adapter.dev, "Transaction failed (0x%02x)\n",
177 size); 177 size);
178 } 178 }
179 179
180 if (temp & 0x08) { 180 if (temp & 0x08) {
181 result = -1; 181 result = -EIO;
182 dev_err(&vt596_adapter.dev, "SMBus collision!\n"); 182 dev_err(&vt596_adapter.dev, "SMBus collision!\n");
183 } 183 }
184 184
185 if (temp & 0x04) { 185 if (temp & 0x04) {
186 int read = inb_p(SMBHSTADD) & 0x01; 186 int read = inb_p(SMBHSTADD) & 0x01;
187 result = -1; 187 result = -ENXIO;
188 /* The quick and receive byte commands are used to probe 188 /* The quick and receive byte commands are used to probe
189 for chips, so errors are expected, and we don't want 189 for chips, so errors are expected, and we don't want
190 to frighten the user. */ 190 to frighten the user. */
@@ -202,12 +202,13 @@ static int vt596_transaction(u8 size)
202 return result; 202 return result;
203} 203}
204 204
205/* Return -1 on error, 0 on success */ 205/* Return negative errno on error, 0 on success */
206static s32 vt596_access(struct i2c_adapter *adap, u16 addr, 206static s32 vt596_access(struct i2c_adapter *adap, u16 addr,
207 unsigned short flags, char read_write, u8 command, 207 unsigned short flags, char read_write, u8 command,
208 int size, union i2c_smbus_data *data) 208 int size, union i2c_smbus_data *data)
209{ 209{
210 int i; 210 int i;
211 int status;
211 212
212 switch (size) { 213 switch (size) {
213 case I2C_SMBUS_QUICK: 214 case I2C_SMBUS_QUICK:
@@ -258,8 +259,9 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr,
258 259
259 outb_p(((addr & 0x7f) << 1) | read_write, SMBHSTADD); 260 outb_p(((addr & 0x7f) << 1) | read_write, SMBHSTADD);
260 261
261 if (vt596_transaction(size)) /* Error in transaction */ 262 status = vt596_transaction(size);
262 return -1; 263 if (status)
264 return status;
263 265
264 if ((read_write == I2C_SMBUS_WRITE) || (size == VT596_QUICK)) 266 if ((read_write == I2C_SMBUS_WRITE) || (size == VT596_QUICK))
265 return 0; 267 return 0;
@@ -287,7 +289,7 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr,
287exit_unsupported: 289exit_unsupported:
288 dev_warn(&vt596_adapter.dev, "Unsupported command invoked! (0x%02x)\n", 290 dev_warn(&vt596_adapter.dev, "Unsupported command invoked! (0x%02x)\n",
289 size); 291 size);
290 return -1; 292 return -EOPNOTSUPP;
291} 293}
292 294
293static u32 vt596_func(struct i2c_adapter *adapter) 295static u32 vt596_func(struct i2c_adapter *adapter)