From: "Hans J. Koch" <hjk@linutronix.de>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH] hwmon: (max6650) Allow setting of fan
Date: Wed, 25 Nov 2009 09:54:40 +0000 [thread overview]
Message-ID: <20091125095439.GA3244@bluebox.local> (raw)
In-Reply-To: <4B0C982F.2090500@elphinstone.net>
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
prev parent reply other threads:[~2009-11-25 9:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091125095439.GA3244@bluebox.local \
--to=hjk@linutronix.de \
--cc=lm-sensors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.