aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-12-04 11:03:37 -0500
committerGuenter Roeck <linux@roeck-us.net>2013-04-08 00:16:39 -0400
commit8e9285b0bb2ab48924032147baa29699c0bbee7c (patch)
tree7f0f65823f5a3d99b166d86b16ea3430b9c5721b
parentbbd8decd4123648ddeba2be485bc7e1a3117bfe4 (diff)
hwmon: (nct6775) Detect and report additional temperature sources
Scan all temperature sources used for fan control and report if additional monitoring registers are available. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r--drivers/hwmon/nct6775.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
index f80ff823c28e..6d5859718113 100644
--- a/drivers/hwmon/nct6775.c
+++ b/drivers/hwmon/nct6775.c
@@ -3364,6 +3364,32 @@ nct6775_check_fan_inputs(const struct nct6775_sio_data *sio_data,
3364 return 0; 3364 return 0;
3365} 3365}
3366 3366
3367static void add_temp_sensors(struct nct6775_data *data, const u16 *regp,
3368 int *available, int *mask)
3369{
3370 int i;
3371 u8 src;
3372
3373 for (i = 0; i < data->pwm_num && *available; i++) {
3374 int index;
3375
3376 if (!regp[i])
3377 continue;
3378 src = nct6775_read_value(data, regp[i]);
3379 src &= 0x1f;
3380 if (!src || (*mask & (1 << src)))
3381 continue;
3382 if (src >= data->temp_label_num ||
3383 !strlen(data->temp_label[src]))
3384 continue;
3385
3386 index = __ffs(*available);
3387 nct6775_write_value(data, data->REG_TEMP_SOURCE[index], src);
3388 *available &= ~(1 << index);
3389 *mask |= 1 << src;
3390 }
3391}
3392
3367static int nct6775_probe(struct platform_device *pdev) 3393static int nct6775_probe(struct platform_device *pdev)
3368{ 3394{
3369 struct device *dev = &pdev->dev; 3395 struct device *dev = &pdev->dev;
@@ -3614,6 +3640,13 @@ static int nct6775_probe(struct platform_device *pdev)
3614 mask |= 1 << src; 3640 mask |= 1 << src;
3615 } 3641 }
3616 3642
3643 /*
3644 * Now find unmonitored temperature registers and enable monitoring
3645 * if additional monitoring registers are available.
3646 */
3647 add_temp_sensors(data, data->REG_TEMP_SEL, &available, &mask);
3648 add_temp_sensors(data, data->REG_WEIGHT_TEMP_SEL, &available, &mask);
3649
3617 mask = 0; 3650 mask = 0;
3618 s = NUM_TEMP_FIXED; /* First dynamic temperature attribute */ 3651 s = NUM_TEMP_FIXED; /* First dynamic temperature attribute */
3619 for (i = 0; i < num_reg_temp; i++) { 3652 for (i = 0; i < num_reg_temp; i++) {