[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAN8YU5MMtP8M7jTDP2S3EBM-PM1dsxVLEgGyB-3BtY5xUF+JTQ@mail.gmail.com>
Date: Mon, 19 Jul 2021 12:33:16 +0200
From: Andrea Merello <andrea.merello@...il.com>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: Jonathan Cameron <jic23@...nel.org>,
Lars-Peter Clausen <lars@...afoo.de>,
Rob Herring <robh+dt@...nel.org>,
Matt Ranostay <matt.ranostay@...sulko.com>,
linux-kernel <linux-kernel@...r.kernel.org>,
linux-iio <linux-iio@...r.kernel.org>,
Andrea Merello <andrea.merello@....it>
Subject: Re: [PATCH 2/4] iio: imu: add Bosch Sensortec BNO055 core driver
> > > > + for (i = 0; i < 4; i++)
> > > > + vals[i] = (s16)le16_to_cpu(raw_vals[i]);
> > >
> > > Extract this to be a helper like there are for u32 and u64.
> >
> > Could you please point me to those helpers? I don't know what you are
> > referring to.
>
> Read include/linux/byteorder/generic.h to the end.
I realized that implementing an helper like the other ones wouldn't
work in this specific case: I'd say a reasonable helper would take a
ptr to a s16 as its destination argument, but here we are assigning to
a int vector; so our brand new helper would be of no use here.
What I can do is to implement a macroized helper that would have no
issues wrt ptr type; I guess something like this:
#define le16_to_cpu_signed_array(dst, src, len) \
({ \
size_t __i; \
for (__i = 0; __i < len; __i++) \
dst[__i] = (s16)le16_to_cpu(src[__i]); \
})
What's your opinion here? should I go with something like this or do
you prefer to let the open-coded implementation stay in this specific
case?
Powered by blists - more mailing lists