aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2010-10-28 14:31:48 -0400
committerJean Delvare <khali@endymion.delvare>2010-10-28 14:31:48 -0400
commitfd7f82b8a37ff4d400c2db9c9fa8f9467dc54a08 (patch)
tree41eff04a59f8b78d5d3950911e60851277043ab7 /drivers/hwmon
parent5f7b77cbd4599b6a90d18981d9883a3e20e689fb (diff)
hwmon: (w83795) Make W83795_REG_PWM more efficient
Cascaded conditionals are inefficient. Reorder the fields so that PWM register addresses can be computed more efficiently. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/w83795.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/drivers/hwmon/w83795.c b/drivers/hwmon/w83795.c
index a1d884bb58ad..35f87ca88cf3 100644
--- a/drivers/hwmon/w83795.c
+++ b/drivers/hwmon/w83795.c
@@ -178,15 +178,11 @@ static const u8 IN_LSB_SHIFT_IDX[][2] = {
178#define W83795_REG_TSS(index) (0x209 + (index)) 178#define W83795_REG_TSS(index) (0x209 + (index))
179 179
180#define PWM_OUTPUT 0 180#define PWM_OUTPUT 0
181#define PWM_START 1 181#define PWM_FREQ 1
182#define PWM_NONSTOP 2 182#define PWM_START 2
183#define PWM_STOP_TIME 3 183#define PWM_NONSTOP 3
184#define PWM_FREQ 4 184#define PWM_STOP_TIME 4
185#define W83795_REG_PWM(index, nr) \ 185#define W83795_REG_PWM(index, nr) (0x210 + (nr) * 8 + (index))
186 (((nr) == 0 ? 0x210 : \
187 (nr) == 1 ? 0x220 : \
188 (nr) == 2 ? 0x228 : \
189 (nr) == 3 ? 0x230 : 0x218) + (index))
190 186
191#define W83795_REG_FTSH(index) (0x240 + (index) * 2) 187#define W83795_REG_FTSH(index) (0x240 + (index) * 2)
192#define W83795_REG_FTSL(index) (0x241 + (index) * 2) 188#define W83795_REG_FTSL(index) (0x241 + (index) * 2)
@@ -356,8 +352,8 @@ struct w83795_data {
356 u8 has_pwm; /* 795g supports 8 pwm, 795adg only supports 2, 352 u8 has_pwm; /* 795g supports 8 pwm, 795adg only supports 2,
357 * no config register, only affected by chip 353 * no config register, only affected by chip
358 * type */ 354 * type */
359 u8 pwm[8][5]; /* Register value, output, start, non stop, stop 355 u8 pwm[8][5]; /* Register value, output, freq, start,
360 * time, freq */ 356 * non stop, stop time */
361 u16 clkin; /* CLKIN frequency in kHz */ 357 u16 clkin; /* CLKIN frequency in kHz */
362 u8 pwm_fcms[2]; /* Register value */ 358 u8 pwm_fcms[2]; /* Register value */
363 u8 pwm_tfmr[6]; /* Register value */ 359 u8 pwm_tfmr[6]; /* Register value */
@@ -1979,7 +1975,7 @@ static int w83795_probe(struct i2c_client *client,
1979 data->pwm_tfmr[i] = w83795_read(client, W83795_REG_TFMR(i)); 1975 data->pwm_tfmr[i] = w83795_read(client, W83795_REG_TFMR(i));
1980 data->pwm_fomc = w83795_read(client, W83795_REG_FOMC); 1976 data->pwm_fomc = w83795_read(client, W83795_REG_FOMC);
1981 for (i = 0; i < data->has_pwm; i++) { 1977 for (i = 0; i < data->has_pwm; i++) {
1982 for (tmp = PWM_START; tmp <= PWM_FREQ; tmp++) 1978 for (tmp = PWM_FREQ; tmp <= PWM_STOP_TIME; tmp++)
1983 data->pwm[i][tmp] = 1979 data->pwm[i][tmp] =
1984 w83795_read(client, W83795_REG_PWM(i, tmp)); 1980 w83795_read(client, W83795_REG_PWM(i, tmp));
1985 } 1981 }