All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakob Hauser <jahau@rocketmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Linus Walleij <linus.walleij@linaro.org>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Hans de Goede <hdegoede@redhat.com>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	phone-devel@vger.kernel.org,
	~postmarketos/upstreaming@lists.sr.ht,
	Jakob Hauser <jahau@rocketmail.com>
Subject: [PATCH v5 08/14] iio: magnetometer: yas530: Apply documentation and style fixes
Date: Mon,  8 Aug 2022 01:06:47 +0200	[thread overview]
Message-ID: <5a00a21e9414ad00117b67064eb585f589abfee1.1659909060.git.jahau@rocketmail.com> (raw)
In-Reply-To: <cover.1659909060.git.jahau@rocketmail.com>

This commit gathers several minor changes.

In the device examples, "Xiaomi" is too generic, specific devices should be
listed here. E.g. Xiaomi Redmi 2 seems to have YAS537 but it's not fully clear
if this applies to all its variants. Samsung Galaxy S7 is often quoted in
conjunction with YAS537.

Removed defines for device IDs of YAS537 and YAS539, they are not needed so far.

Signed-off-by: Jakob Hauser <jahau@rocketmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/iio/magnetometer/yamaha-yas530.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/magnetometer/yamaha-yas530.c b/drivers/iio/magnetometer/yamaha-yas530.c
index 48995176fa39..bf0aa64ac1a2 100644
--- a/drivers/iio/magnetometer/yamaha-yas530.c
+++ b/drivers/iio/magnetometer/yamaha-yas530.c
@@ -10,7 +10,7 @@
  * (YAS534 is a magnetic switch, not handled)
  * YAS535 MS-6C
  * YAS536 MS-3W
- * YAS537 MS-3T (2015 Samsung Galaxy S6, Note 5, Xiaomi)
+ * YAS537 MS-3T (2015 Samsung Galaxy S6, Note 5, Galaxy S7)
  * YAS539 MS-3S (2018 Samsung Galaxy A7 SM-A750FN)
  *
  * Code functions found in the MPU3050 YAS530 and YAS532 drivers
@@ -93,10 +93,6 @@
 #define YAS532_DATA_OVERFLOW		(BIT(YAS532_DATA_BITS) - 1)
 #define YAS532_20DEGREES		390 /* Counts starting at -50 °C */
 
-/* These variant IDs are known from code dumps */
-#define YAS537_DEVICE_ID		0x07 /* YAS537 (MS-3T) */
-#define YAS539_DEVICE_ID		0x08 /* YAS539 (MS-3S) */
-
 /* Turn off device regulators etc after 5 seconds of inactivity */
 #define YAS5XX_AUTOSUSPEND_DELAY_MS	5000
 
