aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/pmbus
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2013-02-21 12:33:25 -0500
committerGuenter Roeck <linux@roeck-us.net>2013-03-04 00:45:47 -0500
commitdbd712c2272764a536e29ad6841dba74989a39d9 (patch)
treea257c49a9b984ca8d71c1c6d28fefa819f16b69b /drivers/hwmon/pmbus
parent6d21a416562c2532f45cbcd40f47653f61d45533 (diff)
hwmon: (pmbus/ltc2978) Fix peak attribute handling
Peak attributes were not initialized and cleared correctly. Also, temp2_max is only supported on page 0 and thus does not need to be an array. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Cc: stable@vger.kernel.org # 3.2+ Acked-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/pmbus')
-rw-r--r--drivers/hwmon/pmbus/ltc2978.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/drivers/hwmon/pmbus/ltc2978.c b/drivers/hwmon/pmbus/ltc2978.c
index 9652a2c92a24..cc29a7e57bd7 100644
--- a/drivers/hwmon/pmbus/ltc2978.c
+++ b/drivers/hwmon/pmbus/ltc2978.c
@@ -62,7 +62,7 @@ struct ltc2978_data {
62 int temp_min, temp_max; 62 int temp_min, temp_max;
63 int vout_min[8], vout_max[8]; 63 int vout_min[8], vout_max[8];
64 int iout_max[2]; 64 int iout_max[2];
65 int temp2_max[2]; 65 int temp2_max;
66 struct pmbus_driver_info info; 66 struct pmbus_driver_info info;
67}; 67};
68 68
@@ -204,10 +204,9 @@ static int ltc3880_read_word_data(struct i2c_client *client, int page, int reg)
204 ret = pmbus_read_word_data(client, page, 204 ret = pmbus_read_word_data(client, page,
205 LTC3880_MFR_TEMPERATURE2_PEAK); 205 LTC3880_MFR_TEMPERATURE2_PEAK);
206 if (ret >= 0) { 206 if (ret >= 0) {
207 if (lin11_to_val(ret) 207 if (lin11_to_val(ret) > lin11_to_val(data->temp2_max))
208 > lin11_to_val(data->temp2_max[page])) 208 data->temp2_max = ret;
209 data->temp2_max[page] = ret; 209 ret = data->temp2_max;
210 ret = data->temp2_max[page];
211 } 210 }
212 break; 211 break;
213 case PMBUS_VIRT_READ_VIN_MIN: 212 case PMBUS_VIRT_READ_VIN_MIN:
@@ -248,11 +247,11 @@ static int ltc2978_write_word_data(struct i2c_client *client, int page,
248 247
249 switch (reg) { 248 switch (reg) {
250 case PMBUS_VIRT_RESET_IOUT_HISTORY: 249 case PMBUS_VIRT_RESET_IOUT_HISTORY:
251 data->iout_max[page] = 0x7fff; 250 data->iout_max[page] = 0x7c00;
252 ret = ltc2978_clear_peaks(client, page, data->id); 251 ret = ltc2978_clear_peaks(client, page, data->id);
253 break; 252 break;
254 case PMBUS_VIRT_RESET_TEMP2_HISTORY: 253 case PMBUS_VIRT_RESET_TEMP2_HISTORY:
255 data->temp2_max[page] = 0x7fff; 254 data->temp2_max = 0x7c00;
256 ret = ltc2978_clear_peaks(client, page, data->id); 255 ret = ltc2978_clear_peaks(client, page, data->id);
257 break; 256 break;
258 case PMBUS_VIRT_RESET_VOUT_HISTORY: 257 case PMBUS_VIRT_RESET_VOUT_HISTORY:
@@ -262,12 +261,12 @@ static int ltc2978_write_word_data(struct i2c_client *client, int page,
262 break; 261 break;
263 case PMBUS_VIRT_RESET_VIN_HISTORY: 262 case PMBUS_VIRT_RESET_VIN_HISTORY:
264 data->vin_min = 0x7bff; 263 data->vin_min = 0x7bff;
265 data->vin_max = 0; 264 data->vin_max = 0x7c00;
266 ret = ltc2978_clear_peaks(client, page, data->id); 265 ret = ltc2978_clear_peaks(client, page, data->id);
267 break; 266 break;
268 case PMBUS_VIRT_RESET_TEMP_HISTORY: 267 case PMBUS_VIRT_RESET_TEMP_HISTORY:
269 data->temp_min = 0x7bff; 268 data->temp_min = 0x7bff;
270 data->temp_max = 0x7fff; 269 data->temp_max = 0x7c00;
271 ret = ltc2978_clear_peaks(client, page, data->id); 270 ret = ltc2978_clear_peaks(client, page, data->id);
272 break; 271 break;
273 default: 272 default:
@@ -321,10 +320,11 @@ static int ltc2978_probe(struct i2c_client *client,
321 info = &data->info; 320 info = &data->info;
322 info->write_word_data = ltc2978_write_word_data; 321 info->write_word_data = ltc2978_write_word_data;
323 322
324 data->vout_min[0] = 0xffff;
325 data->vin_min = 0x7bff; 323 data->vin_min = 0x7bff;
324 data->vin_max = 0x7c00;
326 data->temp_min = 0x7bff; 325 data->temp_min = 0x7bff;
327 data->temp_max = 0x7fff; 326 data->temp_max = 0x7c00;
327 data->temp2_max = 0x7c00;
328 328
329 switch (id->driver_data) { 329 switch (id->driver_data) {
330 case ltc2978: 330 case ltc2978:
@@ -336,7 +336,6 @@ static int ltc2978_probe(struct i2c_client *client,
336 for (i = 1; i < 8; i++) { 336 for (i = 1; i < 8; i++) {
337 info->func[i] = PMBUS_HAVE_VOUT 337 info->func[i] = PMBUS_HAVE_VOUT
338 | PMBUS_HAVE_STATUS_VOUT; 338 | PMBUS_HAVE_STATUS_VOUT;
339 data->vout_min[i] = 0xffff;
340 } 339 }
341 break; 340 break;
342 case ltc3880: 341 case ltc3880:
@@ -352,11 +351,14 @@ static int ltc2978_probe(struct i2c_client *client,
352 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT 351 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
353 | PMBUS_HAVE_POUT 352 | PMBUS_HAVE_POUT
354 | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP; 353 | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP;
355 data->vout_min[1] = 0xffff; 354 data->iout_max[0] = 0x7c00;
355 data->iout_max[1] = 0x7c00;
356 break; 356 break;
357 default: 357 default:
358 return -ENODEV; 358 return -ENODEV;
359 } 359 }
360 for (i = 0; i < info->pages; i++)
361 data->vout_min[i] = 0xffff;
360 362
361 return pmbus_do_probe(client, id, info); 363 return pmbus_do_probe(client, id, info);
362} 364}