aboutsummaryrefslogtreecommitdiff
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorChris Packham2020-09-24 20:51:00 +1200
committerGuenter Roeck2020-09-24 07:41:30 -0700
commit10d097737dfe27bb0bf3f825b5ff28d26053a8c6 (patch)
treeb63be7f6271d8008c4146cb2ffee7a4e881da56c /drivers/hwmon
parent55163a1c00fcb526e2aa9f7f952fb38d3543da5e (diff)
hwmon: (adm9240) Use loops to avoid duplicated code
Use loops for reading temp_max and initialising FAN_MIN/TEMP_MAX rather than duplicating code. Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz> Link: https://lore.kernel.org/r/20200924085102.15219-2-chris.packham@alliedtelesis.co.nz Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/adm9240.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c
index 16364dee1794..a34a8c9235b8 100644
--- a/drivers/hwmon/adm9240.c
+++ b/drivers/hwmon/adm9240.c
@@ -223,10 +223,10 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
data->fan_min[i] = i2c_smbus_read_byte_data(client,
ADM9240_REG_FAN_MIN(i));
}
- data->temp_max[0] = i2c_smbus_read_byte_data(client,
- ADM9240_REG_TEMP_MAX(0));
- data->temp_max[1] = i2c_smbus_read_byte_data(client,
- ADM9240_REG_TEMP_MAX(1));
+ for (i = 0; i < 2; i++) {
+ data->temp_max[i] = i2c_smbus_read_byte_data(client,
+ ADM9240_REG_TEMP_MAX(i));
+ }
/* read fan divs and 5-bit VID */
i = i2c_smbus_read_byte_data(client, ADM9240_REG_VID_FAN_DIV);
@@ -687,14 +687,14 @@ static void adm9240_init_client(struct i2c_client *client)
i2c_smbus_write_byte_data(client,
ADM9240_REG_IN_MAX(i), 255);
}
- i2c_smbus_write_byte_data(client,
- ADM9240_REG_FAN_MIN(0), 255);
- i2c_smbus_write_byte_data(client,
- ADM9240_REG_FAN_MIN(1), 255);
- i2c_smbus_write_byte_data(client,
- ADM9240_REG_TEMP_MAX(0), 127);
- i2c_smbus_write_byte_data(client,
- ADM9240_REG_TEMP_MAX(1), 127);
+ for (i = 0; i < 2; i++) {
+ i2c_smbus_write_byte_data(client,
+ ADM9240_REG_FAN_MIN(i), 255);
+ }
+ for (i = 0; i < 2; i++) {
+ i2c_smbus_write_byte_data(client,
+ ADM9240_REG_TEMP_MAX(i), 127);
+ }
/* start measurement cycle */
i2c_smbus_write_byte_data(client, ADM9240_REG_CONFIG, 1);