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-ali1563.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-ali1563.c')
-rw-r--r-- | drivers/i2c/busses/i2c-ali1563.c | 23 |
1 files changed, 17 insertions, 6 deletions
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 | ||
128 | static int ali1563_block_start(struct i2c_adapter * a) | 131 | static 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 | ||
176 | static int ali1563_block(struct i2c_adapter * a, union i2c_smbus_data * data, u8 rw) | 187 | static int ali1563_block(struct i2c_adapter * a, union i2c_smbus_data * data, u8 rw) |