diff options
author | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-12-08 13:15:51 -0500 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2012-01-05 11:19:30 -0500 |
commit | b1b561a228de9796eff8c7e03e1e7ee63ab13115 (patch) | |
tree | 52912746ebdd55f99068e047a801fddc9cd278a4 /drivers/hwmon | |
parent | 3310600aa7bc11ead9b0324b972d13fb0e91bcaf (diff) |
hwmon: (f75375s) Initialize pwmX_mode and pwmX_enable if there is no platform data
pwmX_mode and pwmX_enable are not initialized if no platform data is provided to
the driver. Read chip configuration at driver initialization time and initialize
attributes to reflect chip configuration.
Cc: Riku Voipio <riku.voipio@iki.fi>
Reviewed-by: Bjoern Gerhart <oss@extracloud.de>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/f75375s.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c index 777a665164f9..9c3f078e263b 100644 --- a/drivers/hwmon/f75375s.c +++ b/drivers/hwmon/f75375s.c | |||
@@ -652,6 +652,31 @@ static void f75375_init(struct i2c_client *client, struct f75375_data *data, | |||
652 | struct f75375s_platform_data *f75375s_pdata) | 652 | struct f75375s_platform_data *f75375s_pdata) |
653 | { | 653 | { |
654 | int nr; | 654 | int nr; |
655 | |||
656 | if (!f75375s_pdata) { | ||
657 | u8 conf, mode; | ||
658 | int nr; | ||
659 | |||
660 | conf = f75375_read8(client, F75375_REG_CONFIG1); | ||
661 | mode = f75375_read8(client, F75375_REG_FAN_TIMER); | ||
662 | for (nr = 0; nr < 2; nr++) { | ||
663 | if (!(conf & (1 << FAN_CTRL_LINEAR(nr)))) | ||
664 | data->pwm_mode[nr] = 1; | ||
665 | switch ((mode >> FAN_CTRL_MODE(nr)) & 3) { | ||
666 | case 0: /* speed */ | ||
667 | data->pwm_enable[nr] = 3; | ||
668 | break; | ||
669 | case 1: /* automatic */ | ||
670 | data->pwm_enable[nr] = 2; | ||
671 | break; | ||
672 | default: /* manual */ | ||
673 | data->pwm_enable[nr] = 1; | ||
674 | break; | ||
675 | } | ||
676 | } | ||
677 | return; | ||
678 | } | ||
679 | |||
655 | set_pwm_enable_direct(client, 0, f75375s_pdata->pwm_enable[0]); | 680 | set_pwm_enable_direct(client, 0, f75375s_pdata->pwm_enable[0]); |
656 | set_pwm_enable_direct(client, 1, f75375s_pdata->pwm_enable[1]); | 681 | set_pwm_enable_direct(client, 1, f75375s_pdata->pwm_enable[1]); |
657 | for (nr = 0; nr < 2; nr++) { | 682 | for (nr = 0; nr < 2; nr++) { |
@@ -703,8 +728,7 @@ static int f75375_probe(struct i2c_client *client, | |||
703 | goto exit_remove; | 728 | goto exit_remove; |
704 | } | 729 | } |
705 | 730 | ||
706 | if (f75375s_pdata != NULL) | 731 | f75375_init(client, data, f75375s_pdata); |
707 | f75375_init(client, data, f75375s_pdata); | ||
708 | 732 | ||
709 | return 0; | 733 | return 0; |
710 | 734 | ||