hwmon: (lm95241) Add support for LM95231
PATCH v2 3/3 hwmon: (lm95241) Add support for LM95231
LM95231 is fully compatible to LM95241; only necessary change is to add chip detection.
--- drivers/hwmon/lm95241.c | 30 +++++++++++++++++++----------- 1 files changed, 19 insertions(+), 11 deletions(-)
drivers/hwmon/lm95241.c +19 -11
@@ -75,7 +75,8 @@ static const unsigned short normal_i2c[] = {#define TT_ON 1#define TT_MASK 7#define MANUFACTURER_ID 0x01 -#define DEFAULT_REVISION 0xA4 +#define LM95231_CHIP_ID 0xA1 +#define LM95241_CHIP_ID 0xA4static const u8 lm95241_reg_address[] = {LM95241_REG_R_LOCAL_TEMPH ,
@@ -332,22 +333,28 @@ static int lm95241_detect(struct i2c_client *new_client,struct i2c_adapter *adapter = new_client->adapter;int address = new_client->addr;const char *name; +int mfg_id, chip_id;if (!i2c_check_functionality (adapter,I2C_FUNC_SMBUS_BYTE_DATA ))return -ENODEV ; -if ((i2c_smbus_read_byte_data (new_client,LM95241_REG_R_MAN_ID ) - =MANUFACTURER_ID ) - && (i2c_smbus_read_byte_data (new_client,LM95241_REG_R_CHIP_ID ) - =DEFAULT_REVISION )) { - name =DEVNAME ; - }else { -dev_dbg (&adapter->dev,"LM95241 detection failed at 0x%02x\n" , - address); + mfg_id =i2c_smbus_read_byte_data (new_client,LM95241_REG_R_MAN_ID ); +if (mfg_id !=MANUFACTURER_ID ) +return -ENODEV ; + } + + chip_id =i2c_smbus_read_byte_data (new_client,LM95241_REG_R_CHIP_ID ); +switch (chip_id) { +case LM95231_CHIP_ID : + name ="lm95231" ; +break ; +case LM95241_CHIP_ID : + name ="lm95241" ; +break ; +default :return -ENODEV ; } -/* Fill the i2c board info */ strlcpy (info->type, name,I2C_NAME_SIZE );return 0 ; }
@@ -423,7 +430,8 @@ static int lm95241_remove(struct i2c_client *client)/* Driver data (common to all clients) */ static const struct i2c_device_id lm95241_id[] = { - {DEVNAME ,0 }, + {"lm95231" ,0 }, + {"lm95241" ,0 }, { } };MODULE_DEVICE_TABLE (i2c, lm95241_id);
Signature · 7 lines
1.7.3.1 _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH v2 3/3] hwmon: (lm95241) Add support for
Quoted 13 lines · Guenter Roeck
LM95231 is fully compatible to LM95241; only necessary change is to add chip detection.
Signed-off-by Guenter Roeck <[email protected]>--- drivers/hwmon/lm95241.c | 30 +++++++++++++++++++----------- 1 files changed, 19 insertions(+), 11 deletions(-)drivers/hwmon/lm95241.c +0
-0
drivers/hwmon/lm95241.c static const unsigned short normal_i2c[] = { · line 77
Quoted 3 lines
drivers/hwmon/lm95241.c +0
-0@@ -75,7 +75,8 @@ static const unsigned short normal_i2c[] = {#define TT_ON 1#define TT_MASK 7#define MANUFACTURER_ID 0x01
Could probably be renamed to NATSEMI_MAN_ID for consistency.
Quoted 17 lines
drivers/hwmon/lm95241.c +3
-3-#define DEFAULT_REVISION 0xA4 +#define LM95231_CHIP_ID 0xA1 +#define LM95241_CHIP_ID 0xA4static const u8 lm95241_reg_address[] = {LM95241_REG_R_LOCAL_TEMPH ,@@ -332,22 +333,28 @@ static int lm95241_detect(struct i2c_client *new_client,struct i2c_adapter *adapter = new_client->adapter;int address = new_client->addr;const char *name; +int mfg_id, chip_id;if (!i2c_check_functionality (adapter,I2C_FUNC_SMBUS_BYTE_DATA ))return -ENODEV ; -if ((i2c_smbus_read_byte_data (new_client,LM95241_REG_R_MAN_ID ) - = MANUFACTURER_ID)
drivers/hwmon/lm95241.c static int lm95241_detect(struct i2c_client *new_client, · line 344
Quoted 10 lines
drivers/hwmon/lm95241.c +4
-6- && (i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID) - = DEFAULT_REVISION)) { - name = DEVNAME; - } else { -dev_dbg (&adapter->dev,"LM95241 detection failed at 0x%02x\n" , - address); + mfg_id =i2c_smbus_read_byte_data (new_client,LM95241_REG_R_MAN_ID ); +if (mfg_id !=MANUFACTURER_ID ) +return -ENODEV ; + }
Meeeeep.
Quoted 4 lines
drivers/hwmon/lm95241.c +4
-0+ + chip_id =i2c_smbus_read_byte_data (new_client,LM95241_REG_R_CHIP_ID ); +switch (chip_id) { +case LM95231_CHIP_ID :
drivers/hwmon/lm95241.c static int lm95241_detect(struct i2c_client *new_client, · line 350
Quoted 10 lines
drivers/hwmon/lm95241.c +6
-1+ name ="lm95231" ; +break ; +case LM95241_CHIP_ID : + name ="lm95241" ; +break ; +default :return -ENODEV ; } -/* Fill the i2c board info */
Well, the comment seems to still apply? Up to you.
drivers/hwmon/lm95241.c static int lm95241_remove(struct i2c_client *client) · line 437
Quoted 13 lines
drivers/hwmon/lm95241.c +2
-1strlcpy (info->type, name,I2C_NAME_SIZE );return 0 ; }@@ -423,7 +430,8 @@ static int lm95241_remove(struct i2c_client *client)/* Driver data (common to all clients) */ static const struct i2c_device_id lm95241_id[] = { - {DEVNAME ,0 }, + {"lm95231" ,0 }, + {"lm95241" ,0 }, { } };MODULE_DEVICE_TABLE (i2c, lm95241_id);
As you're redoing the patch anyway, can you please update the Kconfig file?
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH v2 3/3] hwmon: (lm95241) Add support for
In reply to Guenter RoeckQuoted 9 lines · Jean Delvare
Quoted 8 lines · Guenter Roeck
LM95231 is fully compatible to LM95241; only necessary change is to add chip detection.
Signed-off-by Guenter Roeck <[email protected]>--- drivers/hwmon/lm95241.c | 30 +++++++++++++++++++----------- 1 files changed, 19 insertions(+), 11 deletions(-)
Quoted 11 lines
drivers/hwmon/lm95241.c static const unsigned short normal_i2c[] = { · line 77
Quoted 8 lines
drivers/hwmon/lm95241.c +0
-0@@ -75,7 +75,8 @@ static const unsigned short normal_i2c[] = {#define TT_ON 1#define TT_MASK 7#define MANUFACTURER_ID 0x01Could probably be renamed to
NATSEMI_MAN_IDfor consistency.
Ok.
Quoted 15 lines
Quoted 15 lines
drivers/hwmon/lm95241.c +3
-1-#define DEFAULT_REVISION 0xA4 +#define LM95231_CHIP_ID 0xA1 +#define LM95241_CHIP_ID 0xA4static const u8 lm95241_reg_address[] = {LM95241_REG_R_LOCAL_TEMPH ,@@ -332,22 +333,28 @@ static int lm95241_detect(struct i2c_client *new_client,struct i2c_adapter *adapter = new_client->adapter;int address = new_client->addr;const char *name; +int mfg_id, chip_id;if (!i2c_check_functionality (adapter,I2C_FUNC_SMBUS_BYTE_DATA ))return -ENODEV ;
Quoted 15 lines
drivers/hwmon/lm95241.c static int lm95241_detect(struct i2c_client *new_client, · line 344
Quoted 12 lines
drivers/hwmon/lm95241.c +4
-8-if ((i2c_smbus_read_byte_data (new_client,LM95241_REG_R_MAN_ID ) - =MANUFACTURER_ID ) - && (i2c_smbus_read_byte_data (new_client,LM95241_REG_R_CHIP_ID ) - =DEFAULT_REVISION )) { - name =DEVNAME ; - }else { -dev_dbg (&adapter->dev,"LM95241 detection failed at 0x%02x\n" , - address); + mfg_id =i2c_smbus_read_byte_data (new_client,LM95241_REG_R_MAN_ID ); +if (mfg_id !=MANUFACTURER_ID ) +return -ENODEV ; + }Meeeeep.
Meeep too.
Quoted 13 lines
Quoted 13 lines
drivers/hwmon/lm95241.c +10
-0+ + chip_id =i2c_smbus_read_byte_data (new_client,LM95241_REG_R_CHIP_ID ); +switch (chip_id) { +case LM95231_CHIP_ID : + name ="lm95231" ; +break ; +case LM95241_CHIP_ID : + name ="lm95241" ; +break ; +default :return -ENODEV ; }
Quoted 4 lines
drivers/hwmon/lm95241.c static int lm95241_detect(struct i2c_client *new_client, · line 350
Quoted 1 line
drivers/hwmon/lm95241.c +0
-1-/* Fill the i2c board info */ Well, the comment seems to still apply? Up to you.
You are right, put it back in.
Quoted 5 lines
Quoted 5 lines
drivers/hwmon/lm95241.c +0
-0strlcpy (info->type, name,I2C_NAME_SIZE );return 0 ; }@@ -423,7 +430,8 @@ static int lm95241_remove(struct i2c_client *client)
Quoted 12 lines
drivers/hwmon/lm95241.c static int lm95241_remove(struct i2c_client *client) · line 437
Quoted 8 lines
drivers/hwmon/lm95241.c +2
-1/* Driver data (common to all clients) */ static const struct i2c_device_id lm95241_id[] = { - {DEVNAME ,0 }, + {"lm95231" ,0 }, + {"lm95241" ,0 }, { } };MODULE_DEVICE_TABLE (i2c, lm95241_id);As you're redoing the patch anyway, can you please update the
Kconfigfile?
Actually, I did that. Wonder what happened with it. It will be in the next revision of the patch.
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors