diff options
author | Jean Delvare <khali@linux-fr.org> | 2010-10-28 14:31:47 -0400 |
---|---|---|
committer | Jean Delvare <khali@endymion.delvare> | 2010-10-28 14:31:47 -0400 |
commit | c1a792a6eea42d88a99e6ace215b22fbdb76c7b6 (patch) | |
tree | 92c6f630e7044fdd65100326ed0489a6cc1f5b0a /drivers/hwmon/w83795.c | |
parent | 02728ffef9c2cf067e654e832b8c282a8a4d0b16 (diff) |
hwmon: (w83795) Avoid reading the same register twice
Shorten driver load time by avoiding duplicate register access during
initialization. This saves 112 ms on modprobe on my test system.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/w83795.c')
-rw-r--r-- | drivers/hwmon/w83795.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/hwmon/w83795.c b/drivers/hwmon/w83795.c index fd70a7b46295..aea3275f5dae 100644 --- a/drivers/hwmon/w83795.c +++ b/drivers/hwmon/w83795.c | |||
@@ -1986,6 +1986,9 @@ static int w83795_probe(struct i2c_client *client, | |||
1986 | data->in[i][IN_READ] = tmp; | 1986 | data->in[i][IN_READ] = tmp; |
1987 | } | 1987 | } |
1988 | for (i = 0; i < IN_LSB_REG_NUM; i++) { | 1988 | for (i = 0; i < IN_LSB_REG_NUM; i++) { |
1989 | if ((i == 2 && data->chip_type == w83795adg) || | ||
1990 | (i >= 4 && !(data->has_in & (1 << (i + 11))))) | ||
1991 | continue; | ||
1989 | data->in_lsb[i][IN_MAX] = | 1992 | data->in_lsb[i][IN_MAX] = |
1990 | w83795_read(client, IN_LSB_REG(i, IN_MAX)); | 1993 | w83795_read(client, IN_LSB_REG(i, IN_MAX)); |
1991 | data->in_lsb[i][IN_LOW] = | 1994 | data->in_lsb[i][IN_LOW] = |
@@ -1995,13 +1998,17 @@ static int w83795_probe(struct i2c_client *client, | |||
1995 | 1998 | ||
1996 | /* First update fan and limits */ | 1999 | /* First update fan and limits */ |
1997 | for (i = 0; i < ARRAY_SIZE(data->fan); i++) { | 2000 | for (i = 0; i < ARRAY_SIZE(data->fan); i++) { |
2001 | /* Each register contains LSB for 2 fans, but we want to | ||
2002 | * read it only once to save time */ | ||
2003 | if ((i & 1) == 0 && (data->has_fan & (3 << i))) | ||
2004 | tmp = w83795_read(client, W83795_REG_FAN_MIN_LSB(i)); | ||
2005 | |||
1998 | if (!(data->has_fan & (1 << i))) | 2006 | if (!(data->has_fan & (1 << i))) |
1999 | continue; | 2007 | continue; |
2000 | data->fan_min[i] = | 2008 | data->fan_min[i] = |
2001 | w83795_read(client, W83795_REG_FAN_MIN_HL(i)) << 4; | 2009 | w83795_read(client, W83795_REG_FAN_MIN_HL(i)) << 4; |
2002 | data->fan_min[i] |= | 2010 | data->fan_min[i] |= |
2003 | (w83795_read(client, W83795_REG_FAN_MIN_LSB(i)) >> | 2011 | (tmp >> W83795_REG_FAN_MIN_LSB_SHIFT(i)) & 0x0F; |
2004 | W83795_REG_FAN_MIN_LSB_SHIFT(i)) & 0x0F; | ||
2005 | data->fan[i] = w83795_read(client, W83795_REG_FAN(i)) << 4; | 2012 | data->fan[i] = w83795_read(client, W83795_REG_FAN(i)) << 4; |
2006 | data->fan[i] |= | 2013 | data->fan[i] |= |
2007 | (w83795_read(client, W83795_REG_VRLSB) >> 4) & 0x0F; | 2014 | (w83795_read(client, W83795_REG_VRLSB) >> 4) & 0x0F; |