mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: karthik gengan <gengankarthik@gmail.com>,
	Jean Delvare <jdelvare@suse.com>
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [v1 1/1]hwmon:(pmbus) Validate the data for chip supporting vout_mode (PMBUS_HAVE_VOUT) in the linear config.
Date: Tue, 11 Oct 2022 18:35:13 -0700	[thread overview]
Message-ID: <085e90e5-d21e-9068-a2e1-6f7e07fa64df@roeck-us.net> (raw)
In-Reply-To: <CAAboHLVgQKzNVU6XDWGZmnxGK0DGvtgyzMsY9V+UiOJVq1JyTg@mail.gmail.com>

On 10/11/22 16:59, karthik gengan wrote:
> Linear mode config calculation is based on the exponent value
> derived from vout_mode. So vout_mode value should be valid
> for PMBUS_VOUT_MODE command-supported chips.
> 

We can not do this. The operational word is "should". See comment
below "Not all chips support the VOUT_MODE command". It is what it is.
We can not just refuse to support such chips because they don't
support what we expect them to support.

Sure, those chips will (likely) report wrong values since the
exponent will default to 0. That can be adjusted in user space,
or whoever finds such a chip can provide a back-end driver
with the appropriate values configured (for example by providing
a dummy VOUT_MODE command response). That is better than just
rejecting the chip entirely.

 From a practical perspective, if you know about an affected chip
one that would refuse to instantiate after your patch is applied,
I would suggest to submit (or improve) a back-end driver with
an explanation instead.

Thanks,
Guenter

> Signed-off-by: karthik.gengan <gengankarthik@gmail.com <mailto:gengankarthik@gmail.com>>
> ---
>   drivers/hwmon/pmbus/pmbus_core.c | 10 +++++++++-
>   1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
> index 7ec04934747e..5f80c3b8f245 100644
> --- a/drivers/hwmon/pmbus/pmbus_core.c
> +++ b/drivers/hwmon/pmbus/pmbus_core.c
> @@ -2507,9 +2507,17 @@ static int pmbus_identify_common(struct i2c_client *client,
>   {
>      int vout_mode = -1;
> 
> -   if (pmbus_check_byte_register(client, page, PMBUS_VOUT_MODE))
> +   if (pmbus_check_byte_register(client, page, PMBUS_VOUT_MODE)) {
>          vout_mode = _pmbus_read_byte_data(client, page,
>                            PMBUS_VOUT_MODE);
> +       /*
> +        * If the client page supports PMBUS_VOUT_MODE,
> +        * then the output of the VOUT_MODE command should
> +        * be a valid value for linear mode calculation.
> +        */
> +       if ((data->info->format[PSC_VOLTAGE_OUT] == linear) && (vout_mode < 0))
> +           return -ENODEV;
> +   }
>      if (vout_mode >= 0 && vout_mode != 0xff) {
>          /*
>           * Not all chips support the VOUT_MODE command,
> --
> 2.25.1
> 



       reply	other threads:[~2022-10-12  1:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAAboHLVgQKzNVU6XDWGZmnxGK0DGvtgyzMsY9V+UiOJVq1JyTg@mail.gmail.com>
2022-10-12  1:35 ` Guenter Roeck [this message]
2022-10-13  3:42   ` karthik gengan
2022-10-13  4:35     ` 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=085e90e5-d21e-9068-a2e1-6f7e07fa64df@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=gengankarthik@gmail.com \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®