aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-sis5595.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-07-15 14:16:05 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-15 14:16:05 -0400
commitdc221eae08eea3b0db127d1f152fac24d10b6a52 (patch)
treeeea4cc64f2568db6aea94b9491120525ebcd738f /drivers/i2c/busses/i2c-sis5595.c
parent98339cbd360b77c3167db287fd611468c2c44559 (diff)
parent4735c98f8447acb1c8977e2b8024640f7bf36dd6 (diff)
Merge branch 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6
* 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6: (56 commits) i2c: Add detection capability to new-style drivers i2c: Call client_unregister for new-style devices too i2c: Clean up old chip drivers i2c-ibm_iic: Register child nodes i2c: New-style EEPROM driver using device IDs i2c: Export the i2c_bus_type symbol i2c-au1550: Fix PM support i2c-dev: Delete empty detach_client callback i2c: Drop stray references to lm_sensors i2c: Check for ACPI resource conflicts i2c-ocores: basic PM support i2c-sibyte: SWARM I2C board initialization i2c-i801: Fix handling of error conditions i2c-i801: Rename local variable temp to status i2c-i801: Properly report bus arbitration loss i2c-i801: Remove verbose debugging messages i2c-algo-pcf: Drop unused struct members i2c-algo-pcf: Multi-master lost-arbitration improvement i2c: Deprecate the legacy gpio drivers i2c-pxa: Initialize early ...
Diffstat (limited to 'drivers/i2c/busses/i2c-sis5595.c')
-rw-r--r--drivers/i2c/busses/i2c-sis5595.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c
index 9ca8f9155f95..dfc2d5eb6a68 100644
--- a/drivers/i2c/busses/i2c-sis5595.c
+++ b/drivers/i2c/busses/i2c-sis5595.c
@@ -1,6 +1,4 @@
1/* 1/*
2 sis5595.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> and 2 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> and
5 Philip Edelbrock <phil@netroedge.com> 3 Philip Edelbrock <phil@netroedge.com>
6 4
@@ -62,6 +60,7 @@
62#include <linux/ioport.h> 60#include <linux/ioport.h>
63#include <linux/init.h> 61#include <linux/init.h>
64#include <linux/i2c.h> 62#include <linux/i2c.h>
63#include <linux/acpi.h>
65#include <asm/io.h> 64#include <asm/io.h>
66 65
67static int blacklist[] = { 66static int blacklist[] = {
@@ -174,6 +173,11 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev)
174 173
175 /* NB: We grab just the two SMBus registers here, but this may still 174 /* NB: We grab just the two SMBus registers here, but this may still
176 * interfere with ACPI :-( */ 175 * interfere with ACPI :-( */
176 retval = acpi_check_region(sis5595_base + SMB_INDEX, 2,
177 sis5595_driver.name);
178 if (retval)
179 return retval;
180
177 if (!request_region(sis5595_base + SMB_INDEX, 2, 181 if (!request_region(sis5595_base + SMB_INDEX, 2,
178 sis5595_driver.name)) { 182 sis5595_driver.name)) {
179 dev_err(&SIS5595_dev->dev, "SMBus registers 0x%04x-0x%04x already in use!\n", 183 dev_err(&SIS5595_dev->dev, "SMBus registers 0x%04x-0x%04x already in use!\n",
@@ -236,7 +240,7 @@ static int sis5595_transaction(struct i2c_adapter *adap)
236 sis5595_write(SMB_STS_HI, temp >> 8); 240 sis5595_write(SMB_STS_HI, temp >> 8);
237 if ((temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8)) != 0x00) { 241 if ((temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8)) != 0x00) {
238 dev_dbg(&adap->dev, "Failed! (%02x)\n", temp); 242 dev_dbg(&adap->dev, "Failed! (%02x)\n", temp);
239 return -1; 243 return -EBUSY;
240 } else { 244 } else {
241 dev_dbg(&adap->dev, "Successful!\n"); 245 dev_dbg(&adap->dev, "Successful!\n");
242 } 246 }
@@ -254,19 +258,19 @@ static int sis5595_transaction(struct i2c_adapter *adap)
254 /* If the SMBus is still busy, we give up */ 258 /* If the SMBus is still busy, we give up */
255 if (timeout >= MAX_TIMEOUT) { 259 if (timeout >= MAX_TIMEOUT) {
256 dev_dbg(&adap->dev, "SMBus Timeout!\n"); 260 dev_dbg(&adap->dev, "SMBus Timeout!\n");
257 result = -1; 261 result = -ETIMEDOUT;
258 } 262 }
259 263
260 if (temp & 0x10) { 264 if (temp & 0x10) {
261 dev_dbg(&adap->dev, "Error: Failed bus transaction\n"); 265 dev_dbg(&adap->dev, "Error: Failed bus transaction\n");
262 result = -1; 266 result = -ENXIO;
263 } 267 }
264 268
265 if (temp & 0x20) { 269 if (temp & 0x20) {
266 dev_err(&adap->dev, "Bus collision! SMBus may be locked until " 270 dev_err(&adap->dev, "Bus collision! SMBus may be locked until "
267 "next hard reset (or not...)\n"); 271 "next hard reset (or not...)\n");
268 /* Clock stops and slave is stuck in mid-transmission */ 272 /* Clock stops and slave is stuck in mid-transmission */
269 result = -1; 273 result = -EIO;
270 } 274 }
271 275
272 temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8); 276 temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8);
@@ -282,11 +286,13 @@ static int sis5595_transaction(struct i2c_adapter *adap)
282 return result; 286 return result;
283} 287}
284 288
285/* Return -1 on error. */ 289/* Return negative errno on error. */
286static s32 sis5595_access(struct i2c_adapter *adap, u16 addr, 290static s32 sis5595_access(struct i2c_adapter *adap, u16 addr,
287 unsigned short flags, char read_write, 291 unsigned short flags, char read_write,
288 u8 command, int size, union i2c_smbus_data *data) 292 u8 command, int size, union i2c_smbus_data *data)
289{ 293{
294 int status;
295
290 switch (size) { 296 switch (size) {
291 case I2C_SMBUS_QUICK: 297 case I2C_SMBUS_QUICK:
292 sis5595_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01)); 298 sis5595_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01));
@@ -318,13 +324,14 @@ static s32 sis5595_access(struct i2c_adapter *adap, u16 addr,
318 break; 324 break;
319 default: 325 default:
320 dev_warn(&adap->dev, "Unsupported transaction %d\n", size); 326 dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
321 return -1; 327 return -EOPNOTSUPP;
322 } 328 }
323 329
324 sis5595_write(SMB_CTL_LO, ((size & 0x0E))); 330 sis5595_write(SMB_CTL_LO, ((size & 0x0E)));
325 331
326 if (sis5595_transaction(adap)) 332 status = sis5595_transaction(adap);
327 return -1; 333 if (status)
334 return status;
328 335
329 if ((size != SIS5595_PROC_CALL) && 336 if ((size != SIS5595_PROC_CALL) &&
330 ((read_write == I2C_SMBUS_WRITE) || (size == SIS5595_QUICK))) 337 ((read_write == I2C_SMBUS_WRITE) || (size == SIS5595_QUICK)))
@@ -359,7 +366,7 @@ static const struct i2c_algorithm smbus_algorithm = {
359static struct i2c_adapter sis5595_adapter = { 366static struct i2c_adapter sis5595_adapter = {
360 .owner = THIS_MODULE, 367 .owner = THIS_MODULE,
361 .id = I2C_HW_SMBUS_SIS5595, 368 .id = I2C_HW_SMBUS_SIS5595,
362 .class = I2C_CLASS_HWMON, 369 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
363 .algo = &smbus_algorithm, 370 .algo = &smbus_algorithm,
364}; 371};
365 372