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-nforce2.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-nforce2.c')
-rw-r--r-- | drivers/i2c/busses/i2c-nforce2.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c index f95efff9b3d1..081fdf3393f4 100644 --- a/drivers/i2c/busses/i2c-nforce2.c +++ b/drivers/i2c/busses/i2c-nforce2.c | |||
@@ -172,16 +172,16 @@ static int nforce2_check_status(struct i2c_adapter *adap) | |||
172 | dev_dbg(&adap->dev, "SMBus Timeout!\n"); | 172 | dev_dbg(&adap->dev, "SMBus Timeout!\n"); |
173 | if (smbus->can_abort) | 173 | if (smbus->can_abort) |
174 | nforce2_abort(adap); | 174 | nforce2_abort(adap); |
175 | return -1; | 175 | return -ETIMEDOUT; |
176 | } | 176 | } |
177 | if (!(temp & NVIDIA_SMB_STS_DONE) || (temp & NVIDIA_SMB_STS_STATUS)) { | 177 | if (!(temp & NVIDIA_SMB_STS_DONE) || (temp & NVIDIA_SMB_STS_STATUS)) { |
178 | dev_dbg(&adap->dev, "Transaction failed (0x%02x)!\n", temp); | 178 | dev_dbg(&adap->dev, "Transaction failed (0x%02x)!\n", temp); |
179 | return -1; | 179 | return -EIO; |
180 | } | 180 | } |
181 | return 0; | 181 | return 0; |
182 | } | 182 | } |
183 | 183 | ||
184 | /* Return -1 on error */ | 184 | /* Return negative errno on error */ |
185 | static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, | 185 | static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, |
186 | unsigned short flags, char read_write, | 186 | unsigned short flags, char read_write, |
187 | u8 command, int size, union i2c_smbus_data * data) | 187 | u8 command, int size, union i2c_smbus_data * data) |
@@ -189,7 +189,7 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, | |||
189 | struct nforce2_smbus *smbus = adap->algo_data; | 189 | struct nforce2_smbus *smbus = adap->algo_data; |
190 | unsigned char protocol, pec; | 190 | unsigned char protocol, pec; |
191 | u8 len; | 191 | u8 len; |
192 | int i; | 192 | int i, status; |
193 | 193 | ||
194 | protocol = (read_write == I2C_SMBUS_READ) ? NVIDIA_SMB_PRTCL_READ : | 194 | protocol = (read_write == I2C_SMBUS_READ) ? NVIDIA_SMB_PRTCL_READ : |
195 | NVIDIA_SMB_PRTCL_WRITE; | 195 | NVIDIA_SMB_PRTCL_WRITE; |
@@ -233,7 +233,7 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, | |||
233 | "Transaction failed " | 233 | "Transaction failed " |
234 | "(requested block size: %d)\n", | 234 | "(requested block size: %d)\n", |
235 | len); | 235 | len); |
236 | return -1; | 236 | return -EINVAL; |
237 | } | 237 | } |
238 | outb_p(len, NVIDIA_SMB_BCNT); | 238 | outb_p(len, NVIDIA_SMB_BCNT); |
239 | for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++) | 239 | for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++) |
@@ -245,14 +245,15 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, | |||
245 | 245 | ||
246 | default: | 246 | default: |
247 | dev_err(&adap->dev, "Unsupported transaction %d\n", size); | 247 | dev_err(&adap->dev, "Unsupported transaction %d\n", size); |
248 | return -1; | 248 | return -EOPNOTSUPP; |
249 | } | 249 | } |
250 | 250 | ||
251 | outb_p((addr & 0x7f) << 1, NVIDIA_SMB_ADDR); | 251 | outb_p((addr & 0x7f) << 1, NVIDIA_SMB_ADDR); |
252 | outb_p(protocol, NVIDIA_SMB_PRTCL); | 252 | outb_p(protocol, NVIDIA_SMB_PRTCL); |
253 | 253 | ||
254 | if (nforce2_check_status(adap)) | 254 | status = nforce2_check_status(adap); |
255 | return -1; | 255 | if (status) |
256 | return status; | ||
256 | 257 | ||
257 | if (read_write == I2C_SMBUS_WRITE) | 258 | if (read_write == I2C_SMBUS_WRITE) |
258 | return 0; | 259 | return 0; |
@@ -274,7 +275,7 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, | |||
274 | dev_err(&adap->dev, "Transaction failed " | 275 | dev_err(&adap->dev, "Transaction failed " |
275 | "(received block size: 0x%02x)\n", | 276 | "(received block size: 0x%02x)\n", |
276 | len); | 277 | len); |
277 | return -1; | 278 | return -EPROTO; |
278 | } | 279 | } |
279 | for (i = 0; i < len; i++) | 280 | for (i = 0; i < len; i++) |
280 | data->block[i+1] = inb_p(NVIDIA_SMB_DATA + i); | 281 | data->block[i+1] = inb_p(NVIDIA_SMB_DATA + i); |
@@ -335,7 +336,7 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar, | |||
335 | != PCIBIOS_SUCCESSFUL) { | 336 | != PCIBIOS_SUCCESSFUL) { |
336 | dev_err(&dev->dev, "Error reading PCI config for %s\n", | 337 | dev_err(&dev->dev, "Error reading PCI config for %s\n", |
337 | name); | 338 | name); |
338 | return -1; | 339 | return -EIO; |
339 | } | 340 | } |
340 | 341 | ||
341 | smbus->base = iobase & PCI_BASE_ADDRESS_IO_MASK; | 342 | smbus->base = iobase & PCI_BASE_ADDRESS_IO_MASK; |
@@ -345,7 +346,7 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar, | |||
345 | if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) { | 346 | if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) { |
346 | dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n", | 347 | dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n", |
347 | smbus->base, smbus->base+smbus->size-1, name); | 348 | smbus->base, smbus->base+smbus->size-1, name); |
348 | return -1; | 349 | return -EBUSY; |
349 | } | 350 | } |
350 | smbus->adapter.owner = THIS_MODULE; | 351 | smbus->adapter.owner = THIS_MODULE; |
351 | smbus->adapter.id = I2C_HW_SMBUS_NFORCE2; | 352 | smbus->adapter.id = I2C_HW_SMBUS_NFORCE2; |
@@ -360,7 +361,7 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar, | |||
360 | if (error) { | 361 | if (error) { |
361 | dev_err(&smbus->adapter.dev, "Failed to register adapter.\n"); | 362 | dev_err(&smbus->adapter.dev, "Failed to register adapter.\n"); |
362 | release_region(smbus->base, smbus->size); | 363 | release_region(smbus->base, smbus->size); |
363 | return -1; | 364 | return error; |
364 | } | 365 | } |
365 | dev_info(&smbus->adapter.dev, "nForce2 SMBus adapter at %#x\n", smbus->base); | 366 | dev_info(&smbus->adapter.dev, "nForce2 SMBus adapter at %#x\n", smbus->base); |
366 | return 0; | 367 | return 0; |