All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakob Hauser <jahau@rocketmail.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Linus Walleij <linus.walleij@linaro.org>,
	Hans de Goede <hdegoede@redhat.com>,
	linux-iio <linux-iio@vger.kernel.org>,
	devicetree <devicetree@vger.kernel.org>,
	phone-devel@vger.kernel.org,
	~postmarketos/upstreaming@lists.sr.ht
Subject: Re: [PATCH v2 7/7] iio: magnetometer: yas530: Add YAS537 variant
Date: Wed, 15 Jun 2022 23:51:49 +0200	[thread overview]
Message-ID: <1c2405ac-98bf-f094-a015-76a7badab101@rocketmail.com> (raw)
In-Reply-To: <CAHp75Ve3ydACAQnHR0rgPHEU9kSLYj-t6dU96gxDLPWKfnmP0g@mail.gmail.com>

Hi Andy,

On 13.06.22 17:22, Andy Shevchenko wrote:
>
> Forgot to add that please try to split even more preparatory patches.
> For example, you may convert existing code to stubs / switch-cases /
> etc and in the last patch just add the new case or new function /
> branch.

That's a good idea. I had a closer look. But I can't spot something that
could be beneficial.

The new functions for YAS537 are similar in structure like their
counterparts of YAS530/YAS532. However, in detail they differ too much,
which hinders merging them into each other.

yas537_measure() being different to yas530_532_measure():
 - regmap_write() has an additional bit YAS5XX_MEASURE_CONT
 - regmap_read_poll_timeout() differs in the read location
 - calculating the values t, x, y1 and y2 are different

yas537_get_measure() being different to yas530_532_get_measure():
 - no linearization
 - no temperature compensation
 - different way of calculating x, y, z from x, y1, y2

yas537_get_calibration_data() being different to
yas530.../yas532_get_calibration_data():
 - one regmap_bulk_read() only
 - different way of getting or extracting the calibration data

yas537_power_on()
 - different procedure and registers

The function yas537_dump_calibration() shares a notable part with
yas530_532_dump_calibration() after the changes applied in patchset v2.
Although merging them together would need some "if" or "switch"
statements because YAS537 version 0 needs to be excluded from that
function and YAS537 version 1 would need to be excluded from the first
and last part of that function. I would leave it like it is, it's easier
readable.

Another approach could be to outsource some parts, which are used by all
variants, into separate functions. But again I don't see much beneficial
pars here.

In yas537_measure() and yas530_532_measure() it could be:
 - regmap_bulk_read()

In yas537_get_calibration_data() and
yas530.../yas532_get_calibration_data() it could be:
 - add_device_randomness()

I think that's it. Both are too small for being worth outsourcing into a
separate function.

Kind regards,
Jakob

  reply	other threads:[~2022-06-15 21:51 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1655081082.git.jahau.ref@rocketmail.com>
2022-06-13  1:15 ` [PATCH v2 0/7] Add support for magnetometer Yamaha YAS537 Jakob Hauser
2022-06-13  1:17   ` [PATCH v2 1/7] iio: magnetometer: yas530: Change data type of hard_offsets to signed Jakob Hauser
2022-06-13  1:17   ` [PATCH v2 2/7] iio: magnetometer: yas530: Change range of data in volatile register Jakob Hauser
2022-06-13  1:17   ` [PATCH v2 3/7] iio: magnetometer: yas530: Correct scaling of magnetic axes Jakob Hauser
2022-06-13  1:17   ` [PATCH v2 4/7] iio: magnetometer: yas530: Correct temperature handling Jakob Hauser
2022-06-13 15:01     ` Andy Shevchenko
2022-06-15 21:18       ` Jakob Hauser
2022-06-13  1:17   ` [PATCH v2 5/7] iio: magnetometer: yas530: Change data type of calibration coefficients Jakob Hauser
2022-06-13  1:17   ` [PATCH v2 6/7] iio: magnetometer: yas530: Rename functions and registers Jakob Hauser
2022-06-13  1:17   ` [PATCH v2 7/7] iio: magnetometer: yas530: Add YAS537 variant Jakob Hauser
2022-06-13 15:20     ` Andy Shevchenko
2022-06-13 15:22       ` Andy Shevchenko
2022-06-15 21:51         ` Jakob Hauser [this message]
2022-06-15 21:43       ` Jakob Hauser
2022-06-15 22:00         ` Jakob Hauser
2022-06-18 14:15         ` Jonathan Cameron
2022-06-13 15:23   ` [PATCH v2 0/7] Add support for magnetometer Yamaha YAS537 Andy Shevchenko

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=1c2405ac-98bf-f094-a015-76a7badab101@rocketmail.com \
    --to=jahau@rocketmail.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=hdegoede@redhat.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=phone-devel@vger.kernel.org \
    --cc=~postmarketos/upstreaming@lists.sr.ht \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.