aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-sis96x.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-sis96x.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-sis96x.c')
-rw-r--r--drivers/i2c/busses/i2c-sis96x.c23
1 files changed, 12 insertions, 11 deletions
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)))