* [lm-sensors] [PATCH] hwmon: (max6650) Allow setting of fan voltage
@ 2009-11-25 2:36 Mark Ware
2009-11-25 9:54 ` [lm-sensors] [PATCH] hwmon: (max6650) Allow setting of fan Hans J. Koch
0 siblings, 1 reply; 2+ messages in thread
From: Mark Ware @ 2009-11-25 2:36 UTC (permalink / raw)
To: lm-sensors
The current way to set fan voltage and prescaler parameters is
system-wide via module parameters. This patch allows them to be set on
a per chip basis using platform_data. If no platform data is provided,
the existing behaviour is maintained.
---
drivers/hwmon/max6650.c | 88 +++++++++++++++++++++++++----------------------
1 files changed, 47 insertions(+), 41 deletions(-)
diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c
index 58f66be..2e8ab9e 100644
--- a/drivers/hwmon/max6650.c
+++ b/drivers/hwmon/max6650.c
@@ -635,52 +635,58 @@ static int max6650_init_client(struct i2c_client *client)
return err;
}
- switch (fan_voltage) {
- case 0:
- break;
- case 5:
- config &= ~MAX6650_CFG_V12;
- break;
- case 12:
- config |= MAX6650_CFG_V12;
- break;
- default:
- dev_err(&client->dev,
- "illegal value for fan_voltage (%d)\n",
- fan_voltage);
+ if (client->dev.platform_data) {
+ config = *(u8 *)client->dev.platform_data;
+ }
+ else
+ {
+ switch (fan_voltage) {
+ case 0:
+ break;
+ case 5:
+ config &= ~MAX6650_CFG_V12;
+ break;
+ case 12:
+ config |= MAX6650_CFG_V12;
+ break;
+ default:
+ dev_err(&client->dev,
+ "illegal value for fan_voltage (%d)\n",
+ fan_voltage);
+ }
+
+ switch (prescaler) {
+ case 0:
+ break;
+ case 1:
+ config &= ~MAX6650_CFG_PRESCALER_MASK;
+ break;
+ case 2:
+ config = (config & ~MAX6650_CFG_PRESCALER_MASK)
+ | MAX6650_CFG_PRESCALER_2;
+ break;
+ case 4:
+ config = (config & ~MAX6650_CFG_PRESCALER_MASK)
+ | MAX6650_CFG_PRESCALER_4;
+ break;
+ case 8:
+ config = (config & ~MAX6650_CFG_PRESCALER_MASK)
+ | MAX6650_CFG_PRESCALER_8;
+ break;
+ case 16:
+ config = (config & ~MAX6650_CFG_PRESCALER_MASK)
+ | MAX6650_CFG_PRESCALER_16;
+ break;
+ default:
+ dev_err(&client->dev,
+ "illegal value for prescaler (%d)\n",
+ prescaler);
+ }
}
dev_info(&client->dev, "Fan voltage is set to %dV.\n",
(config & MAX6650_CFG_V12) ? 12 : 5);
- switch (prescaler) {
- case 0:
- break;
- case 1:
- config &= ~MAX6650_CFG_PRESCALER_MASK;
- break;
- case 2:
- config = (config & ~MAX6650_CFG_PRESCALER_MASK)
- | MAX6650_CFG_PRESCALER_2;
- break;
- case 4:
- config = (config & ~MAX6650_CFG_PRESCALER_MASK)
- | MAX6650_CFG_PRESCALER_4;
- break;
- case 8:
- config = (config & ~MAX6650_CFG_PRESCALER_MASK)
- | MAX6650_CFG_PRESCALER_8;
- break;
- case 16:
- config = (config & ~MAX6650_CFG_PRESCALER_MASK)
- | MAX6650_CFG_PRESCALER_16;
- break;
- default:
- dev_err(&client->dev,
- "illegal value for prescaler (%d)\n",
- prescaler);
- }
-
dev_info(&client->dev, "Prescaler is set to %d.\n",
1 << (config & MAX6650_CFG_PRESCALER_MASK));
--
1.5.6.5
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [lm-sensors] [PATCH] hwmon: (max6650) Allow setting of fan
2009-11-25 2:36 [lm-sensors] [PATCH] hwmon: (max6650) Allow setting of fan voltage Mark Ware
@ 2009-11-25 9:54 ` Hans J. Koch
0 siblings, 0 replies; 2+ messages in thread
From: Hans J. Koch @ 2009-11-25 9:54 UTC (permalink / raw)
To: lm-sensors
On Wed, Nov 25, 2009 at 01:36:31PM +1100, Mark Ware wrote:
> The current way to set fan voltage and prescaler parameters is
> system-wide via module parameters. This patch allows them to be set on
> a per chip basis using platform_data. If no platform data is provided,
> the existing behaviour is maintained.
> ---
> drivers/hwmon/max6650.c | 88 +++++++++++++++++++++++++----------------------
> 1 files changed, 47 insertions(+), 41 deletions(-)
>
> diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c
> index 58f66be..2e8ab9e 100644
> --- a/drivers/hwmon/max6650.c
> +++ b/drivers/hwmon/max6650.c
> @@ -635,52 +635,58 @@ static int max6650_init_client(struct i2c_client *client)
> return err;
> }
>
> - switch (fan_voltage) {
> - case 0:
> - break;
> - case 5:
> - config &= ~MAX6650_CFG_V12;
> - break;
> - case 12:
> - config |= MAX6650_CFG_V12;
> - break;
> - default:
> - dev_err(&client->dev,
> - "illegal value for fan_voltage (%d)\n",
> - fan_voltage);
> + if (client->dev.platform_data) {
> + config = *(u8 *)client->dev.platform_data;
This silently ignores errors in that platform data. I'd find it better
to have some struct max6650_platform_data, containing an element
"fan_voltage". Then you can run the given value through the same switch
below, checking errors. Furthermore, the struct offers room for future
extensions.
> + }
> + else
> + {
Make this } else { in one line
Thanks,
Hans
> + switch (fan_voltage) {
> + case 0:
> + break;
> + case 5:
> + config &= ~MAX6650_CFG_V12;
> + break;
> + case 12:
> + config |= MAX6650_CFG_V12;
> + break;
> + default:
> + dev_err(&client->dev,
> + "illegal value for fan_voltage (%d)\n",
> + fan_voltage);
> + }
> +
> + switch (prescaler) {
> + case 0:
> + break;
> + case 1:
> + config &= ~MAX6650_CFG_PRESCALER_MASK;
> + break;
> + case 2:
> + config = (config & ~MAX6650_CFG_PRESCALER_MASK)
> + | MAX6650_CFG_PRESCALER_2;
> + break;
> + case 4:
> + config = (config & ~MAX6650_CFG_PRESCALER_MASK)
> + | MAX6650_CFG_PRESCALER_4;
> + break;
> + case 8:
> + config = (config & ~MAX6650_CFG_PRESCALER_MASK)
> + | MAX6650_CFG_PRESCALER_8;
> + break;
> + case 16:
> + config = (config & ~MAX6650_CFG_PRESCALER_MASK)
> + | MAX6650_CFG_PRESCALER_16;
> + break;
> + default:
> + dev_err(&client->dev,
> + "illegal value for prescaler (%d)\n",
> + prescaler);
> + }
> }
>
> dev_info(&client->dev, "Fan voltage is set to %dV.\n",
> (config & MAX6650_CFG_V12) ? 12 : 5);
>
> - switch (prescaler) {
> - case 0:
> - break;
> - case 1:
> - config &= ~MAX6650_CFG_PRESCALER_MASK;
> - break;
> - case 2:
> - config = (config & ~MAX6650_CFG_PRESCALER_MASK)
> - | MAX6650_CFG_PRESCALER_2;
> - break;
> - case 4:
> - config = (config & ~MAX6650_CFG_PRESCALER_MASK)
> - | MAX6650_CFG_PRESCALER_4;
> - break;
> - case 8:
> - config = (config & ~MAX6650_CFG_PRESCALER_MASK)
> - | MAX6650_CFG_PRESCALER_8;
> - break;
> - case 16:
> - config = (config & ~MAX6650_CFG_PRESCALER_MASK)
> - | MAX6650_CFG_PRESCALER_16;
> - break;
> - default:
> - dev_err(&client->dev,
> - "illegal value for prescaler (%d)\n",
> - prescaler);
> - }
> -
> dev_info(&client->dev, "Prescaler is set to %d.\n",
> 1 << (config & MAX6650_CFG_PRESCALER_MASK));
>
> --
> 1.5.6.5
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-11-25 9:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-25 2:36 [lm-sensors] [PATCH] hwmon: (max6650) Allow setting of fan voltage Mark Ware
2009-11-25 9:54 ` [lm-sensors] [PATCH] hwmon: (max6650) Allow setting of fan Hans J. Koch
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.