diff options
author | David Brownell <david-b@pacbell.net> | 2008-07-14 16:38:25 -0400 |
---|---|---|
committer | Jean Delvare <khali@mahadeva.delvare> | 2008-07-14 16:38:25 -0400 |
commit | 97140342e69d479a3ad82bfd4c154c0b08fe3eea (patch) | |
tree | 2ee2ad225c7e4850a30bc57c4bf07251c1da1085 /drivers/i2c/busses/i2c-sis5595.c | |
parent | 6ea438ec8da4ec56bf415f5ea360e6b0cb59c6c3 (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-sis5595.c')
-rw-r--r-- | drivers/i2c/busses/i2c-sis5595.c | 19 |
1 files changed, 11 insertions, 8 deletions
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. */ |
286 | static s32 sis5595_access(struct i2c_adapter *adap, u16 addr, | 286 | static 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))) |