public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver
@ 2026-04-22 11:22 Joshua Crofts
  2026-04-22 11:22 ` [PATCH v3 1/6] iio: magnetometer: ak8975: sort headers alphabetically Joshua Crofts
                   ` (6 more replies)
  0 siblings, 7 replies; 19+ messages in thread
From: Joshua Crofts @ 2026-04-22 11:22 UTC (permalink / raw)
  To: jic23; +Cc: dlechner, nuno.sa, andy, linux-iio, linux-kernel

This series modernizes and cleans up the ak8975 driver, migrating to
more modern kernel APIs and cleaning up legacy code.

Changes include:
 - replacing usleep_range() with fsleep() for optimization
 - migrating to iopoll macros for better device polling
 - removing unused headers and adding new ones
 - checkpatch.pl fixes

v2:
 - PATCH 1: reverted alphabetical header ordering per logical change
   separation
 - PATCH 2: added newline between fsleep() and return
 - PATCH 3: fixed open parenthesis formatting
 - PATCH 4: fixed whitespace issues, added <linux/time.h> for
   USEC_PER_MSEC macro
v3:
 - PATCH 1 & 2: split alphabetical ordering and header removal into two
   separate patches
 - PATCH 4: commit message fix
 - PATCH 5 & 6: split error handling and polling loop replacement into
   two separate patches

Joshua Crofts (6):
  iio: magnetometer: ak8975: sort headers alphabetically
  iio: magnetometer: ak8975: remove unused headers
  iio: magnetometer: ak8975: replace usleep_range() with fsleep()
  iio: magnetometer: ak8975: change 'u8*' to 'u8 *' in cast
  iio: magnetometer: ak8975: fix wrong errno on return
  iio: magnetometer: ak8975: modernize polling loops with iopoll()
    macros

 drivers/iio/magnetometer/ak8975.c | 92 +++++++++++++++----------------
 1 file changed, 45 insertions(+), 47 deletions(-)


