linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <Marius.Cristea@microchip.com>
To: <David.Laight@ACULAB.COM>, <arnd@arndb.de>
Cc: <linux-arch@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1] asm-generic: introduce be56 unaligned accessors
Date: Mon, 7 Oct 2024 14:40:49 +0000	[thread overview]
Message-ID: <04222aeb7a9c35ec080222168bace72a3788c90a.camel@microchip.com> (raw)
In-Reply-To: <207733c7c25e4e09b0774eb21322e7e5@AcuMS.aculab.com>

Hi David,

  Thank you very much for the feedback.

On Sun, 2024-09-29 at 21:16 +0000, David Laight wrote:
> [You don't often get email from david.laight@aculab.com. Learn why
> this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
> 
> From: marius.cristea@microchip.com
> > Sent: 27 September 2024 09:36
> > 
> > The PAC194X, IIO driver, is using some unaligned 56 bit registers.
> > Provide some helper accessors in preparation for the new driver.
> 
> Someone please shoot the hardware engineer ;-)
> 
> Do separate unaligned access of the first 4 bytes and last four
> bytes.
> It can't matter if the middle byte is accessed twice.
> 
> Or, for reads read 8 bytes from 'p & ~1ul' and then fixup
> the value.
> 

Do you recommend me to drop this patch?

I know that there are some "workarounds", but those didn't "looks"
nice. I was using that function locally and I got a suggestion from the
IIO subsystem maintainer to move it into the kernel in order for others
to used it.


Thanks,
Marius



>         David
> 
> > 
> > Signed-off-by: Marius Cristea <marius.cristea@microchip.com>
> > ---
> >  include/asm-generic/unaligned.h | 27 +++++++++++++++++++++++++++
> >  1 file changed, 27 insertions(+)
> > 
> > diff --git a/include/asm-generic/unaligned.h b/include/asm-
> > generic/unaligned.h
> > index a84c64e5f11e..d171a9f2377a 100644
> > --- a/include/asm-generic/unaligned.h
> > +++ b/include/asm-generic/unaligned.h
> > @@ -152,4 +152,31 @@ static inline u64 get_unaligned_be48(const
> > void *p)
> >       return __get_unaligned_be48(p);
> >  }
> > 
> > +static inline void __put_unaligned_be56(const u64 val, u8 *p)
> > +{
> > +     *p++ = (val >> 48) & 0xff;
> > +     *p++ = (val >> 40) & 0xff;
> > +     *p++ = (val >> 32) & 0xff;
> > +     *p++ = (val >> 24) & 0xff;
> > +     *p++ = (val >> 16) & 0xff;
> > +     *p++ = (val >> 8) & 0xff;
> > +     *p++ = val & 0xff;
> > +}
> > +
> > +static inline void put_unaligned_be56(const u64 val, void *p)
> > +{
> > +     __put_unaligned_be56(val, p);
> > +}
> > +
> > +static inline u64 __get_unaligned_be56(const u8 *p)
> > +{
> > +     return (u64)p[0] << 48 | (u64)p[1] << 40 | (u64)p[2] << 32 |
> > +             (u64)p[3] << 24 | p[4] << 16 | p[5] << 8 | p[6];
> > +}
> > +
> > +static inline u64 get_unaligned_be56(const void *p)
> > +{
> > +     return __get_unaligned_be56(p);
> > +}
> > +
> >  #endif /* __ASM_GENERIC_UNALIGNED_H */
> > 
> > base-commit: b82c1d235a30622177ce10dcb94dfd691a49922f
> > --
> > 2.43.0
> > 
> 
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes,
> MK1 1PT, UK
> Registration No: 1397386 (Wales)
> 


  reply	other threads:[~2024-10-07 14:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-27  8:35 [PATCH v1] asm-generic: introduce be56 unaligned accessors marius.cristea
2024-09-29 21:16 ` David Laight
2024-10-07 14:40   ` Marius.Cristea [this message]
2024-10-07 14:44     ` Arnd Bergmann
2024-10-07 14:57       ` Marius.Cristea
2024-10-07 17:08         ` Arnd Bergmann
2024-10-08  9:03         ` David Laight
2024-10-07 15:05       ` David Laight

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=04222aeb7a9c35ec080222168bace72a3788c90a.camel@microchip.com \
    --to=marius.cristea@microchip.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=arnd@arndb.de \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).