[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CADiBU3_fZxCigiaa8mh9bHV565Bxiyux1a1zFWmi9v6xwdZzgQ@mail.gmail.com>
Date: Tue, 5 Jul 2022 17:30:39 +0800
From: ChiYuan Huang <u0084500@...il.com>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: Jonathan Cameron <jic23@...nel.org>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Lars-Peter Clausen <lars@...afoo.de>,
cy_huang <cy_huang@...htek.com>,
linux-iio <linux-iio@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
devicetree <devicetree@...r.kernel.org>
Subject: Re: [PATCH v2 2/2] iio: adc: Add rtq6056 support
Andy Shevchenko <andy.shevchenko@...il.com> 於 2022年7月5日 週二 下午5:05寫道:
>
> On Tue, Jul 5, 2022 at 3:41 AM ChiYuan Huang <u0084500@...il.com> wrote:
> > Andy Shevchenko <andy.shevchenko@...il.com> 於 2022年7月5日 週二 清晨5:52寫道:
> > > On Mon, Jul 4, 2022 at 9:27 AM ChiYuan Huang <u0084500@...il.com> wrote:
> > > > ChiYuan Huang <u0084500@...il.com> 於 2022年7月4日 週一 上午11:16寫道:
> > > > > Andy Shevchenko <andy.shevchenko@...il.com> 於 2022年7月1日 週五 下午6:05寫道:
> > > > > > On Wed, Jun 29, 2022 at 4:23 AM cy_huang <u0084500@...il.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.
>
Thanks, I think I can get your point. if it need to be compatible with
others, this part will be a trap.
Then it's better to add the align for timestamp member.
I'll submit the v4 for this.
And very sorry about another mail.
I just confused about the text.
> --
> With Best Regards,
> Andy Shevchenko
Powered by blists - more mailing lists