base-commit: c65f27cae0deda3316ed49899df4492a3896e38c
-- 
2.47.3


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v3 1/6] iio: magnetometer: ak8975: sort headers alphabetically
  2026-04-22 11:22 [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver Joshua Crofts
@ 2026-04-22 11:22 ` Joshua Crofts
  2026-04-22 11:22 ` [PATCH v3 2/6] iio: magnetometer: ak8975: remove unused headers Joshua Crofts
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 19+ messages in thread
From: Joshua Crofts @ 2026-04-22 11:22 UTC (permalink / raw)
  To: jic23; +Cc: dlechner, nuno.sa, andy, linux-iio, linux-kernel

Sort include headers alphabetically to improve coding style and
readability.

No functional change.

Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
---
 drivers/iio/magnetometer/ak8975.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
index 44782c26698..569cd6fa839 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -7,23 +7,23 @@
  * Copyright (c) 2010, NVIDIA Corporation.
  */
 
-#include <linux/module.h>
-#include <linux/mod_devicetable.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
+#include <linux/bitops.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
-#include <linux/err.h>
+#include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
 #include <linux/mutex.h>
-#include <linux/delay.h>
-#include <linux/bitops.h>
-#include <linux/gpio/consumer.h>
-#include <linux/regulator/consumer.h>
 #include <linux/pm_runtime.h>
+#include <linux/regulator/consumer.h>
+#include <linux/slab.h>
 
+#include <linux/iio/buffer.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
-#include <linux/iio/buffer.h>
 #include <linux/iio/trigger.h>
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 2/6] iio: magnetometer: ak8975: remove unused headers
  2026-04-22 11:22 [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver Joshua Crofts
  2026-04-22 11:22 ` [PATCH v3 1/6] iio: magnetometer: ak8975: sort headers alphabetically Joshua Crofts
@ 2026-04-22 11:22 ` Joshua Crofts
  2026-04-24 17:58   ` Jonathan Cameron
  2026-04-22 11:22 ` [PATCH v3 3/6] iio: magnetometer: ak8975: replace usleep_range() with fsleep() Joshua Crofts
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 19+ messages in thread
From: Joshua Crofts @ 2026-04-22 11:22 UTC (permalink / raw)
  To: jic23; +Cc: dlechner, nuno.sa, andy, linux-iio, linux-kernel

Remove kernel.h proxy header and unused headers (slab.h, iio/sysfs.h,
iio/trigger.h). Add missing headers to ensure atomicity (array_size.h,
dev_printk.h, asm/byteorder.h, irqreturn.h, minmax.h, property.h,
types.h, wait.h).

Audited using the include-what-you-use tool.

Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
---
 drivers/iio/magnetometer/ak8975.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
index 569cd6fa839..2c2ed2063f8 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -7,24 +7,29 @@
  * Copyright (c) 2010, NVIDIA Corporation.
  */
 
+#include <linux/array_size.h>
 #include <linux/bitops.h>
 #include <linux/delay.h>
+#include <linux/dev_printk.h>
 #include <linux/err.h>
 #include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
-#include <linux/kernel.h>
+#include <linux/irqreturn.h>
+#include <linux/minmax.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/pm_runtime.h>
+#include <linux/property.h>
 #include <linux/regulator/consumer.h>
-#include <linux/slab.h>
+#include <linux/types.h>
+#include <linux/wait.h>
+
+#include <asm/byteorder.h>
 
 #include <linux/iio/buffer.h>
 #include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
-#include <linux/iio/trigger.h>
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
 
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 3/6] iio: magnetometer: ak8975: replace usleep_range() with fsleep()
  2026-04-22 11:22 [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver Joshua Crofts
  2026-04-22 11:22 ` [PATCH v3 1/6] iio: magnetometer: ak8975: sort headers alphabetically Joshua Crofts
  2026-04-22 11:22 ` [PATCH v3 2/6] iio: magnetometer: ak8975: remove unused headers Joshua Crofts
@ 2026-04-22 11:22 ` Joshua Crofts
  2026-04-22 11:22 ` [PATCH v3 4/6] iio: magnetometer: ak8975: change 'u8*' to 'u8 *' in cast Joshua Crofts
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 19+ messages in thread
From: Joshua Crofts @ 2026-04-22 11:22 UTC (permalink / raw)
  To: jic23; +Cc: dlechner, nuno.sa, andy, linux-iio, linux-kernel

Replace usleep_range() calls with fsleep(), passing the minimum value
required by the sensor for hardware delays.

fsleep() automatically selects the optimal sleep mechanism, simplifying
driver code and time management.

Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
---
 drivers/iio/magnetometer/ak8975.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
index 2c2ed2063f8..ccd71bfc8e1 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -461,7 +461,8 @@ static int ak8975_power_on(const struct ak8975_data *data)
 	 * and the minimum wait time before mode setting is 100us, in
 	 * total 300us. Add some margin and say minimum 500us here.
 	 */
-	usleep_range(500, 1000);
+	fsleep(500);
+
 	return 0;
 }
 
@@ -551,7 +552,7 @@ static int ak8975_set_mode(struct ak8975_data *data, enum ak_ctrl_mode mode)
 
 	data->cntl_cache = regval;
 	/* After mode change wait at least 100us */
-	usleep_range(100, 500);
+	fsleep(100);
 
 	return 0;
 }
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 4/6] iio: magnetometer: ak8975: change 'u8*' to 'u8 *' in cast
  2026-04-22 11:22 [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver Joshua Crofts
                   ` (2 preceding siblings ...)
  2026-04-22 11:22 ` [PATCH v3 3/6] iio: magnetometer: ak8975: replace usleep_range() with fsleep() Joshua Crofts
@ 2026-04-22 11:22 ` Joshua Crofts
  2026-04-22 11:22 ` [PATCH v3 5/6] iio: magnetometer: ak8975: fix wrong errno on return Joshua Crofts
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 19+ messages in thread
From: Joshua Crofts @ 2026-04-22 11:22 UTC (permalink / raw)
  To: jic23; +Cc: dlechner, nuno.sa, andy, linux-iio, linux-kernel

Change 'u8*' cast to 'u8 *' as the former triggers a checkpatch error.
Also fix the indentation of parameters in
i2c_smbus_read_i2c_block_data_or_emulated() function.

No functional change.

Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
---
 drivers/iio/magnetometer/ak8975.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
index ccd71bfc8e1..bceab47e5af 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -759,9 +759,10 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val)
 	if (ret)
 		goto exit;
 
