From 9d88e65c71b32b5052cae479a313ac19e1c675dc Mon Sep 17 00:00:00 2001 From: Frodo Looijaard Date: Mon, 27 Sep 1999 14:19:46 +0000 Subject: [PATCH] `functionality' checking for clients implemented git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@584 7894878c-1315-0410-8ee3-d5d059ff63e0 --- kernel/chips/adm1021.c | 2 ++ kernel/chips/adm9240.c | 3 +++ kernel/chips/bt869.c | 4 ++++ kernel/chips/eeprom.c | 4 ++++ kernel/chips/gl518sm.c | 3 +++ kernel/chips/gl520sm.c | 3 +++ kernel/chips/lm75.c | 4 ++++ kernel/chips/lm78.c | 3 +++ kernel/chips/lm80.c | 3 +++ kernel/chips/ltc1710.c | 3 +++ kernel/chips/matorb.c | 5 +++++ kernel/chips/maxilife.c | 11 ++++++++++- kernel/chips/sis5595.c | 5 +---- kernel/chips/thmc50.c | 3 +++ kernel/chips/w83781d.c | 3 +++ kernel/sensors.c | 4 ++++ 16 files changed, 58 insertions(+), 5 deletions(-) diff --git a/kernel/chips/adm1021.c b/kernel/chips/adm1021.c index 921fa7f8..faae37ac 100644 --- a/kernel/chips/adm1021.c +++ b/kernel/chips/adm1021.c @@ -207,6 +207,8 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind) } #endif + 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. */ diff --git a/kernel/chips/adm9240.c b/kernel/chips/adm9240.c index 4634895c..0189716f 100644 --- a/kernel/chips/adm9240.c +++ b/kernel/chips/adm9240.c @@ -361,6 +361,9 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) } #endif + 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. */ diff --git a/kernel/chips/bt869.c b/kernel/chips/bt869.c index e4deccf0..afd72b6d 100644 --- a/kernel/chips/bt869.c +++ b/kernel/chips/bt869.c @@ -178,6 +178,10 @@ printk("bt869.o: probing address %d .\n",address); } #endif + if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_READ_BYTE| + 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. */ diff --git a/kernel/chips/eeprom.c b/kernel/chips/eeprom.c index 94b56205..be1bd1ef 100644 --- a/kernel/chips/eeprom.c +++ b/kernel/chips/eeprom.c @@ -173,6 +173,10 @@ int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) } #endif + if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_BYTE_DATA | + 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. */ diff --git a/kernel/chips/gl518sm.c b/kernel/chips/gl518sm.c index 9f8db362..76740db7 100644 --- a/kernel/chips/gl518sm.c +++ b/kernel/chips/gl518sm.c @@ -303,6 +303,9 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) } #endif + if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_BYTE_DATA | + I2C_FUNC_SMBUS_WORD_DATA)) + goto ERROR0; /* We need address registration for the I2C bus too. That is not yet implemented. */ diff --git a/kernel/chips/gl520sm.c b/kernel/chips/gl520sm.c index 608a76c0..2e790369 100644 --- a/kernel/chips/gl520sm.c +++ b/kernel/chips/gl520sm.c @@ -305,6 +305,9 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) } #endif + if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_BYTE_DATA| + I2C_FUNC_SMBUS_WORD_DATA)) + goto ERROR0; /* We need address registration for the I2C bus too. That is not yet implemented. */ diff --git a/kernel/chips/lm75.c b/kernel/chips/lm75.c index 8a643bc8..cce11c88 100644 --- a/kernel/chips/lm75.c +++ b/kernel/chips/lm75.c @@ -152,6 +152,10 @@ int lm75_detect(struct i2c_adapter *adapter, int address, int kind) } #endif + if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_BYTE_DATA | + 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. */ diff --git a/kernel/chips/lm78.c b/kernel/chips/lm78.c index d9199167..6a4544ee 100644 --- a/kernel/chips/lm78.c +++ b/kernel/chips/lm78.c @@ -313,6 +313,9 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind) const char *client_name = ""; int is_isa = i2c_is_isa_adapter(adapter); + 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) { diff --git a/kernel/chips/lm80.c b/kernel/chips/lm80.c index c640a883..4d911a5a 100644 --- a/kernel/chips/lm80.c +++ b/kernel/chips/lm80.c @@ -299,6 +299,9 @@ int lm80_detect(struct i2c_adapter *adapter, int address, int kind) } #endif + 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. */ diff --git a/kernel/chips/ltc1710.c b/kernel/chips/ltc1710.c index 1ed981d2..18fa8dde 100644 --- a/kernel/chips/ltc1710.c +++ b/kernel/chips/ltc1710.c @@ -166,6 +166,9 @@ int ltc1710_detect(struct i2c_adapter *adapter, int address, int kind) } #endif + 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. */ diff --git a/kernel/chips/matorb.c b/kernel/chips/matorb.c index b9e332c4..2ffc73a6 100644 --- a/kernel/chips/matorb.c +++ b/kernel/chips/matorb.c @@ -138,6 +138,11 @@ int matorb_detect(struct i2c_adapter *adapter, int address, int kind) } #endif + if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_WRITE_BYTE | + 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. */ diff --git a/kernel/chips/maxilife.c b/kernel/chips/maxilife.c index 018b5460..a5786088 100644 --- a/kernel/chips/maxilife.c +++ b/kernel/chips/maxilife.c @@ -49,6 +49,7 @@ static const char *version_str = "1.00 25/2/99 Fons Rademakers"; #include #include "version.h" #include "sensors.h" +#include "i2c-isa.h" #include "compat.h" #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,53) @@ -264,7 +265,10 @@ static ctl_table maxi_dir_table_template[] = { - when a new adapter is inserted (and maxi_driver is still present) */ int maxi_attach_adapter(struct i2c_adapter *adapter) { - return maxi_detect_smbus(adapter); + if (i2c_is_isa_adapter(adapter)) + return 0; + else + return maxi_detect_smbus(adapter); } /* This function is called whenever a client should be removed: @@ -288,6 +292,10 @@ int maxi_detect_smbus(struct i2c_adapter *adapter) /* OK, this is no detection. I know. It will do for now, though. */ err = 0; + + if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_BYTE_DATA)) + goto ERROR0; + for (address = 0x10; (! err) && (address <= 0x14); address++) { /* Later on, we will keep a list of registered addresses for each @@ -375,6 +383,7 @@ ERROR3: ERROR2: kfree(new_client); } +ERROR0: return err; } diff --git a/kernel/chips/sis5595.c b/kernel/chips/sis5595.c index 28851c0f..a96ce7be 100644 --- a/kernel/chips/sis5595.c +++ b/kernel/chips/sis5595.c @@ -312,14 +312,11 @@ int sis5595_detect(struct i2c_adapter *adapter, int address, int kind) const char *type_name = ""; const char *client_name = ""; - /* Make sure we are probing the ISA bus!! This is just a safety check - at this moment; sensors_detect really won't call us for I2C busses. */ -#ifdef DEBUG + /* Make sure we are probing the ISA bus!! */ if (!i2c_is_isa_adapter(adapter)) { printk("sis5595.o: sis5595_detect called for an I2C bus adapter?!?\n"); return 0; } -#endif if (check_region(address,SIS5595_EXTENT)) goto ERROR0; diff --git a/kernel/chips/thmc50.c b/kernel/chips/thmc50.c index 9c91ac8b..e9ee0cf7 100644 --- a/kernel/chips/thmc50.c +++ b/kernel/chips/thmc50.c @@ -198,6 +198,9 @@ int thmc50_detect(struct i2c_adapter *adapter, int address, int kind) } #endif + 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. */ diff --git a/kernel/chips/w83781d.c b/kernel/chips/w83781d.c index 556a6b4c..9502cc7f 100644 --- a/kernel/chips/w83781d.c +++ b/kernel/chips/w83781d.c @@ -645,6 +645,9 @@ int w83781d_detect(struct i2c_adapter *adapter, int address, int kind) const char *client_name = ""; int is_isa = i2c_is_isa_adapter(adapter); + 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) { diff --git a/kernel/sensors.c b/kernel/sensors.c index 68bd3ed1..06030d62 100644 --- a/kernel/sensors.c +++ b/kernel/sensors.c @@ -594,6 +594,10 @@ int sensors_detect(struct i2c_adapter *adapter, int is_isa = i2c_is_isa_adapter(adapter); int adapter_id = is_isa?SENSORS_ISA_BUS:i2c_adapter_id(adapter); + /* Forget it if we can't probe using SMBUS_QUICK */ + if ((! is_isa) && ! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_QUICK)) + return -1; + for (addr = 0x00; addr <= (is_isa?0xffff:0x7f); addr ++) {