All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Vadim Pasternak <vadimp@mellanox.com>
Cc: "linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>,
	Michael Shych <michaelsh@mellanox.com>
Subject: Re: [PATCH hwmon-next v1 1/1] hwmon: (mlxreg-fan) Fix macros for tacho fault reading
Date: Mon, 19 Nov 2018 08:15:07 -0800	[thread overview]
Message-ID: <20181119161507.GA12726@roeck-us.net> (raw)
In-Reply-To: <AM6PR05MB5224D3D72EF7970AB2A18E06A2D80@AM6PR05MB5224.eurprd05.prod.outlook.com>

On Mon, Nov 19, 2018 at 06:07:40AM +0000, Vadim Pasternak wrote:
> 
> 
> > -----Original Message-----
> > From: Guenter Roeck <groeck7@gmail.com> On Behalf Of Guenter Roeck
> > Sent: Friday, November 16, 2018 6:15 PM
> > To: Vadim Pasternak <vadimp@mellanox.com>
> > Cc: linux-hwmon@vger.kernel.org; Michael Shych <michaelsh@mellanox.com>
> > Subject: Re: [PATCH hwmon-next v1 1/1] hwmon: (mlxreg-fan) Fix macros for
> > tacho fault reading
> > 
> > On Fri, Nov 16, 2018 at 01:47:11PM +0000, Vadim Pasternak wrote:
> > > Fix macros for tacometer fault reading.
> > > This fix is relevant for three Mellanox systems MQMB7, MSN37, MSN34,
> > > which are about to be released to the customers.
> > > At the moment, none of them is at customers sites.
> > >
> > > Fixes: 65afb4c8e7e4 ("hwmon: (mlxreg-fan) Add support for Mellanox FAN
> > > driver")
> > > Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
> > > ---
> > >  drivers/hwmon/mlxreg-fan.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/hwmon/mlxreg-fan.c b/drivers/hwmon/mlxreg-fan.c
> > > index de46577..d8fa4be 100644
> > > --- a/drivers/hwmon/mlxreg-fan.c
> > > +++ b/drivers/hwmon/mlxreg-fan.c
> > > @@ -51,7 +51,7 @@
> > >   */
> > >  #define MLXREG_FAN_GET_RPM(rval, d, s)
> > 	(DIV_ROUND_CLOSEST(15000000 * 100, \
> > >  					 ((rval) + (s)) * (d)))
> > > -#define MLXREG_FAN_GET_FAULT(val, mask) (!!((val) ^ (mask)))
> > > +#define MLXREG_FAN_GET_FAULT(val, mask) (!((val) ^ (mask)))
> > 
> > You might want to check if the "^" is correct here. It looks fishy, since the
> > expression only evaluates to true if a no bit of val outside mask is set. I would
> > have expected "&".
> > 
> > Guenter
> 
> Hi Guenter,
> 
> Thanks for you your comment.
> 
> I'll follow your suggestion and change a macros to" 
> #define MLXREG_FAN_GET_FAULT(val, mask) (!((val & mask) ^ (mask)))
> 
That seems excessively complicated. Why the xor after the & ?

Guenter

> > 
> > >  #define MLXREG_FAN_PWM_DUTY2STATE(duty)
> > 	(DIV_ROUND_CLOSEST((duty) *	\
> > >  					 MLXREG_FAN_MAX_STATE,
> > 	\
> > >  					 MLXREG_FAN_MAX_DUTY))

  reply	other threads:[~2018-11-20  2:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-16 13:47 [PATCH hwmon-next v1 1/1] hwmon: (mlxreg-fan) Fix macros for tacho fault reading Vadim Pasternak
2018-11-16 16:10 ` Guenter Roeck
2018-11-16 16:15 ` Guenter Roeck
2018-11-19  6:07   ` Vadim Pasternak
2018-11-19 16:15     ` Guenter Roeck [this message]
2018-11-20 14:46       ` Vadim Pasternak
2018-11-20 16:23         ` 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=20181119161507.GA12726@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=michaelsh@mellanox.com \
    --cc=vadimp@mellanox.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 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.