-	ret = i2c_smbus_read_i2c_block_data_or_emulated(
-			client, def->data_regs[index],
-			sizeof(rval), (u8*)&rval);
+	ret = i2c_smbus_read_i2c_block_data_or_emulated(client,
+							def->data_regs[index],
+							sizeof(rval),
+							(u8 *)&rval);
 	if (ret < 0)
 		goto exit;
 
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 5/6] iio: magnetometer: ak8975: fix wrong errno on return
  2026-04-22 11:22 [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver Joshua Crofts
                   ` (3 preceding siblings ...)
  2026-04-22 11:22 ` [PATCH v3 4/6] iio: magnetometer: ak8975: change 'u8*' to 'u8 *' in cast Joshua Crofts
@ 2026-04-22 11:22 ` Joshua Crofts
  2026-04-22 13:13   ` Andy Shevchenko
  2026-04-22 11:22 ` [PATCH v3 6/6] iio: magnetometer: ak8975: modernize polling loops with iopoll() macros Joshua Crofts
  2026-04-22 13:16 ` [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver Andy Shevchenko
  6 siblings, 1 reply; 19+ messages in thread
From: Joshua Crofts @ 2026-04-22 11:22 UTC (permalink / raw)
  To: jic23; +Cc: dlechner, nuno.sa, andy, linux-iio, linux-kernel, Andy Shevchenko

The driver currently returns -EINVAL on polling timeout instead of
-ETIMEDOUT.

Replace return code for -ETIMEDOUT and remove unnecessary error message
as error is described enough by error code.

Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
---
 drivers/iio/magnetometer/ak8975.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
index bceab47e5af..723c2f64b8e 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -662,10 +662,8 @@ static int wait_conversion_complete_gpio(struct ak8975_data *data)
 			break;
 		timeout_ms -= AK8975_CONVERSION_DONE_POLL_TIME;
 	}
-	if (!timeout_ms) {
-		dev_err(&client->dev, "Conversion timeout happened\n");
-		return -EINVAL;
-	}
+	if (!timeout_ms)
+		return -ETIMEDOUT;
 
 	ret = i2c_smbus_read_byte_data(client, data->def->ctrl_regs[ST1]);
 	if (ret < 0)
@@ -695,10 +693,8 @@ static int wait_conversion_complete_polled(struct ak8975_data *data)
 			break;
 		timeout_ms -= AK8975_CONVERSION_DONE_POLL_TIME;
 	}
