hwmon/f71882fg: Make the decision wether
PATCH 3/3 hwmon/f71882fg: Make the decision wether
Before this patch the f71882fg driver completely fails to initialize on systems which have reserved settings in the pwm enable register, and it disables all auto pwm sysfs attributes if any fan is controlled by a digital sensor reading.
This patch changes the fail to initialize into don't register any attributes for the fan for which there are reserved settings in the pwm enable register and also makes the not registering of auto pwm sysfs attributes a per fan thing.
--- drivers/hwmon/f71882fg.c | 119 +++++++++++++++++++++------------------------- 1 files changed, 54 insertions(+), 65 deletions(-)
drivers/hwmon/f71882fg.c +53 -64
@@ -2155,11 +2155,37 @@ static void f71882fg_remove_sysfs_files(struct platform_device *pdev, }static int __devinit f71882fg_create_fan_sysfs_files ( -struct platform_device *pdev,int idx,bool pwm_auto_point) +struct platform_device *pdev,int idx) {struct f71882fg_data *data =platform_get_drvdata (pdev);int err; +/* Sanity check the pwm setting */ + err =0 ; +switch (data->type) { +case f71858fg: +if (((data->pwm_enable >> (idx *2 )) &3 ) =3 ) + err =1 ; +break ; +case f71862fg: +if (((data->pwm_enable >> (idx *2 )) &1 ) !=1 ) + err =1 ; +break ; +case f8000: +if (idx =2 ) + err = data->pwm_enable &0x20 ; +break ; +default : +break ; + } +if (err) { +dev_err (&pdev->dev, +"Invalid (reserved) pwm settings: 0x%02x, " +"skipping fan %d\n" , + (data->pwm_enable >> (idx *2 )) &3 , idx +1 ); +return 0 ;/* This is a non fatal condition */ + } + err =f71882fg_create_sysfs_files (pdev, &fxxxx_fan_attr[idx][0 ],ARRAY_SIZE (fxxxx_fan_attr[0 ]));if (err)
@@ -2173,8 +2199,32 @@ static int __devinit f71882fg_create_fan_sysfs_files(return err; } -if (!pwm_auto_point) -return 0 ;/* All done */ +dev_info (&pdev->dev,"Fan: %d is in %s mode\n" , idx +1 , + (data->pwm_enable & (1 << (2 * idx))) ?"duty-cycle" :"RPM" ); + +/* Check for unsupported auto pwm settings */ +switch (data->type) { +case f71808e: +case f71808a: +case f71869: +case f71869a: +case f71889fg: +case f71889ed: +case f71889a: + data->pwm_auto_point_mapping[idx] +f71882fg_read8 (data,F71882FG_REG_POINT_MAPPING (idx)); +if ((data->pwm_auto_point_mapping[idx] &0x80 ) || + (data->pwm_auto_point_mapping[idx] &3 ) =0 ) { +dev_warn (&pdev->dev, +"Auto pwm controlled by raw digital " +"data, disabling pwm auto_point " +"sysfs attributes for fan %d\n" , idx +1 ); +return 0 ;/* This is a non fatal condition */ + } +break ; +default : +break ; + }switch (data->type) {case f71862fg:
@@ -2295,8 +2345,6 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) }if (start_reg &0x02 ) { -bool pwm_auto_point = true; -switch (data->type) {case f71808e:case f71808a:
@@ -2322,69 +2370,10 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) data->pwm_enable f71882fg_read8(data, F71882FG_REG_PWM_ENABLE); -/* Sanity check the pwm settings */ -switch (data->type) { -case f71858fg: - err =0 ; -for (i =0 ; i < nr_fans; i++) -if (((data->pwm_enable >> (i *2 )) &3 ) =3 ) - err =1 ; -break ; -case f71862fg: - err = (data->pwm_enable &0x15 ) !=0x15 ; -break ; -case f8000: - err = data->pwm_enable &0x20 ; -break ; -default : - err =0 ; -break ; - } -if (err) { -dev_err (&pdev->dev, -"Invalid (reserved) pwm settings: 0x%02x\n" , - (unsigned int )data->pwm_enable); - err = -ENODEV ; - goto exit_unregister_sysfs; - } - -switch (data->type) { -case f71808e: -case f71808a: -case f71869: -case f71869a: -case f71889fg: -case f71889ed: -case f71889a: -for (i =0 ; i < nr_fans; i++) { - data->pwm_auto_point_mapping[i] -f71882fg_read8 (data, -F71882FG_REG_POINT_MAPPING (i)); -if ((data->pwm_auto_point_mapping[i] &0x80 ) || - (data->pwm_auto_point_mapping[i] &3 ) =0 ) -break ; - } -if (i != nr_fans) { -dev_warn (&pdev->dev, -"Auto pwm controlled by raw digital " -"data, disabling pwm auto_point " -"sysfs attributes\n" ); - pwm_auto_point = false; - } -break ; -default : -break ; - } -for (i =0 ; i < nr_fans; i++) { - err =f71882fg_create_fan_sysfs_files (pdev, i, - pwm_auto_point); + err =f71882fg_create_fan_sysfs_files (pdev, i);if (err) goto exit_unregister_sysfs; - -dev_info (&pdev->dev,"Fan: %d is in %s mode\n" , i +1 , - (data->pwm_enable & (1 <<2 * i)) ? -"duty-cycle" :"RPM" ); }/* Some types have 1 extra fan with limited functionality */
Signature · 7 lines
1.7.6.1 _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 3/3] hwmon/f71882fg: Make the decision
Quoted 11 lines · Hans de Goede
Before this patch the f71882fg driver completely fails to initialize on systems which have reserved settings in the pwm enable register, and it disables all auto pwm sysfs attributes if any fan is controlled by a digital sensor reading.
This patch changes the fail to initialize into don't register any attributes for the fan for which there are reserved settings in the pwm enable register and also makes the not registering of auto pwm sysfs attributes a per fan thing.
Signed-off-by Hans de Goede <[email protected]>
Given that this is no longer a pure hwmon driver, it may make sense to split it into separate mfd/hwmon/watchdog drivers. But on the other side I notice that other drivers in the hwmon directory implement watchdog functionality as well. Bad precedent :(. Wonder what happens with those watchdogs if HWMON is disabled.
Not really sure if we should let this happen, or start being more restrictive and enforce cleaner code. Jean, any thoughts/comments ?
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 3/3] hwmon/f71882fg: Make the decision
In reply to Hans de GoedeHi,
Quoted 13 lines · Guenter Roeck
Quoted 11 lines · Hans de Goede
Before this patch the f71882fg driver completely fails to initialize on systems which have reserved settings in the pwm enable register, and it disables all auto pwm sysfs attributes if any fan is controlled by a digital sensor reading.
This patch changes the fail to initialize into don't register any attributes for the fan for which there are reserved settings in the pwm enable register and also makes the not registering of auto pwm sysfs attributes a per fan thing.
Signed-off-by Hans de Goede<[email protected]>
Quoted 8 lines
Given that this is no longer a pure hwmon driver, it may make sense to split it into separate mfd/hwmon/watchdog drivers. But on the other side I notice that other drivers in the hwmon directory implement watchdog functionality as well. Bad precedent :(. Wonder what happens with those watchdogs if HWMON is disabled.
Not really sure if we should let this happen, or start being more restrictive and enforce cleaner code. Jean, any thoughts/comments ?
It seems that you put this reply in the wrong thread? Can you please copy paste to the right thread (with the CC list intact so that the watchdog people get it too). Then I'll reply there.
Thanks,
Hans
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 3/3] hwmon/f71882fg: Make the decision
In reply to Hans de GoedeQuoted 22 lines · Hans de Goede
Hi,
Quoted 19 lines · Guenter Roeck
Quoted 11 lines · Hans de Goede
Before this patch the f71882fg driver completely fails to initialize on systems which have reserved settings in the pwm enable register, and it disables all auto pwm sysfs attributes if any fan is controlled by a digital sensor reading.
This patch changes the fail to initialize into don't register any attributes for the fan for which there are reserved settings in the pwm enable register and also makes the not registering of auto pwm sysfs attributes a per fan thing.
Signed-off-by Hans de Goede<[email protected]>Given that this is no longer a pure hwmon driver, it may make sense to split it into separate mfd/hwmon/watchdog drivers. But on the other side I notice that other drivers in the hwmon directory implement watchdog functionality as well. Bad precedent :(. Wonder what happens with those watchdogs if HWMON is disabled.
Quoted 7 lines
Quoted 2 lines
Not really sure if we should let this happen, or start being more restrictive and enforce cleaner code. Jean, any thoughts/comments ?
It seems that you put this reply in the wrong thread? Can you please copy paste to the right thread (with the CC list intact so that the watchdog people get it too). Then I'll reply there.
Oops. Not my day :(.
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 3/3] hwmon/f71882fg: Make the decision
In reply to Hans de GoedeQuoted 11 lines · Hans de Goede
Before this patch the f71882fg driver completely fails to initialize on systems which have reserved settings in the pwm enable register, and it disables all auto pwm sysfs attributes if any fan is controlled by a digital sensor reading.
This patch changes the fail to initialize into don't register any attributes for the fan for which there are reserved settings in the pwm enable register and also makes the not registering of auto pwm sysfs attributes a per fan thing.
Signed-off-by Hans de Goede <[email protected]>
Nice cleanup. One minor comment:
[ ... ]
Quoted 23 lines
static int
__devinitf71882fg_create_fan_sysfs_files(drivers/hwmon/f71882fg.c +16
-1- struct platform_device *pdev, int idx, bool pwm_auto_point) + struct platform_device *pdev, int idx) {struct f71882fg_data *data =platform_get_drvdata (pdev);int err; +/* Sanity check the pwm setting */ + err =0 ; +switch (data->type) { +case f71858fg: +if (((data->pwm_enable >> (idx *2 )) &3 ) =3 ) + err =1 ; +break ; +case f71862fg: +if (((data->pwm_enable >> (idx *2 )) &1 ) !=1 ) + err =1 ; +break ; +case f8000: +if (idx =2 ) + err = data->pwm_enable &0x20 ; +break ;
drivers/hwmon/f71882fg.c static void f71882fg_remove_sysfs_files(struct platform_device *pdev, · line 2187
Quoted 10 lines
drivers/hwmon/f71882fg.c +10
-0+default : +break ; + } +if (err) { +dev_err (&pdev->dev, +"Invalid (reserved) pwm settings: 0x%02x, " +"skipping fan %d\n" , + (data->pwm_enable >> (idx *2 )) &3 , idx +1 ); +return 0 ;/* This is a non fatal condition */ + }
Since this is no longer a fatal condition, it might make sense to use dev_warn instead.
Otherwise
Jean, do you want to take the series (and maybe have another look), or do you want me to take it ?
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 3/3] hwmon/f71882fg: Make the decision
In reply to Hans de GoedeQuoted 2 lines · Guenter Roeck
Jean, do you want to take the series (and maybe have another look), or do you want me to take it ?
Please take it, this will free me some time for the coretemp work + reviewing your own patches.
Thanks,
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 3/3] hwmon/f71882fg: Make the decision
In reply to Hans de GoedeHi,
Quoted 44 lines · Guenter Roeck
Quoted 11 lines · Hans de Goede
Before this patch the f71882fg driver completely fails to initialize on systems which have reserved settings in the pwm enable register, and it disables all auto pwm sysfs attributes if any fan is controlled by a digital sensor reading.
This patch changes the fail to initialize into don't register any attributes for the fan for which there are reserved settings in the pwm enable register and also makes the not registering of auto pwm sysfs attributes a per fan thing.
Signed-off-by Hans de Goede<[email protected]>Nice cleanup. One minor comment:
[ ... ]
Quoted 28 lines
static int
__devinitf71882fg_create_fan_sysfs_files(drivers/hwmon/f71882fg.c +21
-1- struct platform_device *pdev, int idx, bool pwm_auto_point) + struct platform_device *pdev, int idx) {struct f71882fg_data *data =platform_get_drvdata (pdev);int err; +/* Sanity check the pwm setting */ + err =0 ; +switch (data->type) { +case f71858fg: +if (((data->pwm_enable>> (idx *2 ))&3 ) =3 ) + err =1 ; +break ; +case f71862fg: +if (((data->pwm_enable>> (idx *2 ))&1 ) !=1 ) + err =1 ; +break ; +case f8000: +if (idx =2 ) + err = data->pwm_enable&0x20 ; +break ; +default : +break ; + } +if (err) { + dev_err(&pdev->dev,
Quoted 8 lines
drivers/hwmon/f71882fg.c static void f71882fg_remove_sysfs_files(struct platform_device *pdev, · line 2187
Quoted 5 lines
drivers/hwmon/f71882fg.c +5
-0+"Invalid (reserved) pwm settings: 0x%02x, " +"skipping fan %d\n" , + (data->pwm_enable>> (idx * 2))& 3, idx + 1); +return 0 ;/* This is a non fatal condition */ + }Since this is no longer a fatal condition, it might make sense to use
dev_warninstead.
Despite being non fatal, this is still very much an error. f71882fg has been doing these checks for quite some time now, and Daniel's mobo is the first one to actual trigger them. Who knows this error may even point out to some BIOS developer that he is doing something wrong (yeah right BIOS developers testing with Linux, well we can always hope).
iow I would prefer to keep this as is :)
Regards,
Hans
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 3/3] hwmon/f71882fg: Make the decision
In reply to Hans de GoedeQuoted 56 lines · Hans de Goede
Hi,
Quoted 44 lines · Guenter Roeck
Quoted 11 lines · Hans de Goede
Before this patch the f71882fg driver completely fails to initialize on systems which have reserved settings in the pwm enable register, and it disables all auto pwm sysfs attributes if any fan is controlled by a digital sensor reading.
This patch changes the fail to initialize into don't register any attributes for the fan for which there are reserved settings in the pwm enable register and also makes the not registering of auto pwm sysfs attributes a per fan thing.
Signed-off-by Hans de Goede<[email protected]>Nice cleanup. One minor comment:
[ ... ]
Quoted 28 lines
static int
__devinitf71882fg_create_fan_sysfs_files(drivers/hwmon/f71882fg.c +21
-1- struct platform_device *pdev, int idx, bool pwm_auto_point) + struct platform_device *pdev, int idx) {struct f71882fg_data *data =platform_get_drvdata (pdev);int err; +/* Sanity check the pwm setting */ + err =0 ; +switch (data->type) { +case f71858fg: +if (((data->pwm_enable>> (idx *2 ))&3 ) =3 ) + err =1 ; +break ; +case f71862fg: +if (((data->pwm_enable>> (idx *2 ))&1 ) !=1 ) + err =1 ; +break ; +case f8000: +if (idx =2 ) + err = data->pwm_enable&0x20 ; +break ; +default : +break ; + } +if (err) { + dev_err(&pdev->dev,Quoted 8 lines
drivers/hwmon/f71882fg.c static void f71882fg_remove_sysfs_files(struct platform_device *pdev, · line 2187
Quoted 5 lines
drivers/hwmon/f71882fg.c +5
-0+"Invalid (reserved) pwm settings: 0x%02x, " +"skipping fan %d\n" , + (data->pwm_enable>> (idx * 2))& 3, idx + 1); +return 0 ;/* This is a non fatal condition */ + }Since this is no longer a fatal condition, it might make sense to use
dev_warninstead.
Quoted 8 lines
Despite being non fatal, this is still very much an error. f71882fg has been doing these checks for quite some time now, and Daniel's mobo is the first one to actual trigger them. Who knows this error may even point out to some BIOS developer that he is doing something wrong (yeah right BIOS developers testing with Linux, well we can always hope).
iow I would prefer to keep this as is :)
Ok, I'll accept that. All three patches applied to -next.
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors