diff options
author | Guenter Roeck <linux@roeck-us.net> | 2013-04-09 08:04:00 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2013-04-13 11:44:35 -0400 |
commit | c409fd43bdea705799d21531600b8f305b120009 (patch) | |
tree | 0ea105e552da63ae4feb4c29faa8a8647983d462 /drivers/hwmon | |
parent | 1754e4c5c7650da6581dc28f182af9010b84e9c2 (diff) |
hwmon: (nct6775) Use ARRAY_SIZE for loops where possible
This ensures that the loop iterations are correct even if/when
the number of elements in an array changes.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/nct6775.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index 8d0e4c47cca5..04ccfff44738 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c | |||
@@ -854,7 +854,7 @@ static void nct6775_init_fan_div(struct nct6775_data *data) | |||
854 | * reading from the fan count register, even if it is not optimal. | 854 | * reading from the fan count register, even if it is not optimal. |
855 | * We'll compute a better divider later on. | 855 | * We'll compute a better divider later on. |
856 | */ | 856 | */ |
857 | for (i = 0; i < 3; i++) { | 857 | for (i = 0; i < ARRAY_SIZE(data->fan_div); i++) { |
858 | if (!(data->has_fan & (1 << i))) | 858 | if (!(data->has_fan & (1 << i))) |
859 | continue; | 859 | continue; |
860 | if (data->fan_div[i] == 0) { | 860 | if (data->fan_div[i] == 0) { |
@@ -877,7 +877,7 @@ static void nct6775_init_fan_common(struct device *dev, | |||
877 | * If fan_min is not set (0), set it to 0xff to disable it. This | 877 | * If fan_min is not set (0), set it to 0xff to disable it. This |
878 | * prevents the unnecessary warning when fanX_min is reported as 0. | 878 | * prevents the unnecessary warning when fanX_min is reported as 0. |
879 | */ | 879 | */ |
880 | for (i = 0; i < 5; i++) { | 880 | for (i = 0; i < ARRAY_SIZE(data->fan_min); i++) { |
881 | if (data->has_fan_min & (1 << i)) { | 881 | if (data->has_fan_min & (1 << i)) { |
882 | reg = nct6775_read_value(data, data->REG_FAN_MIN[i]); | 882 | reg = nct6775_read_value(data, data->REG_FAN_MIN[i]); |
883 | if (!reg) | 883 | if (!reg) |
@@ -994,7 +994,7 @@ static void nct6775_update_pwm(struct device *dev) | |||
994 | data->pwm_weight_temp_sel[i] = 0; | 994 | data->pwm_weight_temp_sel[i] = 0; |
995 | 995 | ||
996 | /* Weight temp data */ | 996 | /* Weight temp data */ |
997 | for (j = 0; j < 3; j++) { | 997 | for (j = 0; j < ARRAY_SIZE(data->weight_temp); j++) { |
998 | data->weight_temp[j][i] | 998 | data->weight_temp[j][i] |
999 | = nct6775_read_value(data, | 999 | = nct6775_read_value(data, |
1000 | data->REG_WEIGHT_TEMP[j][i]); | 1000 | data->REG_WEIGHT_TEMP[j][i]); |
@@ -1013,7 +1013,7 @@ static void nct6775_update_pwm_limits(struct device *dev) | |||
1013 | if (!(data->has_pwm & (1 << i))) | 1013 | if (!(data->has_pwm & (1 << i))) |
1014 | continue; | 1014 | continue; |
1015 | 1015 | ||
1016 | for (j = 0; j < 3; j++) { | 1016 | for (j = 0; j < ARRAY_SIZE(data->fan_time); j++) { |
1017 | data->fan_time[j][i] = | 1017 | data->fan_time[j][i] = |
1018 | nct6775_read_value(data, data->REG_FAN_TIME[j][i]); | 1018 | nct6775_read_value(data, data->REG_FAN_TIME[j][i]); |
1019 | } | 1019 | } |
@@ -1095,7 +1095,7 @@ static struct nct6775_data *nct6775_update_device(struct device *dev) | |||
1095 | } | 1095 | } |
1096 | 1096 | ||
1097 | /* Measured fan speeds and limits */ | 1097 | /* Measured fan speeds and limits */ |
1098 | for (i = 0; i < 5; i++) { | 1098 | for (i = 0; i < ARRAY_SIZE(data->rpm); i++) { |
1099 | u16 reg; | 1099 | u16 reg; |
1100 | 1100 | ||
1101 | if (!(data->has_fan & (1 << i))) | 1101 | if (!(data->has_fan & (1 << i))) |
@@ -1121,7 +1121,7 @@ static struct nct6775_data *nct6775_update_device(struct device *dev) | |||
1121 | for (i = 0; i < NUM_TEMP; i++) { | 1121 | for (i = 0; i < NUM_TEMP; i++) { |
1122 | if (!(data->have_temp & (1 << i))) | 1122 | if (!(data->have_temp & (1 << i))) |
1123 | continue; | 1123 | continue; |
1124 | for (j = 0; j < 4; j++) { | 1124 | for (j = 0; j < ARRAY_SIZE(data->reg_temp); j++) { |
1125 | if (data->reg_temp[j][i]) | 1125 | if (data->reg_temp[j][i]) |
1126 | data->temp[j][i] | 1126 | data->temp[j][i] |
1127 | = nct6775_read_temp(data, | 1127 | = nct6775_read_temp(data, |
@@ -3983,7 +3983,7 @@ static int nct6775_resume(struct device *dev) | |||
3983 | data->in[i][2]); | 3983 | data->in[i][2]); |
3984 | } | 3984 | } |
3985 | 3985 | ||
3986 | for (i = 0; i < 5; i++) { | 3986 | for (i = 0; i < ARRAY_SIZE(data->fan_min); i++) { |
3987 | if (!(data->has_fan_min & (1 << i))) | 3987 | if (!(data->has_fan_min & (1 << i))) |
3988 | continue; | 3988 | continue; |
3989 | 3989 | ||
@@ -3995,7 +3995,7 @@ static int nct6775_resume(struct device *dev) | |||
3995 | if (!(data->have_temp & (1 << i))) | 3995 | if (!(data->have_temp & (1 << i))) |
3996 | continue; | 3996 | continue; |
3997 | 3997 | ||
3998 | for (j = 1; j < 4; j++) | 3998 | for (j = 1; j < ARRAY_SIZE(data->reg_temp); j++) |
3999 | if (data->reg_temp[j][i]) | 3999 | if (data->reg_temp[j][i]) |
4000 | nct6775_write_temp(data, data->reg_temp[j][i], | 4000 | nct6775_write_temp(data, data->reg_temp[j][i], |
4001 | data->temp[j][i]); | 4001 | data->temp[j][i]); |