From: William Breathitt Gray <william.gray@linaro.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Johannes Berg <johannes.berg@intel.com>,
Jonathan Cameron <jic23@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>
Subject: Re: [PATCH v3 3/3] counter: 104-quad-8: Utilize helper functions to handle PR, FLAG and PSC
Date: Tue, 11 Apr 2023 10:58:47 -0400 [thread overview]
Message-ID: <ZDV1p36N3wCav/vF@fedora> (raw)
In-Reply-To: <ZDVyJV8TfC31TYP2@smile.fi.intel.com>
[-- Attachment #1: Type: text/plain, Size: 1922 bytes --]
On Tue, Apr 11, 2023 at 05:43:49PM +0300, Andy Shevchenko wrote:
> On Tue, Apr 11, 2023 at 10:05:25AM -0400, William Breathitt Gray wrote:
> > On Tue, Apr 11, 2023 at 04:50:03PM +0300, Andy Shevchenko wrote:
> > > On Mon, Apr 10, 2023 at 10:03:13AM -0400, William Breathitt Gray wrote:
> > > > The Preset Register (PR), Flag Register (FLAG), and Filter Clock
> > > > Prescaler (PSC) have common usage patterns. Wrap up such usage into
> > > > dedicated functions to improve code clarity.
>
> ...
>
> > > > *val = 0;
> > >
> > > Is not needed now as always being initialized by below call.
> >
> > The regmap_noinc_read() call only reads the number of bytes requested.
> > Since we request 3 bytes, the upper bytes of the u64 val remain
> > uninitialized, so that is why we need to set *val = 0. This isn't
> > immediately clear in the code, so I can add a comment to make it
> > explicit.
>
> Hmm...
> Since we are using byte array for the value, can we actually use
> memset() to show that explicitly? Perhaps in that way it will be more visible?
>
> > > > spin_lock_irqsave(&priv->lock, irqflags);
> > > >
> > > > iowrite8(SELECT_RLD | RESET_BP | TRANSFER_CNTR_TO_OL, &chan->control);
> > > > -
> > > > - for (i = 0; i < 3; i++)
> > > > - *val |= (unsigned long)ioread8(&chan->data) << (8 * i);
> > > > + ioread8_rep(&chan->data, val, 3);
>
> But hold on, wouldn't this have an endianess issue? The call fills in LE,
> while here you use the CPU order.
>
> > > > spin_unlock_irqrestore(&priv->lock, irqflags);
>
> That said, I think you should have something like
>
> u8 value[3];
>
> ioread8_rep(..., value, sizeof(value));
>
> *val = get_unaligned_le24(value);
>
> --
> With Best Regards,
> Andy Shevchenko
Yes, I think you're right, that solves both problems at once so I'll use
get_aligned_le24() to set *val.
William Breathitt Gray
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
prev parent reply other threads:[~2023-04-11 14:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-10 14:03 [PATCH v3 0/3] Refactor 104-quad-8 to match device operations William Breathitt Gray
2023-04-10 14:03 ` [PATCH v3 1/3] counter: 104-quad-8: Utilize bitfield access macros William Breathitt Gray
2023-04-10 14:03 ` [PATCH v3 2/3] counter: 104-quad-8: Refactor to buffer states for CMR, IOR, and IDR William Breathitt Gray
2023-04-10 14:03 ` [PATCH v3 3/3] counter: 104-quad-8: Utilize helper functions to handle PR, FLAG and PSC William Breathitt Gray
2023-04-11 13:50 ` Andy Shevchenko
2023-04-11 14:05 ` William Breathitt Gray
2023-04-11 14:43 ` Andy Shevchenko
2023-04-11 14:58 ` William Breathitt Gray [this message]
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=ZDV1p36N3wCav/vF@fedora \
--to=william.gray@linaro.org \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=jic23@kernel.org \
--cc=johannes.berg@intel.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=viro@zeniv.linux.org.uk \
/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