-	if (!timeout_ms) {
-		dev_err(&client->dev, "Conversion timeout happened\n");
-		return -EINVAL;
-	}
+	if (!timeout_ms)
+		return -ETIMEDOUT;
 
 	return read_status;
 }
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 6/6] iio: magnetometer: ak8975: modernize polling loops with iopoll() macros
  2026-04-22 11:22 [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver Joshua Crofts
                   ` (4 preceding siblings ...)
  2026-04-22 11:22 ` [PATCH v3 5/6] iio: magnetometer: ak8975: fix wrong errno on return Joshua Crofts
@ 2026-04-22 11:22 ` Joshua Crofts
  2026-04-22 13:16 ` [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver Andy Shevchenko
  6 siblings, 0 replies; 19+ messages in thread
From: Joshua Crofts @ 2026-04-22 11:22 UTC (permalink / raw)
  To: jic23; +Cc: dlechner, nuno.sa, andy, linux-iio, linux-kernel

The driver currently uses while loops and msleep() for polling during
conversion waits.

Replace the custom polling loops with readx_poll_timeout() and
read_poll_timeout() macros from <linux/iopoll.h>. This reduces
boilerplate, standardizes timeout handling and improves overall code
readability, keeping the original timing and error behaviour. Add
<linux/time.h> for USEC_PER_MSEC macro instead of using magic numbers.

Assisted-by: Gemini:3.1-Pro
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
---
 drivers/iio/magnetometer/ak8975.c | 47 ++++++++++++++-----------------
 1 file changed, 21 insertions(+), 26 deletions(-)

diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
index 723c2f64b8e..0724569e766 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -15,6 +15,7 @@
 #include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
+#include <linux/iopoll.h>
 #include <linux/irqreturn.h>
 #include <linux/minmax.h>
 #include <linux/mod_devicetable.h>
@@ -23,6 +24,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/property.h>
 #include <linux/regulator/consumer.h>
+#include <linux/time.h>
 #include <linux/types.h>
 #include <linux/wait.h>
 
@@ -652,18 +654,16 @@ static int ak8975_setup(struct i2c_client *client)
 static int wait_conversion_complete_gpio(struct ak8975_data *data)
 {
 	struct i2c_client *client = data->client;
-	u32 timeout_ms = AK8975_MAX_CONVERSION_TIMEOUT;
 	int ret;
+	int val;
 
 	/* Wait for the conversion to complete. */
-	while (timeout_ms) {
-		msleep(AK8975_CONVERSION_DONE_POLL_TIME);
-		if (gpiod_get_value(data->eoc_gpiod))
-			break;
-		timeout_ms -= AK8975_CONVERSION_DONE_POLL_TIME;
-	}
-	if (!timeout_ms)
-		return -ETIMEDOUT;
+	ret = readx_poll_timeout(gpiod_get_value, data->eoc_gpiod, val,
+				 val != 0,
+				 AK8975_CONVERSION_DONE_POLL_TIME * USEC_PER_MSEC,
+				 AK8975_MAX_CONVERSION_TIMEOUT * USEC_PER_MSEC);
+	if (ret)
+		return ret;
 
 	ret = i2c_smbus_read_byte_data(client, data->def->ctrl_regs[ST1]);
 	if (ret < 0)
@@ -675,28 +675,23 @@ static int wait_conversion_complete_gpio(struct ak8975_data *data)
 static int wait_conversion_complete_polled(struct ak8975_data *data)
 {
 	struct i2c_client *client = data->client;
-	u8 read_status;
-	u32 timeout_ms = AK8975_MAX_CONVERSION_TIMEOUT;
 	int ret;
+	int val;
 
 	/* Wait for the conversion to complete. */
-	while (timeout_ms) {
-		msleep(AK8975_CONVERSION_DONE_POLL_TIME);
-		ret = i2c_smbus_read_byte_data(client,
-					       data->def->ctrl_regs[ST1]);
-		if (ret < 0) {
-			dev_err(&client->dev, "Error in reading ST1\n");
-			return ret;
-		}
-		read_status = ret;
-		if (read_status)
-			break;
-		timeout_ms -= AK8975_CONVERSION_DONE_POLL_TIME;
+	ret = read_poll_timeout(i2c_smbus_read_byte_data, val, val != 0,
+				AK8975_CONVERSION_DONE_POLL_TIME * USEC_PER_MSEC,
+				AK8975_MAX_CONVERSION_TIMEOUT * USEC_PER_MSEC,
+				true,
+				client, data->def->ctrl_regs[ST1]);
+	if (ret)
+		return ret;
+	if (val < 0) {
+		dev_err(&client->dev, "Error in reading ST1\n");
+		return val;
 	}
-	if (!timeout_ms)
-		return -ETIMEDOUT;
 
-	return read_status;
+	return val;
 }
 
 /* Returns 0 if the end of conversion interrupt occurred or -ETIME otherwise */
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 5/6] iio: magnetometer: ak8975: fix wrong errno on return
  2026-04-22 11:22 ` [PATCH v3 5/6] iio: magnetometer: ak8975: fix wrong errno on return Joshua Crofts
@ 2026-04-22 13:13   ` Andy Shevchenko
  2026-04-22 13:27     ` Joshua Crofts
  0 siblings, 1 reply; 19+ messages in thread
From: Andy Shevchenko @ 2026-04-22 13:13 UTC (permalink / raw)
  To: Joshua Crofts; +Cc: jic23, dlechner, nuno.sa, andy, linux-iio, linux-kernel

On Wed, Apr 22, 2026 at 11:22:06AM +0000, Joshua Crofts wrote:
> The driver currently returns -EINVAL on polling timeout instead of
> -ETIMEDOUT.
> 
> Replace return code for -ETIMEDOUT and remove unnecessary error message
> as error is described enough by error code.

The idea is to drop messages because this is well established error code
and we have a POSIX message being associated with that (meaning all libc
implementations should follow). That said, it's not described by the error
code, it can simply be retrieved from libc *based on the error code*.

Can you rephrase that?

...

You also want to align the code in
https://elixir.bootlin.com/linux/v7.0/source/drivers/iio/magnetometer/ak8975.c#L700

The all three wait_conv...*() are called by the same user in a single
if-else-if chain.

There are two definitions:

#define	ETIME		62	/* Timer expired */
#define	ETIMEDOUT	110	/* Connection timed out */

For IO the first one makes no sense.

The driver says

`	/* Wait for the conversion to complete. */

which implies the IO with the device, and "Connection timed out" maybe not
the clearest form of it but better than "Timer expired" which rather misleading.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver
  2026-04-22 11:22 [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver Joshua Crofts
                   ` (5 preceding siblings ...)
  2026-04-22 11:22 ` [PATCH v3 6/6] iio: magnetometer: ak8975: modernize polling loops with iopoll() macros Joshua Crofts
@ 2026-04-22 13:16 ` Andy Shevchenko
  2026-04-22 13:20   ` Joshua Crofts
  2026-04-24  8:23   ` Joshua Crofts
  6 siblings, 2 replies; 19+ messages in thread
From: Andy Shevchenko @ 2026-04-22 13:16 UTC (permalink / raw)
  To: Joshua Crofts; +Cc: jic23, dlechner, nuno.sa, andy, linux-iio, linux-kernel

On Wed, Apr 22, 2026 at 11:22:01AM +0000, Joshua Crofts wrote:
> This series modernizes and cleans up the ak8975 driver, migrating to
> more modern kernel APIs and cleaning up legacy code.
> 
> Changes include:
>  - replacing usleep_range() with fsleep() for optimization
>  - migrating to iopoll macros for better device polling
>  - removing unused headers and adding new ones
>  - checkpatch.pl fixes

5 out of 6 are good, one needs a bit more as it's a new patch in this version.
Also, wait a bit I'll send a couple more that you may incorporate in your
series. Btw, are you familiar with `b4` tool? If not, good time to start
playing with it.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver
  2026-04-22 13:16 ` [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver Andy Shevchenko
@ 2026-04-22 13:20   ` Joshua Crofts
  2026-04-24  8:23   ` Joshua Crofts
  1 sibling, 0 replies; 19+ messages in thread
From: Joshua Crofts @ 2026-04-22 13:20 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: jic23, dlechner, nuno.sa, andy, linux-iio, linux-kernel

On Wed, 22 Apr 2026 at 15:16, Andy Shevchenko
<andriy.shevchenko@intel.com> wrote:
> 5 out of 6 are good, one needs a bit more as it's a new patch in this version.

Considering this is my second patch series, I'll take this as a compliment :)

> Also, wait a bit I'll send a couple more that you may incorporate in your
> series. Btw, are you familiar with `b4` tool? If not, good time to start
> playing with it.

Only a little bit, I only really do 'b4 am' on patches but I'll check
out the manual
a bit more.

-- 
Kind regards

CJD

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 5/6] iio: magnetometer: ak8975: fix wrong errno on return
  2026-04-22 13:13   ` Andy Shevchenko
@ 2026-04-22 13:27     ` Joshua Crofts
  0 siblings, 0 replies; 19+ messages in thread
From: Joshua Crofts @ 2026-04-22 13:27 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: jic23, dlechner, nuno.sa, andy, linux-iio, linux-kernel

On Wed, 22 Apr 2026 at 15:13, Andy Shevchenko
<andriy.shevchenko@intel.com> wrote:
> The idea is to drop messages because this is well established error code
> and we have a POSIX message being associated with that (meaning all libc
> implementations should follow). That said, it's not described by the error
> code, it can simply be retrieved from libc *based on the error code*.
>
> Can you rephrase that?

Sure, I know that these are just regular errno.h codes, I could've elaborated
a bit more in the commit message.

> You also want to align the code in
> https://elixir.bootlin.com/linux/v7.0/source/drivers/iio/magnetometer/ak8975.c#L700
>
> The all three wait_conv...*() are called by the same user in a single
> if-else-if chain.
>
> There are two definitions:
>
> #define ETIME           62      /* Timer expired */
> #define ETIMEDOUT       110     /* Connection timed out */
>
> For IO the first one makes no sense.

That is odd, it definitely should be -ETIMEDOUT.

> The driver says
>
> `       /* Wait for the conversion to complete. */
>
> which implies the IO with the device, and "Connection timed out" maybe not
> the clearest form of it but better than "Timer expired" which rather misleading.

This driver has more issues than I expected...

-- 
Kind regards

CJD

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver
  2026-04-22 13:16 ` [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver Andy Shevchenko
  2026-04-22 13:20   ` Joshua Crofts
@ 2026-04-24  8:23   ` Joshua Crofts
  2026-04-24 10:18     ` Andy Shevchenko
  1 sibling, 1 reply; 19+ messages in thread
From: Joshua Crofts @ 2026-04-24  8:23 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: jic23, dlechner, nuno.sa, andy, linux-iio, linux-kernel

On Wed, 22 Apr 2026 at 15:16, Andy Shevchenko
<andriy.shevchenko@intel.com> wrote:
> 5 out of 6 are good, one needs a bit more as it's a new patch in this version.
> Also, wait a bit I'll send a couple more that you may incorporate in your
> series. Btw, are you familiar with `b4` tool? If not, good time to start
> playing with it.

Just checking in on this, since I haven't seen any changes on lore.
Btw, b4 really does save *a lot* of time.

-- 
Kind regards

CJD

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver
  2026-04-24  8:23   ` Joshua Crofts
@ 2026-04-24 10:18     ` Andy Shevchenko
  2026-04-24 10:23       ` Joshua Crofts
  0 siblings, 1 reply; 19+ messages in thread
From: Andy Shevchenko @ 2026-04-24 10:18 UTC (permalink / raw)
  To: Joshua Crofts; +Cc: jic23, dlechner, nuno.sa, andy, linux-iio, linux-kernel

On Fri, Apr 24, 2026 at 10:23:31AM +0200, Joshua Crofts wrote:
> On Wed, 22 Apr 2026 at 15:16, Andy Shevchenko
> <andriy.shevchenko@intel.com> wrote:
> > 5 out of 6 are good, one needs a bit more as it's a new patch in this version.
> > Also, wait a bit I'll send a couple more that you may incorporate in your
> > series. Btw, are you familiar with `b4` tool? If not, good time to start
> > playing with it.
> 
> Just checking in on this, since I haven't seen any changes on lore.

Sorry for the delay (if you want to help, start reviewing others' patches in
IIO mailing list, you also learn from that). Now when I got my email pipeline
clean, I am about to start doing what's been promised.

> Btw, b4 really does save *a lot* of time.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver
  2026-04-24 10:18     ` Andy Shevchenko
@ 2026-04-24 10:23       ` Joshua Crofts
  2026-04-24 18:02         ` Jonathan Cameron
  2026-04-27 20:15         ` Andy Shevchenko
  0 siblings, 2 replies; 19+ messages in thread
From: Joshua Crofts @ 2026-04-24 10:23 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: jic23, dlechner, nuno.sa, andy, linux-iio, linux-kernel

On Fri, 24 Apr 2026 at 12:18, Andy Shevchenko
<andriy.shevchenko@intel.com> wrote:
> Sorry for the delay (if you want to help, start reviewing others' patches in
> IIO mailing list, you also learn from that). Now when I got my email pipeline
> clean, I am about to start doing what's been promised.

I wasn't sure that I can just start reviewing, so good to know. No worries about
the delay.

-- 
Kind regards

CJD

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 2/6] iio: magnetometer: ak8975: remove unused headers
  2026-04-22 11:22 ` [PATCH v3 2/6] iio: magnetometer: ak8975: remove unused headers Joshua Crofts
@ 2026-04-24 17:58   ` Jonathan Cameron
  2026-04-24 18:12     ` Joshua Crofts
  0 siblings, 1 reply; 19+ messages in thread
From: Jonathan Cameron @ 2026-04-24 17:58 UTC (permalink / raw)
  To: Joshua Crofts; +Cc: dlechner, nuno.sa, andy, linux-iio, linux-kernel

On Wed, 22 Apr 2026 11:22:03 +0000
Joshua Crofts <joshua.crofts1@gmail.com> wrote:

> Remove kernel.h proxy header and unused headers (slab.h, iio/sysfs.h,
> iio/trigger.h). Add missing headers to ensure atomicity (array_size.h,
> dev_printk.h, asm/byteorder.h, irqreturn.h, minmax.h, property.h,
> types.h, wait.h).
Patch title should not focus on just removing headers. Maybe
"update header to reflect what is actually used"

Otherwise LGTM
> 
> Audited using the include-what-you-use tool.
> 
> Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
> ---
>  drivers/iio/magnetometer/ak8975.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
> index 569cd6fa839..2c2ed2063f8 100644
> --- a/drivers/iio/magnetometer/ak8975.c
> +++ b/drivers/iio/magnetometer/ak8975.c
> @@ -7,24 +7,29 @@
>   * Copyright (c) 2010, NVIDIA Corporation.
>   */
>  
> +#include <linux/array_size.h>
>  #include <linux/bitops.h>
>  #include <linux/delay.h>
> +#include <linux/dev_printk.h>
>  #include <linux/err.h>
>  #include <linux/gpio/consumer.h>
>  #include <linux/i2c.h>
>  #include <linux/interrupt.h>
> -#include <linux/kernel.h>
> +#include <linux/irqreturn.h>
> +#include <linux/minmax.h>
>  #include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/mutex.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/property.h>
>  #include <linux/regulator/consumer.h>
> -#include <linux/slab.h>
> +#include <linux/types.h>
> +#include <linux/wait.h>
> +
> +#include <asm/byteorder.h>
>  
>  #include <linux/iio/buffer.h>
>  #include <linux/iio/iio.h>
> -#include <linux/iio/sysfs.h>
> -#include <linux/iio/trigger.h>
>  #include <linux/iio/trigger_consumer.h>
>  #include <linux/iio/triggered_buffer.h>
>  


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver
  2026-04-24 10:23       ` Joshua Crofts
@ 2026-04-24 18:02         ` Jonathan Cameron
  2026-04-24 18:15           ` Joshua Crofts
  2026-04-27 20:15         ` Andy Shevchenko
  1 sibling, 1 reply; 19+ messages in thread
From: Jonathan Cameron @ 2026-04-24 18:02 UTC (permalink / raw)
  To: Joshua Crofts
  Cc: Andy Shevchenko, dlechner, nuno.sa, andy, linux-iio, linux-kernel

On Fri, 24 Apr 2026 12:23:09 +0200
Joshua Crofts <joshua.crofts1@gmail.com> wrote:

> On Fri, 24 Apr 2026 at 12:18, Andy Shevchenko
> <andriy.shevchenko@intel.com> wrote:
> > Sorry for the delay (if you want to help, start reviewing others' patches in
> > IIO mailing list, you also learn from that). Now when I got my email pipeline
> > clean, I am about to start doing what's been promised.  
> 
> I wasn't sure that I can just start reviewing, so good to know. No worries about
> the delay.
> 

FWIW I took a look through and have nothing to add. Looking forward to v4.
How Andy manage to catch up with is backlog is beyond me :)

Jonathan

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 2/6] iio: magnetometer: ak8975: remove unused headers
  2026-04-24 17:58   ` Jonathan Cameron
@ 2026-04-24 18:12     ` Joshua Crofts
  0 siblings, 0 replies; 19+ messages in thread
From: Joshua Crofts @ 2026-04-24 18:12 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: dlechner, nuno.sa, andy, linux-iio, linux-kernel

On Fri, 24 Apr 2026 at 19:58, Jonathan Cameron <jic23@kernel.org> wrote:
> Patch title should not focus on just removing headers. Maybe
> "update header to reflect what is actually used"

Yeah, I realized that it's not fully descriptive of the actual changes.

> Otherwise LGTM

Thanks!

-- 
Kind regards

CJD

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver
  2026-04-24 18:02         ` Jonathan Cameron
@ 2026-04-24 18:15           ` Joshua Crofts
  0 siblings, 0 replies; 19+ messages in thread
From: Joshua Crofts @ 2026-04-24 18:15 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Andy Shevchenko, dlechner, nuno.sa, andy, linux-iio, linux-kernel

On Fri, 24 Apr 2026 at 20:02, Jonathan Cameron <jic23@kernel.org> wrote:
> FWIW I took a look through and have nothing to add. Looking forward to v4.
> How Andy manage to catch up with is backlog is beyond me :)

Sure is impressive judging by the amount of patches that come in daily :)

-- 
Kind regards

CJD

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver
  2026-04-24 10:23       ` Joshua Crofts
  2026-04-24 18:02         ` Jonathan Cameron
@ 2026-04-27 20:15         ` Andy Shevchenko
  1 sibling, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2026-04-27 20:15 UTC (permalink / raw)
  To: Joshua Crofts; +Cc: jic23, dlechner, nuno.sa, andy, linux-iio, linux-kernel

On Fri, Apr 24, 2026 at 12:23:09PM +0200, Joshua Crofts wrote:
> On Fri, 24 Apr 2026 at 12:18, Andy Shevchenko
> <andriy.shevchenko@intel.com> wrote:
> > Sorry for the delay (if you want to help, start reviewing others' patches in
> > IIO mailing list, you also learn from that). Now when I got my email pipeline
> > clean, I am about to start doing what's been promised.
> 
> I wasn't sure that I can just start reviewing, so good to know. No worries about
> the delay.

FWIW, just send what I promised to send, this driver is a rabbit hole...
See 20260427201412.3067235-1-andriy.shevchenko@linux.intel.com.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2026-04-27 20:15 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-22 11:22 [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver Joshua Crofts
2026-04-22 11:22 ` [PATCH v3 1/6] iio: magnetometer: ak8975: sort headers alphabetically Joshua Crofts
2026-04-22 11:22 ` [PATCH v3 2/6] iio: magnetometer: ak8975: remove unused headers Joshua Crofts
2026-04-24 17:58   ` Jonathan Cameron
2026-04-24 18:12     ` Joshua Crofts
2026-04-22 11:22 ` [PATCH v3 3/6] iio: magnetometer: ak8975: replace usleep_range() with fsleep() Joshua Crofts
2026-04-22 11:22 ` [PATCH v3 4/6] iio: magnetometer: ak8975: change 'u8*' to 'u8 *' in cast Joshua Crofts
2026-04-22 11:22 ` [PATCH v3 5/6] iio: magnetometer: ak8975: fix wrong errno on return Joshua Crofts
2026-04-22 13:13   ` Andy Shevchenko
2026-04-22 13:27     ` Joshua Crofts
2026-04-22 11:22 ` [PATCH v3 6/6] iio: magnetometer: ak8975: modernize polling loops with iopoll() macros Joshua Crofts
2026-04-22 13:16 ` [PATCH v3 0/6] iio: magnetometer: ak8975: modernize and cleanup driver Andy Shevchenko
2026-04-22 13:20   ` Joshua Crofts
2026-04-24  8:23   ` Joshua Crofts
2026-04-24 10:18     ` Andy Shevchenko
2026-04-24 10:23       ` Joshua Crofts
2026-04-24 18:02         ` Jonathan Cameron
2026-04-24 18:15           ` Joshua Crofts
2026-04-27 20:15         ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox