aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-amd756.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-amd756.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-amd756.c')
-rw-r--r--drivers/i2c/busses/i2c-amd756.c18
1 files changed, 10 insertions, 8 deletions
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;