aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm90.c
diff options
context:
space:
mode:
authorGuenter Roeck <guenter.roeck@ericsson.com>2010-10-28 14:31:43 -0400
committerJean Delvare <khali@endymion.delvare>2010-10-28 14:31:43 -0400
commit88073bb1ba969d4e3c41dc5f35c902c6b7dab0a7 (patch)
tree86711d2f4988dd29c3dc5ab8c5f7a176fbacc181 /drivers/hwmon/lm90.c
parent11e578129af74c4866cf559e62e981c6415fffd9 (diff)
hwmon: (lm90) Introduce device feature bits
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/lm90.c')
-rw-r--r--drivers/hwmon/lm90.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index aafed2898d95..f628f2ae7e73 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -142,7 +142,11 @@ enum chips { lm90, adm1032, lm99, lm86, max6657, adt7461, max6680, max6646,
142/* 142/*
143 * Device flags 143 * Device flags
144 */ 144 */
145#define LM90_FLAG_ADT7461_EXT 0x01 /* ADT7461 extended mode */ 145#define LM90_FLAG_ADT7461_EXT (1 << 0) /* ADT7461 extended mode */
146/* Device features */
147#define LM90_HAVE_OFFSET (1 << 1) /* temperature offset register */
148#define LM90_HAVE_LOCAL_EXT (1 << 2) /* extended local temperature */
149#define LM90_HAVE_REM_LIMIT_EXT (1 << 3) /* extended remote limit */
146 150
147/* 151/*
148 * Functions declaration 152 * Functions declaration
@@ -462,17 +466,16 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
462 mutex_lock(&data->update_lock); 466 mutex_lock(&data->update_lock);
463 if (data->kind == adt7461) 467 if (data->kind == adt7461)
464 data->temp11[nr] = temp_to_u16_adt7461(data, val); 468 data->temp11[nr] = temp_to_u16_adt7461(data, val);
465 else if (data->kind == max6657 || data->kind == max6680)
466 data->temp11[nr] = temp_to_s8(val) << 8;
467 else if (data->kind == max6646) 469 else if (data->kind == max6646)
468 data->temp11[nr] = temp_to_u8(val) << 8; 470 data->temp11[nr] = temp_to_u8(val) << 8;
469 else 471 else if (data->flags & LM90_HAVE_REM_LIMIT_EXT)
470 data->temp11[nr] = temp_to_s16(val); 472 data->temp11[nr] = temp_to_s16(val);
473 else
474 data->temp11[nr] = temp_to_s8(val) << 8;
471 475
472 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], 476 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2],
473 data->temp11[nr] >> 8); 477 data->temp11[nr] >> 8);
474 if (data->kind != max6657 && data->kind != max6680 478 if (data->flags & LM90_HAVE_REM_LIMIT_EXT)
475 && data->kind != max6646)
476 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], 479 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1],
477 data->temp11[nr] & 0xff); 480 data->temp11[nr] & 0xff);
478 mutex_unlock(&data->update_lock); 481 mutex_unlock(&data->update_lock);
@@ -847,6 +850,17 @@ static int lm90_probe(struct i2c_client *new_client,
847 break; 850 break;
848 } 851 }
849 852
853 /* Set chip capabilities */
854 if (data->kind != max6657 && data->kind != max6646)
855 data->flags |= LM90_HAVE_OFFSET;
856
857 if (data->kind == max6657 || data->kind == max6646)
858 data->flags |= LM90_HAVE_LOCAL_EXT;
859
860 if (data->kind != max6657 && data->kind != max6646
861 && data->kind != max6680)
862 data->flags |= LM90_HAVE_REM_LIMIT_EXT;
863
850 /* Initialize the LM90 chip */ 864 /* Initialize the LM90 chip */
851 lm90_init_client(new_client); 865 lm90_init_client(new_client);
852 866
@@ -859,7 +873,7 @@ static int lm90_probe(struct i2c_client *new_client,
859 if (err) 873 if (err)
860 goto exit_remove_files; 874 goto exit_remove_files;
861 } 875 }
862 if (data->kind != max6657 && data->kind != max6646) { 876 if (data->flags & LM90_HAVE_OFFSET) {
863 err = device_create_file(&new_client->dev, 877 err = device_create_file(&new_client->dev,
864 &sensor_dev_attr_temp2_offset.dev_attr); 878 &sensor_dev_attr_temp2_offset.dev_attr);
865 if (err) 879 if (err)
@@ -925,7 +939,7 @@ static int lm90_remove(struct i2c_client *client)
925 hwmon_device_unregister(data->hwmon_dev); 939 hwmon_device_unregister(data->hwmon_dev);
926 sysfs_remove_group(&client->dev.kobj, &lm90_group); 940 sysfs_remove_group(&client->dev.kobj, &lm90_group);
927 device_remove_file(&client->dev, &dev_attr_pec); 941 device_remove_file(&client->dev, &dev_attr_pec);
928 if (data->kind != max6657 && data->kind != max6646) 942 if (data->flags & LM90_HAVE_OFFSET)
929 device_remove_file(&client->dev, 943 device_remove_file(&client->dev,
930 &sensor_dev_attr_temp2_offset.dev_attr); 944 &sensor_dev_attr_temp2_offset.dev_attr);
931 945
@@ -1019,7 +1033,7 @@ static struct lm90_data *lm90_update_device(struct device *dev)
1019 lm90_read_reg(client, LM90_REG_R_REMOTE_CRIT, &data->temp8[3]); 1033 lm90_read_reg(client, LM90_REG_R_REMOTE_CRIT, &data->temp8[3]);
1020 lm90_read_reg(client, LM90_REG_R_TCRIT_HYST, &data->temp_hyst); 1034 lm90_read_reg(client, LM90_REG_R_TCRIT_HYST, &data->temp_hyst);
1021 1035
1022 if (data->kind == max6657 || data->kind == max6646) { 1036 if (data->flags & LM90_HAVE_LOCAL_EXT) {
1023 lm90_read16(client, LM90_REG_R_LOCAL_TEMP, 1037 lm90_read16(client, LM90_REG_R_LOCAL_TEMP,
1024 MAX6657_REG_R_LOCAL_TEMPL, 1038 MAX6657_REG_R_LOCAL_TEMPL,
1025 &data->temp11[4]); 1039 &data->temp11[4]);
@@ -1033,22 +1047,20 @@ static struct lm90_data *lm90_update_device(struct device *dev)
1033 1047
1034 if (lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH, &h) == 0) { 1048 if (lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH, &h) == 0) {
1035 data->temp11[1] = h << 8; 1049 data->temp11[1] = h << 8;
1036 if (data->kind != max6657 && data->kind != max6680 1050 if ((data->flags & LM90_HAVE_REM_LIMIT_EXT)
1037 && data->kind != max6646
1038 && lm90_read_reg(client, LM90_REG_R_REMOTE_LOWL, 1051 && lm90_read_reg(client, LM90_REG_R_REMOTE_LOWL,
1039 &l) == 0) 1052 &l) == 0)
1040 data->temp11[1] |= l; 1053 data->temp11[1] |= l;
1041 } 1054 }
1042 if (lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHH, &h) == 0) { 1055 if (lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHH, &h) == 0) {
1043 data->temp11[2] = h << 8; 1056 data->temp11[2] = h << 8;
1044 if (data->kind != max6657 && data->kind != max6680 1057 if ((data->flags & LM90_HAVE_REM_LIMIT_EXT)
1045 && data->kind != max6646
1046 && lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHL, 1058 && lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHL,
1047 &l) == 0) 1059 &l) == 0)
1048 data->temp11[2] |= l; 1060 data->temp11[2] |= l;
1049 } 1061 }
1050 1062
1051 if (data->kind != max6657 && data->kind != max6646) { 1063 if (data->flags & LM90_HAVE_OFFSET) {
1052 if (lm90_read_reg(client, LM90_REG_R_REMOTE_OFFSH, 1064 if (lm90_read_reg(client, LM90_REG_R_REMOTE_OFFSH,
1053 &h) == 0 1065 &h) == 0
1054 && lm90_read_reg(client, LM90_REG_R_REMOTE_OFFSL, 1066 && lm90_read_reg(client, LM90_REG_R_REMOTE_OFFSL,