[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <OS0PR01MB592218CADC2F90290B0B727D86EFA@OS0PR01MB5922.jpnprd01.prod.outlook.com>
Date: Wed, 6 Sep 2023 14:46:37 +0000
From: Biju Das <biju.das.jz@...renesas.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
CC: Eric Tremblay <etremblay@...tech-controls.com>,
Jean Delvare <jdelvare@...e.com>,
Guenter Roeck <linux@...ck-us.net>,
"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
Hi Andy,
> Subject: Re: [PATCH v4 1/2] hwmon: tmp513: Add max_channels variable to
> struct tmp51x_data
>
> On Tue, Sep 05, 2023 at 07:42:51PM +0100, Biju Das wrote:
> > The tmp512 chip has 3 channels whereas tmp513 has 4 channels. Avoid
> > using tmp51x_ids for this HW difference by replacing OF/ID table data
> > with maximum channels supported by the device.
> >
> > Replace id->max_channels variable from struct tmp51x_data and drop the
> > macros TMP51{2,3}_TEMP_CONFIG_DEFAULT as it can be derived from the
> > macro TMP51X_TEMP_CONFIG_DEFAULT and update the logic in
> > tmp51x_is_visible(),
> > tmp51x_read_properties() and tmp51x_init() using max_channels.
> >
> > While at it, drop enum tmp51x_ids as there is no user and remove
> > trailing comma in the terminator entry for OF table.
>
> ...
>
> > +#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.
For eg:
GENMASK(14, 11)--> bits 11..14
GENMASK((n) - 1, 0)--> value 15 for 4 channels and 7 for 3 channels.
>
> ...
>
> > +#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.
Cheers,
Biju
Powered by blists - more mailing lists