linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: ChiYuan Huang <u0084500@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	cy_huang <cy_huang@richtek.com>,
	linux-iio <linux-iio@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	devicetree <devicetree@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] iio: adc: Add rtq6056 support
Date: Tue, 5 Jul 2022 11:04:32 +0200	[thread overview]
Message-ID: <CAHp75VfyKtFQbcJJxW8TNSHMZppM6Qgj4hxiUzLB1bSmeWBBAg@mail.gmail.com> (raw)
In-Reply-To: <CADiBU38FbZ87EHn_UDy-rS6V2bGDdLZJOcqNZsS03MzbNaVaKA@mail.gmail.com>

On Tue, Jul 5, 2022 at 3:41 AM ChiYuan Huang <u0084500@gmail.com> wrote:
> Andy Shevchenko <andy.shevchenko@gmail.com> 於 2022年7月5日 週二 清晨5:52寫道:
> > On Mon, Jul 4, 2022 at 9:27 AM ChiYuan Huang <u0084500@gmail.com> wrote:
> > > ChiYuan Huang <u0084500@gmail.com> 於 2022年7月4日 週一 上午11:16寫道:
> > > > Andy Shevchenko <andy.shevchenko@gmail.com> 於 2022年7月1日 週五 下午6:05寫道:
> > > > > On Wed, Jun 29, 2022 at 4:23 AM cy_huang <u0084500@gmail.com> wrote:

...

> > > > > > +       struct {
> > > > > > +               u16 vals[RTQ6056_MAX_CHANNEL];
> > > > > > +               int64_t timestamp;
> > > > > > +       } data __aligned(8);
> > > > >
> > > > > Hmm... alignment of this struct will be at least 4 bytes, but
> > > > > shouldn't we rather be sure that the timestamp member is aligned
> > > > > properly? Otherwise this seems fragile and dependent on
> > > > > RTQ6056_MAX_CHANNEL % 4 == 0.
> > > > >
> > > > Yap, from the 'max channel', it already guarantee this struct will be
> > > > aligned at lease 4.
> > > > Actually, It can be removed.
> >
> > I think for the safest side it should be given to the timestamp member. No?
> >
> Sorry, following your comment, Why to use 'align' for the timestamp member?
> the data member already guarantee 2 * 4 = 8 byte, then timestamp will
> be 8 byte aligned, right?

Today it's true, tomorrow it might be different. Imagine if this
driver will cover a new (version of) hardware and needs an additional
channel, how do you guarantee alignment in that case? So, current
approach is working, but fragile.

> what you mentioned is to put __aligned(8) only for timestamp.

Yes.

> I try to put aligned in two ways ( one is only for timestamp, another
> is the whole struct). the result is the same.
> From my thinking, in this case, the struct is already 8 byte aligned
> for timestamp member. don't you think to put 'aligned' is redundant?

No.

-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2022-07-05  9:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-29  2:20 [PATCH v2 0/2] Add Richtek RTQ6056 support cy_huang
2022-06-29  2:20 ` [PATCH v2 1/2] dt-bindings: iio: adc: Add rtq6056 adc support cy_huang
2022-06-29  8:25   ` Krzysztof Kozlowski
2022-06-29  8:59     ` ChiYuan Huang
2022-06-29  2:20 ` [PATCH v2 2/2] iio: adc: Add rtq6056 support cy_huang
2022-07-01 10:04   ` Andy Shevchenko
2022-07-04  3:16     ` ChiYuan Huang
2022-07-04  7:27       ` ChiYuan Huang
2022-07-04 21:51         ` Andy Shevchenko
2022-07-05  1:41           ` ChiYuan Huang
2022-07-05  9:04             ` Andy Shevchenko [this message]
2022-07-05  9:30               ` ChiYuan Huang
     [not found]                 ` <CADiBU3_qL1xf+VirMxD5q3wOH_UGSpXZi6pCjX2H44zbeXBqdg@mail.gmail.com>
2022-07-05 11:01                   ` Andy Shevchenko
2022-07-07 17:05                     ` Jonathan Cameron
2022-07-07 17:02             ` Jonathan Cameron

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=CAHp75VfyKtFQbcJJxW8TNSHMZppM6Qgj4hxiUzLB1bSmeWBBAg@mail.gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=cy_huang@richtek.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=u0084500@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).