lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <329b6717-6bba-42c4-94a7-7466d3d0f411@roeck-us.net>
Date:   Wed, 6 Sep 2023 08:21:13 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc:     Biju Das <biju.das.jz@...renesas.com>,
        Eric Tremblay <etremblay@...tech-controls.com>,
        Jean Delvare <jdelvare@...e.com>,
        "linux-hwmon@...r.kernel.org" <linux-hwmon@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Biju Das <biju.das.au@...il.com>
Subject: Re: [PATCH v4 1/2] hwmon: tmp513: Add max_channels variable to
 struct tmp51x_data

On Wed, Sep 06, 2023 at 05:59:55PM +0300, Andy Shevchenko wrote:
> On Wed, Sep 06, 2023 at 02:46:37PM +0000, Biju Das wrote:
> > > On Tue, Sep 05, 2023 at 07:42:51PM +0100, Biju Das wrote:
> 
> ...
> 
> > > > +#define TMP51X_TEMP_CONFIG_CONV_RATE	FIELD_PREP(GENMASK(9, 7), 0x7)
> > > > +#define TMP51X_TEMP_CONFIG_RC		BIT(10)
> > > > +#define TMP51X_TEMP_CHANNEL_MASK(n)	FIELD_PREP(GENMASK(14, 11), \
> > > > +						   GENMASK((n) - 1, 0))
> > > 
> > > Why do you need FIELD_PREP() for the pure constants here? Why can you
> > > simply define the constants in the proper place?
> > 
> > I think one can clearly understand the bit definitions and value from FIELD_PREP.
> 
> I think it is clear over engineering. In the first one the constant can't be
> more than the field, in the second the defensive programming that is discouraged
> in the kernel.
> 
> #define TMP51X_TEMP_CHANNEL_MASK(n)	(GENMASK((n) - 1, 0) << 11)
> 
> would suffice and much easier to understand.
> 

I agree.

> ...
> 
> > > > +#define TMP51X_TEMP_CONFIG_DEFAULT(n)	(TMP51X_TEMP_CONFIG_CONT | \
> > > > +			TMP51X_TEMP_CHANNEL_MASK(n) | \
> > > > +			TMP51X_TEMP_CONFIG_CONV_RATE | TMP51X_TEMP_CONFIG_RC)
> > > 
> > > This is better to read in a form of
> > > 
> > > #define TMP51X_TEMP_CONFIG_DEFAULT(n)					\
> > > 	(TMP51X_TEMP_CHANNEL_MASK(n) | TMP51X_TEMP_CONFIG_CONT |	\
> > > 	 TMP51X_TEMP_CONFIG_CONV_RATE | TMP51X_TEMP_CONFIG_RC)
> > > 
> > 
> > I just used the indentation suggested by Guenter.
> 
> But wouldn't my proposal be sightly better to read?

I'd have to look up what specifically I had asked for, but it wasn't meant
to exclude better formatting. I agree that the formatting you suggested
is better.

Guenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