From fd545796ee084a733a41d5ed295d1c5ca020ed15 Mon Sep 17 00:00:00 2001 From: Frodo Looijaard Date: Wed, 8 Dec 1999 20:37:09 +0000 Subject: [PATCH] Changes regarding the new i2c_check_addr function Changes in sensors.c: sensors_detect now skips addresses which are already taken. Even a force parameter can not override this, as it could lead to major problems. For ISA addresses, the same is done; but the client drivers still need a check if they claim more than one ISA address (as all of the current ISA clients do). Changes in chip drivers: Removed the comment about needing address registration Changes in i2cdetect.c: Marks addresses which are already claimed Changes in sensors-detect: Warns when an address is already claimed, and skips it. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@667 7894878c-1315-0410-8ee3-d5d059ff63e0 --- TODO | 2 +- kernel/chips/adm1021.c | 3 --- kernel/chips/adm9240.c | 3 --- kernel/chips/bt869.c | 3 --- kernel/chips/eeprom.c | 3 --- kernel/chips/gl518sm.c | 3 --- kernel/chips/gl520sm.c | 3 --- kernel/chips/lm75.c | 3 --- kernel/chips/lm78.c | 2 -- kernel/chips/lm80.c | 3 --- kernel/chips/ltc1710.c | 3 --- kernel/chips/matorb.c | 3 --- kernel/chips/thmc50.c | 3 --- kernel/chips/w83781d.c | 2 -- kernel/sensors.c | 4 ++++ prog/detect/i2cdetect.c | 11 ++++++++--- prog/detect/sensors-detect | 4 ++-- 17 files changed, 15 insertions(+), 43 deletions(-) diff --git a/TODO b/TODO index da221421..cfcdab62 100644 --- a/TODO +++ b/TODO @@ -25,7 +25,7 @@ KERNEL MODULES in Simon Vogl's i2c modules. * Better general locking, or at least a once-over to check no race-conditions remain. This is part of the SMP-safeness, and can better be done at once. -* Test SIS5595(/91/98) sensor support. Write generic i2c support. +* Test SIS5595(/91/98) sensor support and SMBus support Thomas Dickel owns one SIS5595. * adm9240: check whether the current voltage computations are correct. Probably not, as they are different from the datasheet specifications. diff --git a/kernel/chips/adm1021.c b/kernel/chips/adm1021.c index 1a10be6d..dc0e275e 100644 --- a/kernel/chips/adm1021.c +++ b/kernel/chips/adm1021.c @@ -213,9 +213,6 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_BYTE_DATA)) goto ERROR0; - /* We need address registration for the I2C bus too. That is not yet - implemented. */ - /* OK. For now, we presume we have a valid client. We now create the client structure, even though we cannot fill it completely yet. But it allows us to access adm1021_{read,write}_value. */ diff --git a/kernel/chips/adm9240.c b/kernel/chips/adm9240.c index 66d89ca2..4c0f48a1 100644 --- a/kernel/chips/adm9240.c +++ b/kernel/chips/adm9240.c @@ -367,9 +367,6 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, if (!i2c_check_functionality(adapter,I2C_FUNC_SMBUS_BYTE_DATA)) goto ERROR0; - /* We need address registration for the I2C bus too. That is not yet - implemented. */ - /* OK. For now, we presume we have a valid client. We now create the client structure, even though we cannot fill it completely yet. But it allows us to access adm9240_{read,write}_value. */ diff --git a/kernel/chips/bt869.c b/kernel/chips/bt869.c index 06c2daa0..7b8dc137 100644 --- a/kernel/chips/bt869.c +++ b/kernel/chips/bt869.c @@ -185,9 +185,6 @@ printk("bt869.o: probing address %d .\n",address); I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) goto ERROR0; - /* Here, we have to do the address registration check for the I2C bus. - But that is not yet implemented. */ - /* OK. For now, we presume we have a valid client. We now create the client structure, even though we cannot fill it completely yet. But it allows us to access bt869_{read,write}_value. */ diff --git a/kernel/chips/eeprom.c b/kernel/chips/eeprom.c index db63a90e..9eca5416 100644 --- a/kernel/chips/eeprom.c +++ b/kernel/chips/eeprom.c @@ -180,9 +180,6 @@ int eeprom_detect(struct i2c_adapter *adapter, int address, I2C_FUNC_SMBUS_WRITE_WORD_DATA)) goto ERROR0; - /* Here, we have to do the address registration check for the I2C bus. - But that is not yet implemented. */ - /* OK. For now, we presume we have a valid client. We now create the client structure, even though we cannot fill it completely yet. But it allows us to access eeprom_{read,write}_value. */ diff --git a/kernel/chips/gl518sm.c b/kernel/chips/gl518sm.c index 831be965..e4c3f135 100644 --- a/kernel/chips/gl518sm.c +++ b/kernel/chips/gl518sm.c @@ -317,9 +317,6 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, I2C_FUNC_SMBUS_WORD_DATA)) goto ERROR0; - /* We need address registration for the I2C bus too. That is not yet - implemented. */ - /* OK. For now, we presume we have a valid client. We now create the client structure, even though we cannot fill it completely yet. But it allows us to access gl518_{read,write}_value. */ diff --git a/kernel/chips/gl520sm.c b/kernel/chips/gl520sm.c index fb6509d7..289cbdea 100644 --- a/kernel/chips/gl520sm.c +++ b/kernel/chips/gl520sm.c @@ -312,9 +312,6 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, I2C_FUNC_SMBUS_WORD_DATA)) goto ERROR0; - /* We need address registration for the I2C bus too. That is not yet - implemented. */ - /* OK. For now, we presume we have a valid client. We now create the client structure, even though we cannot fill it completely yet. But it allows us to access gl520_{read,write}_value. */ diff --git a/kernel/chips/lm75.c b/kernel/chips/lm75.c index 0f0fb7fd..65b5aa20 100644 --- a/kernel/chips/lm75.c +++ b/kernel/chips/lm75.c @@ -159,9 +159,6 @@ int lm75_detect(struct i2c_adapter *adapter, int address, I2C_FUNC_SMBUS_WORD_DATA)) goto ERROR0; - /* Here, we have to do the address registration check for the I2C bus. - But that is not yet implemented. */ - /* OK. For now, we presume we have a valid client. We now create the client structure, even though we cannot fill it completely yet. But it allows us to access lm75_{read,write}_value. */ diff --git a/kernel/chips/lm78.c b/kernel/chips/lm78.c index 2996aebb..2da44d87 100644 --- a/kernel/chips/lm78.c +++ b/kernel/chips/lm78.c @@ -319,8 +319,6 @@ int lm78_detect(struct i2c_adapter *adapter, int address, if (!is_isa && ! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_BYTE_DATA)) goto ERROR0; - /* We need address registration for the I2C bus too. That is not yet - implemented. */ if (is_isa) { if (check_region(address,LM78_EXTENT)) goto ERROR0; diff --git a/kernel/chips/lm80.c b/kernel/chips/lm80.c index c93eba03..e1536345 100644 --- a/kernel/chips/lm80.c +++ b/kernel/chips/lm80.c @@ -310,9 +310,6 @@ int lm80_detect(struct i2c_adapter *adapter, int address, if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_BYTE_DATA)) goto ERROR0; - /* Here, we have to do the address registration check for the I2C bus. - But that is not yet implemented. */ - /* OK. For now, we presume we have a valid client. We now create the client structure, even though we cannot fill it completely yet. But it allows us to access lm80_{read,write}_value. */ diff --git a/kernel/chips/ltc1710.c b/kernel/chips/ltc1710.c index db2bb5df..51a87f89 100644 --- a/kernel/chips/ltc1710.c +++ b/kernel/chips/ltc1710.c @@ -172,9 +172,6 @@ int ltc1710_detect(struct i2c_adapter *adapter, int address, if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_BYTE)) goto ERROR0; - /* Here, we have to do the address registration check for the I2C bus. - But that is not yet implemented. */ - /* OK. For now, we presume we have a valid client. We now create the client structure, even though we cannot fill it completely yet. But it allows us to access ltc1710_{read,write}_value. */ diff --git a/kernel/chips/matorb.c b/kernel/chips/matorb.c index 3defba15..ed597082 100644 --- a/kernel/chips/matorb.c +++ b/kernel/chips/matorb.c @@ -146,9 +146,6 @@ int matorb_detect(struct i2c_adapter *adapter, int address, goto ERROR0; - /* Here, we have to do the address registration check for the I2C bus. - But that is not yet implemented. */ - /* OK. For now, we presume we have a valid client. We now create the client structure, even though we cannot fill it completely yet. But it allows us to access matorb_{read,write}_value. */ diff --git a/kernel/chips/thmc50.c b/kernel/chips/thmc50.c index e1de42cd..d785f4e6 100644 --- a/kernel/chips/thmc50.c +++ b/kernel/chips/thmc50.c @@ -204,9 +204,6 @@ int thmc50_detect(struct i2c_adapter *adapter, int address, if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_BYTE_DATA)) goto ERROR0; - /* Here, we have to do the address registration check for the I2C bus. - But that is not yet implemented. */ - /* OK. For now, we presume we have a valid client. We now create the client structure, even though we cannot fill it completely yet. But it allows us to access thmc50_{read,write}_value. */ diff --git a/kernel/chips/w83781d.c b/kernel/chips/w83781d.c index 7a5990e4..73f6410b 100644 --- a/kernel/chips/w83781d.c +++ b/kernel/chips/w83781d.c @@ -653,8 +653,6 @@ int w83781d_detect(struct i2c_adapter *adapter, int address, if (!is_isa && ! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_BYTE_DATA)) goto ERROR0; - /* We need address registration for the I2C bus too. That is not yet - implemented. */ if (is_isa) { if (check_region(address,W83781D_EXTENT)) goto ERROR0; diff --git a/kernel/sensors.c b/kernel/sensors.c index d60140d4..0bd143bd 100644 --- a/kernel/sensors.c +++ b/kernel/sensors.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "version.h" #include @@ -613,6 +614,9 @@ int sensors_detect(struct i2c_adapter *adapter, for (addr = 0x00; addr <= (is_isa?0xffff:0x7f); addr ++) { + if ((is_isa && check_region(addr,1)) || + (!is_isa && i2c_check_addr(adapter,addr))) + continue; /* If it is in one of the force entries, we don't do any detection at all */ diff --git a/prog/detect/i2cdetect.c b/prog/detect/i2cdetect.c index a612d6ef..a33353d2 100644 --- a/prog/detect/i2cdetect.c +++ b/prog/detect/i2cdetect.c @@ -87,9 +87,14 @@ int main(int argc, char *argv[]) printf("%02x: ",i); for(j = 0; j < 16; j++) { if (ioctl(file,I2C_SLAVE,i+j) < 0) { - fprintf(stderr,"Error: Could not set address to %d: %s\n",i+j, - strerror(errno)); - exit(1); + if (errno == EBUSY) { + printf("UU "); + continue; + } else { + fprintf(stderr,"Error: Could not set address to %02x: %s\n",i+j, + strerror(errno)); + exit(1); + } } res = i2c_smbus_write_quick(file, I2C_SMBUS_WRITE); diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect index 3c14eab2..d07c3bc2 100755 --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -1082,8 +1082,8 @@ sub scan_adapter next; } - i2c_set_slave_addr(\*FILE,$addr) or print("Can't set address to $_?!?\n"), - next; + i2c_set_slave_addr(\*FILE,$addr) or + printf("Client at address 0x%02x can not be probed - unload all client drivers first!\n",$addr), next; next unless i2c_smbus_write_quick(\*FILE,$SMBUS_WRITE) >= 0; printf "Client found at address 0x%02x\n",$addr;