linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Alex Qiu <xqiu@google.com>
Cc: Hardware Monitoring <linux-hwmon@vger.kernel.org>,
	Jean Delvare <jdelvare@suse.com>
Subject: Re: [PATCH] hwmon: (pmbus) Improve initialization of 'currpage' and 'currphase'
Date: Thu, 7 May 2020 13:55:13 -0700	[thread overview]
Message-ID: <20200507205513.GB215120@roeck-us.net> (raw)
In-Reply-To: <CAA_a9x+HokYr+kTVfE-tqpztwJRF78bD-YA9TDAak41V81oPoA@mail.gmail.com>

On Thu, May 07, 2020 at 01:19:58PM -0700, Alex Qiu wrote:
> Hi Guenter,
> 
> LGTM; minor nits:
> 
> On Thu, May 7, 2020 at 10:44 AM Guenter Roeck <linux@roeck-us.net> wrote:
> >
> > The 'currpage' and 'currphase' variables in struct pmbus_data are used by
> > the PMBus core to determine if the phase or page value has changed. Both
> > are initialized with values which are never expected to be set in the code
> > to ensure that the first page/phase write operation is actually performed.
> >
> > This is not well explained and occasionally causes confusion. Change the
> > type of both variables to s16 and initialize with -1 to ensure that the
> > initial value never matches a requested value, and clarify that this
> > value means "unknown/unset".
> >
> > Cc: Alex Qiu <xqiu@google.com>
> > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> > ---
> >  drivers/hwmon/pmbus/pmbus_core.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
> > index 8d321bf7d15b..a420877ba533 100644
> > --- a/drivers/hwmon/pmbus/pmbus_core.c
> > +++ b/drivers/hwmon/pmbus/pmbus_core.c
> > @@ -109,8 +109,8 @@ struct pmbus_data {
> >         bool has_status_word;           /* device uses STATUS_WORD register */
> >         int (*read_status)(struct i2c_client *client, int page);
> >
> > -       u8 currpage;
> > -       u8 currphase;   /* current phase, 0xff for all */
> > +       s16 currpage;   /* current page, -1 for unknown/unset */
> > +       s16 currphase;  /* current phase, 0xff for all, -1 for unknown/unset */
> I'm not sure if assigning macros for -1 and 0xff would be a good idea?

The driver uses hardcoded 0xff in various places. We could replace it
with defines, but that should be a separate patch.

Thanks,
Guenter

      reply	other threads:[~2020-05-07 20:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-07 17:44 [PATCH] hwmon: (pmbus) Improve initialization of 'currpage' and 'currphase' Guenter Roeck
2020-05-07 20:19 ` Alex Qiu
2020-05-07 20:55   ` Guenter Roeck [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=20200507205513.GB215120@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=xqiu@google.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;
as well as URLs for NNTP newsgroup(s).