aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-viapro.c
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2008-07-14 16:38:25 -0400
committerJean Delvare <khali@mahadeva.delvare>2008-07-14 16:38:25 -0400
commit97140342e69d479a3ad82bfd4c154c0b08fe3eea (patch)
tree2ee2ad225c7e4850a30bc57c4bf07251c1da1085 /drivers/i2c/busses/i2c-viapro.c
parent6ea438ec8da4ec56bf415f5ea360e6b0cb59c6c3 (diff)
i2c: Bus drivers return -Errno not -1
Tighten error paths used by various i2c adapters (mostly x86) so they return real fault/errno codes instead of a "-1" (which is most often interpreted as "-EPERM"). Build tested, with eyeball review. One minor initial goal is to have adapters consistently return the code "-ENXIO" when addressing a device doesn't get an ACK response, at least in the probe paths where they are already good at stifling related logspam. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/i2c/busses/i2c-viapro.c')
-rw-r--r--drivers/i2c/busses/i2c-viapro.c20
1 files changed, 11 insertions, 9 deletions
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)