From: Guenter Roeck <linux@roeck-us.net>
To: Naresh Solanki <naresh.solanki@9elements.com>
Cc: Jean Delvare <jdelvare@suse.com>,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 2/2] hwmon: (max6639) : Add hwmon attributes for fan and pwm
Date: Fri, 14 Jun 2024 06:34:46 -0700 [thread overview]
Message-ID: <3df529a9-b2cc-467e-aef0-598dcdbbfb3e@roeck-us.net> (raw)
In-Reply-To: <20240614055533.2735210-2-naresh.solanki@9elements.com>
On Fri, Jun 14, 2024 at 11:25:31AM +0530, Naresh Solanki wrote:
> Add attribute for fan & pwm i.e.,
> fanY_pulse
> pwmY_freq
>
> Signed-off-by: Naresh Solanki <naresh.solanki@9elements.com>
> ---
> Changes in V5:
> - Remove unnecessary IS_ERR check.
> - Add mutex
> ---
> drivers/hwmon/max6639.c | 90 +++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 86 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/hwmon/max6639.c b/drivers/hwmon/max6639.c
> index 45ed629c6af9..091a4a0abd27 100644
> --- a/drivers/hwmon/max6639.c
> +++ b/drivers/hwmon/max6639.c
> @@ -76,6 +76,7 @@ static const unsigned int freq_table[] = { 20, 33, 50, 100, 5000, 8333, 12500,
> */
> struct max6639_data {
> struct regmap *regmap;
> + struct mutex update_lock;
>
> /* Register values initialized only once */
> u8 ppr[MAX6639_NUM_CHANNELS]; /* Pulses per rotation 0..3 for 1..4 ppr */
> @@ -232,6 +233,9 @@ static int max6639_read_fan(struct device *dev, u32 attr, int channel,
> return res;
> *fan_val = !!(val & BIT(1 - channel));
> return 0;
> + case hwmon_fan_pulses:
> + *fan_val = data->ppr[channel];
> + return 0;
> default:
> return -EOPNOTSUPP;
> }
> @@ -243,6 +247,33 @@ static int max6639_set_ppr(struct max6639_data *data, int channel, u8 ppr)
> return regmap_write(data->regmap, MAX6639_REG_FAN_PPR(channel), ppr-- << 6);
> }
>
> +static int max6639_write_fan(struct device *dev, u32 attr, int channel,
> + long val)
> +{
> + struct max6639_data *data = dev_get_drvdata(dev);
> + int err;
> +
> + switch (attr) {
> + case hwmon_fan_pulses:
> + if (val <= 0 || val > 5)
> + return -EINVAL;
> +
Testing max6639 ...
Out of range value accepted writing into fan1_pulses: val=5 max=4
Out of range value accepted writing into fan2_pulses: val=5 max=4
Valid range is 1..4.
No need to resend, I'll fix that up and apply.
Thanks,
Guenter
next prev parent reply other threads:[~2024-06-14 13:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-14 5:55 [PATCH v5 1/2] hwmon: (max6639) : Update hwmon init using info structure Naresh Solanki
2024-06-14 5:55 ` [PATCH v5 2/2] hwmon: (max6639) : Add hwmon attributes for fan and pwm Naresh Solanki
2024-06-14 13:34 ` Guenter Roeck [this message]
2024-06-14 13:08 ` [PATCH v5 1/2] hwmon: (max6639) : Update hwmon init using info structure Guenter Roeck
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=3df529a9-b2cc-467e-aef0-598dcdbbfb3e@roeck-us.net \
--to=linux@roeck-us.net \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=naresh.solanki@9elements.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox