All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy@kernel.org>
To: Ceclan Dumitru <mitrutzceclan@gmail.com>
Cc: linus.walleij@linaro.org, brgl@bgdev.pl,
	linux-gpio@vger.kernel.org,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Michael Walle" <michael@walle.cc>,
	"Arnd Bergmann" <arnd@arndb.de>,
	"ChiaEn Wu" <chiaen_wu@richtek.com>,
	"Niklas Schnelle" <schnelle@linux.ibm.com>,
	"Leonard Göhrs" <l.goehrs@pengutronix.de>,
	"Mike Looijmans" <mike.looijmans@topic.nl>,
	"Haibo Chen" <haibo.chen@nxp.com>,
	"Hugo Villeneuve" <hvilleneuve@dimonoff.com>,
	"Ceclan Dumitru" <dumitru.ceclan@analog.com>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/2] iio: adc: ad7173: add AD7173 driver
Date: Mon, 20 Nov 2023 18:21:05 +0200	[thread overview]
Message-ID: <ZVuHcaUQL6xnchK-@smile.fi.intel.com> (raw)
In-Reply-To: <5cf3824f-6375-4c76-86ff-c5389ddf4196@gmail.com>

On Mon, Nov 20, 2023 at 05:55:12PM +0200, Ceclan Dumitru wrote:
> On 11/20/23 15:00, Andy Shevchenko wrote:
> > On Thu, Nov 16, 2023 at 03:46:55PM +0200, mitrutzceclan wrote:

...

> >> +struct ad7173_channel_config {
> >> +	bool live;
> >> +	u8 cfg_slot;
> >> +	/* Following fields are used to compare equality. Bipolar must be first */
> >> +	bool bipolar;
> >> +	bool input_buf;
> >> +	u8 odr;
> >> +	u8 ref_sel;
> > 
> > If you group better by types, it might save a few bytes on the architectures /
> > compilers where bool != byte.
> >
> Grouping by type will result in not being able to use memcmp() for
> comparing configs. But then there is the issue that I was under the
> assumption that bool=byte. If that is not the case, the config equality
> check might be comparing padding bytes.

It's most likely the case, BUT... it is not guaranteed by the C standard.

> In this case what do you suggest:
> - using the packed attribute
> - using only u8
> - drop memcmp, manually compare fields

Use struct_group() to show explicitly the group of members. If it's not an ABI
in any sense, then memcmp() is fine.

...

> >> +	cmp_size = sizeof(*cfg) - offset;
> > 
> > sizeof_field() from the above mentioned header?
> 
> This computes the size of multiple fields, following cfg_slot. Better to
> group the fields that need to be compared into another struct then use
> sizeof_field()?

See above.

...

> >> +	return vref / (MICRO/MILLI);
> > 
> > What does the denominator mean and why you can't simply use MILL?
> 
> Original vref values are in micro, I considered that it was adequate to
> represent the conversion from MICRO to MILLI as a fraction.
> 
> >> +		*val = st->info->sinc5_data_rates[reg] / (MICRO/MILLI);
> >> +		*val2 = (st->info->sinc5_data_rates[reg] % MILLI) * (MICRO/MILLI);
> > 
> > Same Q about denominator.
> > 
> Here, a misunderstanding on my part of a suggestion from Jonathan in V2,
> will be removed.

You need to clarify with him that.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2023-11-20 16:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-16 13:46 [PATCH v4 1/2] dt-bindings: adc: add AD7173 mitrutzceclan
2023-11-16 13:46 ` mitrutzceclan
2023-11-16 13:46 ` [PATCH v4 2/2] iio: adc: ad7173: add AD7173 driver mitrutzceclan
2023-11-16 13:46   ` mitrutzceclan
2023-11-20 13:00   ` Andy Shevchenko
2023-11-20 15:55     ` Ceclan Dumitru
2023-11-20 16:21       ` Andy Shevchenko [this message]
     [not found]         ` <643d2c2c8dd4490081c234b6831ee5dd@analog.com>
2023-11-21 17:17           ` Ceclan Dumitru
2023-11-16 14:47 ` [PATCH v4 1/2] dt-bindings: adc: add AD7173 Rob Herring
2023-11-16 14:54 ` Krzysztof Kozlowski
2023-11-16 17:54   ` Conor Dooley
2023-11-17 12:43 kernel test robot
2023-11-20  3:17 ` kernel test robot

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=ZVuHcaUQL6xnchK-@smile.fi.intel.com \
    --to=andy@kernel.org \
    --cc=arnd@arndb.de \
    --cc=brgl@bgdev.pl \
    --cc=chiaen_wu@richtek.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dumitru.ceclan@analog.com \
    --cc=haibo.chen@nxp.com \
    --cc=hvilleneuve@dimonoff.com \
    --cc=jic23@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=l.goehrs@pengutronix.de \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael@walle.cc \
    --cc=mike.looijmans@topic.nl \
    --cc=mitrutzceclan@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=schnelle@linux.ibm.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.