From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Gerald Loacker <gerald.loacker@wolfvision.net>,
<linux-iio@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Nikita Yushchenko <nikita.yoush@cogentembedded.com>,
Jakob Hauser <jahau@rocketmail.com>,
Michael Riesch <michael.riesch@wolfvision.net>
Subject: Re: [PATCH v2 2/2] iio: magnetometer: add ti tmag5273 driver
Date: Wed, 23 Nov 2022 17:56:39 +0000 [thread overview]
Message-ID: <20221123175639.00000ede@Huawei.com> (raw)
In-Reply-To: <Y34irZRlkpdqLrll@smile.fi.intel.com>
On Wed, 23 Nov 2022 15:39:57 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> On Wed, Nov 23, 2022 at 10:58:47AM +0100, Gerald Loacker wrote:
> > Am 21.11.2022 um 15:04 schrieb Andy Shevchenko:
> > > On Mon, Nov 21, 2022 at 01:35:42PM +0100, Gerald Loacker wrote:
>
> ...
>
> > >> +static const struct {
> > >> + unsigned int scale_int;
> > >> + unsigned int scale_micro;
> > >
> > > Can we have a separate patch to define this one eventually in the (one of) IIO
> > > generic headers? It's a bit pity that every new driver seems to reinvent the
> > > wheel.
> > >
> > >> +} tmag5273_scale_table[4][2] = {
> > >> + { { 0, 0 }, { 0, 0 } },
> > >> + { { 0, 12200 }, { 0, 24400 } },
> > >> + { { 0, 40600 }, { 0, 81200 } },
> > >> + { { 0, 0 }, { 0, 0 } },
> > >> +};
> > >
> >
> > I'm thinking of defining structs for all similar types of IIO output
> > formats in iio.h like this:
> >
> >
> > struct iio_val_int_plus_micro {
> > int val_int;
> > int val_micro;
> > };
> >
> > struct iio_val_int_plus_nano {
> > int val_int;
> > int val_nano;
> > };
> >
> > struct iio_val_int_plus_micro_db {
> > int val_int;
> > int val_micro_db;
> > };
>
> ...
>
> > struct iio_val_fractional {
> > int dividend;
> > int divisor;
> > };
>
> This one...
>
> > struct iio_val_fractional_log2 {
> > int dividend;
> > int divisor;
> > };
>
> ...and this one repeat struct s32_fract (or u32_fract, whatever suits better).
>
> > Do you agree?
>
> Me, yes, but you need a blessing by maintainers of IIO.
I'm not 100% convinced it matters, particularly as one of the two typical
use paths has to cast them to an int * anyway (as it can take any of the
above, or a 1D array of ints). However, if it makes drivers a little
easier to read then fair enough. I'm not keen to see a brute force
set of patches updating existing drivers that treat them as simple array
of ints though. Fine to convert any drivers with a local equivalent of these
structures defined.
Jonathan
next prev parent reply other threads:[~2022-11-23 17:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-21 12:35 [PATCH v2 0/2] add ti tmag5273 driver Gerald Loacker
2022-11-21 12:35 ` [PATCH v2 1/2] dt-bindings: iio: magnetometer: add ti tmag5273 documentation file Gerald Loacker
2022-11-21 14:08 ` Krzysztof Kozlowski
2022-11-21 12:35 ` [PATCH v2 2/2] iio: magnetometer: add ti tmag5273 driver Gerald Loacker
2022-11-21 14:04 ` Andy Shevchenko
2022-11-21 17:24 ` Gerald Loacker
2022-11-21 18:40 ` Andy Shevchenko
2022-11-21 18:56 ` Andy Shevchenko
2022-11-22 7:39 ` Gerald Loacker
2022-11-23 9:58 ` Gerald Loacker
2022-11-23 13:39 ` Andy Shevchenko
2022-11-23 17:56 ` Jonathan Cameron [this message]
2022-11-23 18:10 ` Jonathan Cameron
2022-11-23 22:30 ` kernel test robot
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=20221123175639.00000ede@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=devicetree@vger.kernel.org \
--cc=gerald.loacker@wolfvision.net \
--cc=jahau@rocketmail.com \
--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=michael.riesch@wolfvision.net \
--cc=nikita.yoush@cogentembedded.com \
--cc=robh+dt@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