All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Biju Das <biju.das.jz@bp.renesas.com>
Cc: Eric Tremblay <etremblay@distech-controls.com>,
	Jean Delvare <jdelvare@suse.com>,
	Guenter Roeck <linux@roeck-us.net>,
	"linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Biju Das <biju.das.au@gmail.com>
Subject: Re: [PATCH v4 1/2] hwmon: tmp513: Add max_channels variable to struct tmp51x_data
Date: Wed, 6 Sep 2023 17:59:55 +0300	[thread overview]
Message-ID: <ZPiT606wpCDsNVPC@smile.fi.intel.com> (raw)
In-Reply-To: <OS0PR01MB592218CADC2F90290B0B727D86EFA@OS0PR01MB5922.jpnprd01.prod.outlook.com>

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.

...

> > > +#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?

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2023-09-06 15:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-05 18:42 [PATCH v4 0/2] Enhancements for tmp51x driver Biju Das
2023-09-05 18:42 ` [PATCH v4 1/2] hwmon: tmp513: Add max_channels variable to struct tmp51x_data Biju Das
2023-09-06 14:40   ` Andy Shevchenko
2023-09-06 14:46     ` Biju Das
2023-09-06 14:59       ` Andy Shevchenko [this message]
2023-09-06 15:21         ` Guenter Roeck
2023-09-05 18:42 ` [PATCH v4 2/2] hwmon: tmp513: Simplify tmp51x_read_properties() Biju Das

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=ZPiT606wpCDsNVPC@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=biju.das.au@gmail.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=etremblay@distech-controls.com \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /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.