@@ -325,7 +321,7 @@ static int yas530_get_measure(struct yas5xx *yas5xx, s32 *to, s32 *xo, s32 *yo,
 {
 	struct yas5xx_calibration *c = &yas5xx->calibration;
 	u16 t_ref, t, x, y1, y2;
-	/* These are "signed x, signed y1 etc */
+	/* These are signed x, signed y1 etc */
 	s32 sx, sy1, sy2, sy, sz;
 	int ret;
 
@@ -666,7 +662,10 @@ static int yas530_get_calibration_data(struct yas5xx *yas5xx)
 		return ret;
 	dev_dbg(yas5xx->dev, "calibration data: %16ph\n", data);
 
+	/* Contribute calibration data to the input pool for kernel entropy */
 	add_device_randomness(data, sizeof(data));
+
+	/* Extract version */
 	yas5xx->version = data[15] & GENMASK(1, 0);
 
 	/* Extract the calibration from the bitfield */
@@ -693,6 +692,7 @@ static int yas530_get_calibration_data(struct yas5xx *yas5xx)
 	c->r[0] = sign_extend32(FIELD_GET(GENMASK(28, 23), val), 5);
 	c->r[1] = sign_extend32(FIELD_GET(GENMASK(20, 15), val), 5);
 	c->r[2] = sign_extend32(FIELD_GET(GENMASK(12, 7), val), 5);
+
 	return 0;
 }
 
@@ -714,12 +714,12 @@ static int yas532_get_calibration_data(struct yas5xx *yas5xx)
 	dev_dbg(yas5xx->dev, "calibration data: %14ph\n", data);
 
 	/* Sanity check, is this all zeroes? */
-	if (memchr_inv(data, 0x00, 13) == NULL) {
-		if (!(data[13] & BIT(7)))
-			dev_warn(yas5xx->dev, "calibration is blank!\n");
-	}
+	if (!memchr_inv(data, 0x00, 13) && !(data[13] & BIT(7)))
+		dev_warn(yas5xx->dev, "calibration is blank!\n");
 
+	/* Contribute calibration data to the input pool for kernel entropy */
 	add_device_randomness(data, sizeof(data));
+
 	/* Only one bit of version info reserved here as far as we know */
 	yas5xx->version = data[13] & BIT(0);
 
@@ -728,6 +728,7 @@ static int yas532_get_calibration_data(struct yas5xx *yas5xx)
 	c->Cy1 = data[1] * 10 - 1280;
 	c->Cy2 = data[2] * 10 - 1280;
 	yas530_extract_calibration(&data[3], c);
+
 	/*
 	 * Extract linearization:
 	 * Linearization layout in the 32 bits at byte 10:
-- 
2.35.1


  parent reply	other threads:[~2022-08-07 23:07 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1659909060.git.jahau.ref@rocketmail.com>
2022-08-07 23:02 ` [PATCH v5 00/14] Add support for magnetometer Yamaha YAS537 Jakob Hauser
2022-08-07 23:02   ` [PATCH v5 01/14] iio: magnetometer: yas530: Change data type of hard_offsets to signed Jakob Hauser
2022-08-07 23:02   ` [PATCH v5 02/14] iio: magnetometer: yas530: Change range of data in volatile register Jakob Hauser
2022-08-07 23:02   ` [PATCH v5 03/14] iio: magnetometer: yas530: Correct scaling of magnetic axes Jakob Hauser
2022-08-07 23:02   ` [PATCH v5 04/14] iio: magnetometer: yas530: Correct temperature handling Jakob Hauser
2022-08-07 23:02   ` [PATCH v5 05/14] iio: magnetometer: yas530: Change data type of calibration coefficients Jakob Hauser
2022-08-07 23:02   ` [PATCH v5 06/14] iio: magnetometer: yas530: Rename functions and registers Jakob Hauser
2022-08-08 11:08     ` Andy Shevchenko
2022-08-09 23:23       ` Jakob Hauser
2022-08-07 23:06   ` [PATCH v5 07/14] iio: magnetometer: yas530: Move printk %*ph parameters out from stack Jakob Hauser
2022-08-08 11:10     ` Andy Shevchenko
2022-08-09 23:24       ` Jakob Hauser
2022-08-07 23:06   ` Jakob Hauser [this message]
2022-08-07 23:06   ` [PATCH v5 09/14] iio: magnetometer: yas530: Introduce "chip_info" structure Jakob Hauser
2022-08-08  5:39     ` kernel test robot
2022-08-08 11:18       ` Andy Shevchenko
2022-08-08 11:18         ` Andy Shevchenko
2022-08-08 11:24         ` Andy Shevchenko
2022-08-08 11:24           ` Andy Shevchenko
2022-08-08 15:59         ` Nathan Chancellor
2022-08-08 15:59           ` Nathan Chancellor
2022-08-08 18:04           ` Andy Shevchenko
2022-08-08 18:04             ` Andy Shevchenko
2022-08-08 19:48             ` Nathan Chancellor
2022-08-08 19:48               ` Nathan Chancellor
2022-08-09 23:26             ` Jakob Hauser
2022-08-09 23:26               ` Jakob Hauser
2022-08-08 11:22     ` Andy Shevchenko
2022-08-09 23:29       ` Jakob Hauser
2022-08-08 11:32     ` Andy Shevchenko
2022-08-09 23:32       ` Jakob Hauser
2022-08-07 23:06   ` [PATCH v5 10/14] iio: magnetometer: yas530: Add volatile registers to "chip_info" Jakob Hauser
2022-08-08 11:33     ` Andy Shevchenko
2022-08-07 23:06   ` [PATCH v5 11/14] iio: magnetometer: yas530: Add IIO scaling " Jakob Hauser
2022-08-08 11:33     ` Andy Shevchenko
2022-08-07 23:06   ` [PATCH v5 12/14] iio: magnetometer: yas530: Add temperature calculation " Jakob Hauser
2022-08-08 11:36     ` Andy Shevchenko
2022-08-09 23:36       ` Jakob Hauser
2022-08-07 23:06   ` [PATCH v5 13/14] iio: magnetometer: yas530: Add function pointers " Jakob Hauser
2022-08-08 11:37     ` Andy Shevchenko
2022-08-09 23:38       ` Jakob Hauser
2022-08-07 23:12   ` [PATCH v5 14/14] iio: magnetometer: yas530: Add YAS537 variant Jakob Hauser
2022-08-08 11:47     ` Andy Shevchenko
2022-08-09 23:41       ` Jakob Hauser
2022-08-12 21:43         ` Linus Walleij
2022-08-12 21:49           ` 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=5a00a21e9414ad00117b67064eb585f589abfee1.1659909060.git.jahau@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.