From nobody Mon May 4 13:03:49 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C34B38837D; Mon, 4 May 2026 09:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; cv=none; b=aTsHranJa6YlPZczlKOEgYbnB7wbvaZE3gAXC3iSmILqzpoYaYBRIOKYh2JCoCWP1vYjbEDLPnmd77Xngnxl/BC3FXl751LsKdyG93fTjF58S+LExK3pCEUPDDBZ4vCLRIusg5+Vr14rLKUMbIuioXeaJSYe+yiEj77TWEwkZpA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; c=relaxed/simple; bh=XoUSz6+rVgZOj9EzZCIx9qvAwS9jQ+z9/pQSL9KW+tY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sS9KeGsT/MJ8VdfUzq0Za+Kc1y3dQMuRBBUj15BRK1flua9T3d5dAZ6HFCEpmQBqIj8+ETbljUH7d8oG7FUKs3pyTnNUJASGxFURNmoZIHNiiZZ9OcQcDlm3IjO8ok+wXv8Ace/pRM+qLnHjCUTopR9n4UBkOGtKyUWRIo1uqwM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F98sn9F/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="F98sn9F/" Received: by smtp.kernel.org (Postfix) with ESMTPS id A7998C2BCF4; Mon, 4 May 2026 09:48:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777888114; bh=XoUSz6+rVgZOj9EzZCIx9qvAwS9jQ+z9/pQSL9KW+tY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=F98sn9F/e40jd7PLIQotzh1xCFA/URQtWldtrnwuJqlH5TH6s3mizZoocz9U9araK S7kjOOMgLNQCAosyjgZQYSSLe//UF/qzY+iBD5FvSrKVXyNCRDF6YLKAlSlvVoc331 kP787VP1hZ1Xg9NZZZLMLmdegM7wQoorslBELPnUXZGZpPzzgb3g+KIOrUJbwbRNI6 +eFycd9CQoi7SOGd9k2MoC2ybr/PxMn9eu8dui/9qQxKST7rL6uEw331GZa1kJjYN4 4eFDZSrMudBGvyzPVSalm95qouKXgK5r7Votpbt6aEN9Z9Q9XPtoJB96sQUih2XPtu Au8SidyBnxuVA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94634CD3426; Mon, 4 May 2026 09:48:34 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Mon, 04 May 2026 11:48:13 +0200 Subject: [PATCH v4 01/17] iio: magnetometer: ak8975: sort headers alphabetically Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260504-magnetometer-fixes-v4-1-a291c2a7c71a@gmail.com> References: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> In-Reply-To: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Joshua Crofts X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777888111; l=1542; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=ifC04FwraxdTSdGAo9jIXh6jMIMFxT5mVabPgLPFhPM=; b=xhlO6XkIxZ/bzflz1hACjL7XpQ2K8fERgG8KpqGqiHDTpXsU0FiKbfOP1bklHbgiwRj5ZZDBx Ry3VMKRsy2uCogCY/lP1VCHaEtpHPze2IGyRd291m1gRQPhk4W4b10E X-Developer-Key: i=joshua.crofts1@gmail.com; a=ed25519; pk=Xd+UVoRPiiI0K3LHQ2XIcXmO0jvVuFTv9eTx3lgBphI= X-Endpoint-Received: by B4 Relay for joshua.crofts1@gmail.com/20260422 with auth_id=746 X-Original-From: Joshua Crofts Reply-To: joshua.crofts1@gmail.com From: Joshua Crofts Sort include headers alphabetically to improve coding style and readability. No functional change. Signed-off-by: Joshua Crofts --- 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/a= k8975.c index 44782c26698bcac5ebfc62ce3740f361078fd0ce..569cd6fa839aec6ee8758a261d0= e659fc20131c6 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -7,23 +7,23 @@ * Copyright (c) 2010, NVIDIA Corporation. */ =20 -#include -#include -#include -#include +#include +#include +#include +#include #include #include -#include +#include +#include +#include #include -#include -#include -#include -#include #include +#include +#include =20 +#include #include #include -#include #include #include #include --=20 2.47.3 From nobody Mon May 4 13:03:49 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C3F538838B; Mon, 4 May 2026 09:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; cv=none; b=JhnIokUTPGiZHDXpOaM0yqL2Oj5kug/LII23udWZCfVyFvMbGmnEBo/Vr/RZ4KIkYVOjG1P2M+nOVfeixx4hZiDAX2Ywry0p9HJNAHjRtPAHhqL2yu2sKmZGBYT2Yen3QAVlES1vDxJUUbeDEfktmLneDkK21zcKG3J0kU2R8LQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; c=relaxed/simple; bh=IUZnifWjWiVaH9oOBO9Q0EXpmXHpyJvQ2zdlulvn7eM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZIWInyh5lUe1PcyvOzGGBSgmA89o+gDU6SP1VIN07b9yB8lJZYr/qIEfcPUxAy1kzwvu4CJgIEORV/+8/yfWBDl/7kTZq6b4Ynz+ch0siTLQeVlsoSC2Ns2CLJtGA9HGvAD8aDD1VnDNDoDII+z9fp1cRUE4ejy02D3lmsBJyF0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DBYo3nX1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DBYo3nX1" Received: by smtp.kernel.org (Postfix) with ESMTPS id B14C5C2BCB9; Mon, 4 May 2026 09:48:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777888114; bh=IUZnifWjWiVaH9oOBO9Q0EXpmXHpyJvQ2zdlulvn7eM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=DBYo3nX1GSfuaWTiQ2jefdLdsxkp5uCDT9fF6WYWKexLFWyViFbL81Labs9f/Vj4U zD0aUG2Noz4loHQx1pZ2G9ygmCdFMqibs7gd6mlJOj0WrdZDvNyImsUZO4qZewJ5io Wy4JGPy7c0UeqYmFH2/9HTl03cg3VeVR8qN4KZVHkS1RLOwIcy2fskIoJEkByZBRn2 jQcIwsGpLB5XZImJUHautzhSBEytZDxHdYQo1dCgEeD7q3vdtq++JNHtTfhxEbP4W9 5+iR3aoJJn3Q4STrfxfG66Q5DQFyZI7FpZQv9/zGMm0VtNPMDou+JewcP77wV/lG2N YZpX7z4PXCSQw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id A407AFF885A; Mon, 4 May 2026 09:48:34 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Mon, 04 May 2026 11:48:14 +0200 Subject: [PATCH v4 02/17] iio: magnetometer: ak8975: update headers per IWYU principle Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260504-magnetometer-fixes-v4-2-a291c2a7c71a@gmail.com> References: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> In-Reply-To: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Joshua Crofts , Andy Shevchenko X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777888111; l=1776; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=BdAwGxFbW7o2amP8FH9H+4YQxsDM8p5KHZL35H1tc4w=; b=gCXO8QDFJElmD8P9ntRVSiZLMIYN8dNWWacyJf210PxdmVwIlpTOt5TFyWw8chMlsh2RThDb4 0rWRC8dyGPyDT0iEprTHYtWmrh/+xPmkbg8KKB2YFLNm16I0+5+iDrr X-Developer-Key: i=joshua.crofts1@gmail.com; a=ed25519; pk=Xd+UVoRPiiI0K3LHQ2XIcXmO0jvVuFTv9eTx3lgBphI= X-Endpoint-Received: by B4 Relay for joshua.crofts1@gmail.com/20260422 with auth_id=746 X-Original-From: Joshua Crofts Reply-To: joshua.crofts1@gmail.com From: Joshua Crofts 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. Co-developed-by: Andy Shevchenko Signed-off-by: Andy Shevchenko Signed-off-by: Joshua Crofts --- 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/a= k8975.c index 569cd6fa839aec6ee8758a261d0e659fc20131c6..dac0a90c33eebd43f8aeed846c9= cbf5fd1a6ab91 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -7,24 +7,29 @@ * Copyright (c) 2010, NVIDIA Corporation. */ =20 +#include #include #include +#include #include #include #include #include -#include +#include +#include #include #include #include #include +#include #include -#include +#include +#include + +#include =20 #include #include -#include -#include #include #include =20 --=20 2.47.3 From nobody Mon May 4 13:03:49 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C47038838E; Mon, 4 May 2026 09:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; cv=none; b=K550qWnJh2VdJniWlOgUAFmka1rKZo5yo5zpHsGvD/4ER6Vd3lZHa5Uy7DX88i67ZeWRXDyaFNvsV0YyqqbAde+UpShreqGGkZPuXYI6Kq4QQUEY7r2lwrMM/KbeWOtJNRU10xarnLUjbjd4yXT76loM/90daCvVkpZ8fbvPIYE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; c=relaxed/simple; bh=IQqw8dqzN87N3kyvLEEH/hIdLkUDhN+PIO0XcgQOetQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qRiU1qTgSCFAw0rpx4eUhvndnoBNOxg6itrZh/HWhaC7QMTo5E7MsU1QLt+6XEj9V1CpTLVhHLUFC8kwxgt9GSW1X0Lz/dC0Iu9PjYAJ4+le3p0n1JEjz/4JuplRp2cLhL+gWXaXUaqQdufr9JeZzzpm7n3TNQiTPJ6fiWuloGI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VlOqoF2x; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VlOqoF2x" Received: by smtp.kernel.org (Postfix) with ESMTPS id BC52DC2BCF5; Mon, 4 May 2026 09:48:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777888114; bh=IQqw8dqzN87N3kyvLEEH/hIdLkUDhN+PIO0XcgQOetQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=VlOqoF2xHEzghd99DccqGyCKJVlh4eJL0sZxC56EPs5WtXCOKrd4swaJZkL3wmiTN f33MP6kQr62tPA/UBjR0D/DgjF7AOSMfDvU+I7sKDVCEqX4UUaAFw9+TDJGXFmx0+T BxEM9kWpu44Psyns6vrICVXNil2htRfp9sb7cey4KfQJWGzUinqZfvQF/U680Ffh2Y VJYjXePCUYP7e49QxVeOBStpI1a6dKFriGVZB2BsZgikl4ptQqJMG3xdzFCXGuItOq kJ8yK7b5K/SYjSb9JgvGVgIj/q+EWKBf5rooAcW22GlvFM5s/5HEkskdQUQw6D5aYD M8OQw0pZDno6A== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3B16CD3430; Mon, 4 May 2026 09:48:34 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Mon, 04 May 2026 11:48:15 +0200 Subject: [PATCH v4 03/17] iio: magnetometer: ak8975: replace usleep_range() with fsleep() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260504-magnetometer-fixes-v4-3-a291c2a7c71a@gmail.com> References: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> In-Reply-To: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Joshua Crofts X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777888111; l=1188; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=pYNXSLcsScB1UFEjU4yV7Zvmf3IflZ84nydrNj+FmrM=; b=kdSsSuCWY1z/qJqtyJXW2Q6dxOy7BKEipYDgYV/AEIYkLhgB/KS9PsBNQ0WHoG3Wdusn3ra4Z o8vIWwb6VZ1Afn3qXEoiDz7PRAiTaKcLgaEKXWnirZljidtmii020NI X-Developer-Key: i=joshua.crofts1@gmail.com; a=ed25519; pk=Xd+UVoRPiiI0K3LHQ2XIcXmO0jvVuFTv9eTx3lgBphI= X-Endpoint-Received: by B4 Relay for joshua.crofts1@gmail.com/20260422 with auth_id=746 X-Original-From: Joshua Crofts Reply-To: joshua.crofts1@gmail.com From: Joshua Crofts 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 --- 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/a= k8975.c index dac0a90c33eebd43f8aeed846c9cbf5fd1a6ab91..a84a05a1b64280e26c428e9752a= 39380e386c234 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 *da= ta) * 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; } =20 @@ -551,7 +552,7 @@ static int ak8975_set_mode(struct ak8975_data *data, en= um ak_ctrl_mode mode) =20 data->cntl_cache =3D regval; /* After mode change wait at least 100us */ - usleep_range(100, 500); + fsleep(100); =20 return 0; } --=20 2.47.3 From nobody Mon May 4 13:03:49 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE6EF3876BB; Mon, 4 May 2026 09:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; cv=none; b=Uk5bPaoJbWRGpuecMVEvfs6jj4Vvizb+DihDoFz3647hpwoAMZBZ+kMIJUcJuuaCy9kf9BO34ceoMWVeuRLDcB2DjJefLui3FzLjtW5imbPEAFDT3tEQwsivhWSJXAXji5gAzizmWwX5PQo30HHGbYiFEBhD2B8rDuPegMdZAhE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; c=relaxed/simple; bh=LzFzwM1vVt7yzGjBEJMTkXfLayEfGMNdWc3OJe6lpjQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=C42L1bt9BsJBmLBF7MQK/2DgTe5L31UNFuvW7aOYcUHRuPEthlVNVUJCjswj3dIH9tMx8sbW8uWURsOe+9GBVCJvG+trlUyMC2R63kkZyoDCiTJNN2d1K/w5hByJBEPFqblYh3ovxceB3gXJ2yhglMH+f2jTC4KqqQtxNBZ72ms= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aBYiNrqB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aBYiNrqB" Received: by smtp.kernel.org (Postfix) with ESMTPS id C93D4C2BCF7; Mon, 4 May 2026 09:48:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777888114; bh=LzFzwM1vVt7yzGjBEJMTkXfLayEfGMNdWc3OJe6lpjQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=aBYiNrqBF8I1l17ChSV9xehyHFdwreBA3V/NmWOGdYSvh3gD43UyV9bhD2RwFW5ma UFWshKCOcsC8vnQ95R7VwwtFkTDAluKAWe+3/ncQn+GEw3XFUMsbGoSFq/g7ZtA+se qWQ4yFDevcR/TLvat/ejfexR4qDAebKwLVvOFjsFcb5Y6wJnxNHkP6mlJIjq1sQhdQ 0V7YkG2FEqGjQvzDA19XWxxRwADRoblDwrxn6OWaSzwuFaTG3IVTQ1J3a6g9XzmPhJ mEUW223ZZUDYGbLjaojPYuhJNMPn4zYfMoOEtmNhdDUAKcu41q9UQ6oKA1cfRWdUgQ o3Wr2R7ECMOug== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C21C2CD342C; Mon, 4 May 2026 09:48:34 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Mon, 04 May 2026 11:48:16 +0200 Subject: [PATCH v4 04/17] iio: magnetometer: ak8975: change 'u8*' to 'u8 *' in cast Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260504-magnetometer-fixes-v4-4-a291c2a7c71a@gmail.com> References: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> In-Reply-To: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Joshua Crofts X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777888111; l=1056; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=Wdt8KANnDoSFXBcgrJIrMksQrP9sjlwOf4hExOFf40Y=; b=EPobh4fhjT8hpclgEUMCzw2uJj/0oL2VSQEc3oJ+TKckLd5kWE3Lp6PyPUz+p+fcSEqqaknwF Gw6DhgQBfCcBUlVTyOlB0QIZvnZmh02ZQ0G+bzW4cR4BMQWxsRjES6C X-Developer-Key: i=joshua.crofts1@gmail.com; a=ed25519; pk=Xd+UVoRPiiI0K3LHQ2XIcXmO0jvVuFTv9eTx3lgBphI= X-Endpoint-Received: by B4 Relay for joshua.crofts1@gmail.com/20260422 with auth_id=746 X-Original-From: Joshua Crofts Reply-To: joshua.crofts1@gmail.com From: Joshua Crofts 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 --- 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/a= k8975.c index a84a05a1b64280e26c428e9752a39380e386c234..6ca8c24b9fba452b6fed8155957= a8e5fcbc6511c 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; =20 - ret =3D i2c_smbus_read_i2c_block_data_or_emulated( - client, def->data_regs[index], - sizeof(rval), (u8*)&rval); + ret =3D i2c_smbus_read_i2c_block_data_or_emulated(client, + def->data_regs[index], + sizeof(rval), + (u8 *)&rval); if (ret < 0) goto exit; =20 --=20 2.47.3 From nobody Mon May 4 13:03:49 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01020388371; Mon, 4 May 2026 09:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; cv=none; b=Zjh9Vlv8TzWSqrlfg93gTSZjGrTSLlpNF7wVxDI86j57NOban5tpmmxRQkBRpfsHFhWrVgIYZmgPUBJPkhvSII9B5qCg329QmjRbSUu+jNQI/wHCStSEVQn/YI/dWLNLiR6TqpFi9HxIbw7Aj6quEkX5JDIGwUNzRDdVRk/x97c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; c=relaxed/simple; bh=BUDkYNMkYEk61zOz0NxunnO9uxC4YjPK5Byrp01dd7E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RzjsWBbPdZuEKtWDD6Y91smInOTnJBBv8oSvQeN8z1OLaOzB/xFJyYG7uNrWbCgGDNqnk0gX0tgS7oR8b/sNfYMF+qsV8/Bnk4lNpBogMHTStMbRBHKcFV1gs02DyV+fUtoiUO9jmDloqTteA3HfvGhM9joKXX2BX3QMQcBQvno= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sqKMXpA2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sqKMXpA2" Received: by smtp.kernel.org (Postfix) with ESMTPS id D8259C2BCB8; Mon, 4 May 2026 09:48:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777888114; bh=BUDkYNMkYEk61zOz0NxunnO9uxC4YjPK5Byrp01dd7E=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=sqKMXpA2QaiAT5SawApfidJBmdkQSLfcXq9p8m7ttezgN/1pJyOGVxU8PmfYLpzQh QeAdoY4NFpR7W9oir5v4PtCvGQ2+cm5OELp0M2RgEKI7w2VNnwmynqhEdvC1wMEir4 abwKHdYNIub5ugEsvtBOCQaBhOkfjv1ZhOc2T/cqtY8ZxZ5ziDrN8wpkUQXQFHj5mA SK4ANw0m5Cqg4XWbLYpISxoEuKAUuO0GNaBrCxv8mWY1ZJbhMekJSZPiqh+rjydzia 6xb422C1w/1r1/+ZIUyvOPXbP++CFtsNa7jeRQcLOz2HQY+WqIfNRj4A2FiM5F6yKC 0j8qVb/1twT5Q== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id D158FCD3436; Mon, 4 May 2026 09:48:34 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Mon, 04 May 2026 11:48:17 +0200 Subject: [PATCH v4 05/17] iio: magnetometer: ak8975: fix wrong errno on return Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260504-magnetometer-fixes-v4-5-a291c2a7c71a@gmail.com> References: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> In-Reply-To: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Joshua Crofts , Andy Shevchenko X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777888111; l=2202; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=9ktKUq7LUuC30Nz9Y4JUVYutq/hQ0HQt0x6idr2JCxo=; b=MsXORgSWCSqZKGyJVv3GS3nKQXvavEmrU1hMGojhecTzGE/QwyuoYgmDE8/Bhs2PyAbl8sq27 2aMk+sJm+9GDIYpC+1jWDFmNEBNBpUeULIXjlOFahDmEHy6d3WfPAQF X-Developer-Key: i=joshua.crofts1@gmail.com; a=ed25519; pk=Xd+UVoRPiiI0K3LHQ2XIcXmO0jvVuFTv9eTx3lgBphI= X-Endpoint-Received: by B4 Relay for joshua.crofts1@gmail.com/20260422 with auth_id=746 X-Original-From: Joshua Crofts Reply-To: joshua.crofts1@gmail.com From: Joshua Crofts The driver currently returns -EINVAL on polling timeout instead of -ETIMEDOUT. Replace return code for -ETIMEDOUT and remove unnecessary error message as -ETIMEDOUT is a standard POSIX error. Also replace instances of -EINVAL in comments. Suggested-by: Andy Shevchenko Co-developed-by: Andy Shevchenko Signed-off-by: Andy Shevchenko Signed-off-by: Joshua Crofts --- drivers/iio/magnetometer/ak8975.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/a= k8975.c index 6ca8c24b9fba452b6fed8155957a8e5fcbc6511c..57f50c09cca539c3733f516a161= 7375e9134c349 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 -=3D AK8975_CONVERSION_DONE_POLL_TIME; } - if (!timeout_ms) { - dev_err(&client->dev, "Conversion timeout happened\n"); - return -EINVAL; - } + if (!timeout_ms) + return -ETIMEDOUT; =20 ret =3D i2c_smbus_read_byte_data(client, data->def->ctrl_regs[ST1]); if (ret < 0) @@ -695,15 +693,13 @@ static int wait_conversion_complete_polled(struct ak8= 975_data *data) break; timeout_ms -=3D AK8975_CONVERSION_DONE_POLL_TIME; } - if (!timeout_ms) { - dev_err(&client->dev, "Conversion timeout happened\n"); - return -EINVAL; - } + if (!timeout_ms) + return -ETIMEDOUT; =20 return read_status; } =20 -/* Returns 0 if the end of conversion interrupt occurred or -ETIME otherwi= se */ +/* Returns 0 if the end of conversion interrupt occurred or -ETIMEDOUT oth= erwise */ static int wait_conversion_complete_interrupt(struct ak8975_data *data) { int ret; @@ -713,7 +709,7 @@ static int wait_conversion_complete_interrupt(struct ak= 8975_data *data) AK8975_DATA_READY_TIMEOUT); clear_bit(0, &data->flags); =20 - return ret > 0 ? 0 : -ETIME; + return ret > 0 ? 0 : -ETIMEDOUT; } =20 static int ak8975_start_read_axis(struct ak8975_data *data, --=20 2.47.3 From nobody Mon May 4 13:03:49 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E3FD388394; Mon, 4 May 2026 09:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; cv=none; b=FV2KOavnlF4WU5v5bAMxhQbNkMTDh10vl1+v5TBM6lfNEvHb+xwfyklzHTBp04K/5SJwnYPbHpQF3XyUQzoYxdZpFu+67XUIFM11XyoTDVq2MfUmYmaMOahYfpdfb2rjtH2Z9rkvUBOMbqw8qIYzUjSnAL8sEi8XzQbTLZBPNSU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; c=relaxed/simple; bh=AVjY5my06SRMpeceBcFyOk68HKZ9lOshUQpqVpgruJQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=G9CNDJW+tBZYeAWpYOlBbcspF4PToPtaTItruhtLf6yiQE3aJPzZ/7gKmdaI8dTRYstuvci7+vd1TgcDOVCKoJqj8JEnu3uvw8/0osf3bCSeb2h4uReQtar2/lrwu0bceROZa4joIxB51AOqOg78Vxpnhyqblgoah4Tnbi/NS/0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LpRmH1N9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LpRmH1N9" Received: by smtp.kernel.org (Postfix) with ESMTPS id ED45EC2BCFB; Mon, 4 May 2026 09:48:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777888115; bh=AVjY5my06SRMpeceBcFyOk68HKZ9lOshUQpqVpgruJQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=LpRmH1N9AcQuCA8cJ3shI7YMrlqCo86HPmHVRNydj0wMfoup/6Rp5SgDs4HTxg9ca Jv24oPOh8RoE7R+fUqsWpQ5KDQW7l78RBoyu0n4Jg1DyeAxkgaqDBySBKRIOtn1rsc JlXDLMo1gJnr3hQXCTMNr0BRrIGxRoQD3GhoDDh5F2J2wie5zyopg65MwjokVSY9yC N1Y/ecIY1mQS37ta5h3fizT0gGG8VFyYAX3pLmGM7C5QzGzM1AsiX0gCnfxK8Zos+4 iv241nGe5Q+VqtLGsA9U9JeDCeCkJ25b15e57/zoHPT44UDC9oqXuGsd8r3pQl7xrd DaKklz5OX563g== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0737CD3426; Mon, 4 May 2026 09:48:34 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Mon, 04 May 2026 11:48:18 +0200 Subject: [PATCH v4 06/17] iio: magnetometer: ak8975: modernize polling loops with iopoll() macros Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260504-magnetometer-fixes-v4-6-a291c2a7c71a@gmail.com> References: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> In-Reply-To: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Joshua Crofts , Andy Shevchenko X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777888111; l=3362; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=hktgxAMIWkT3d4BfrJ2NbYY6onqoBjLzuppRGAxqibY=; b=gPXY2wRCBytC/D+3F52ieO7TFh8D2zbu4+u1GKvPpk0gCLC4FmzogL4wWZdGp/NVcftqcsgGR yXBcP6GwmDtDOFpGSP1yM9V1/sXshjofBfjnLDCIONGBpxilwosY3Vc X-Developer-Key: i=joshua.crofts1@gmail.com; a=ed25519; pk=Xd+UVoRPiiI0K3LHQ2XIcXmO0jvVuFTv9eTx3lgBphI= X-Endpoint-Received: by B4 Relay for joshua.crofts1@gmail.com/20260422 with auth_id=746 X-Original-From: Joshua Crofts Reply-To: joshua.crofts1@gmail.com From: Joshua Crofts 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 . This reduces boilerplate, standardizes timeout handling and improves overall code readability, keeping the original timing and error behaviour. Add for USEC_PER_MSEC macro instead of using magic numbers. Assisted-by: Gemini:3.1-Pro Co-developed-by: Andy Shevchenko Signed-off-by: Andy Shevchenko Signed-off-by: Joshua Crofts --- drivers/iio/magnetometer/ak8975.c | 45 +++++++++++++++++------------------= ---- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/a= k8975.c index 57f50c09cca539c3733f516a1617375e9134c349..2e750c151435da57926969a63ba= 9fe996d774e7a 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include =20 @@ -652,18 +653,15 @@ static int ak8975_setup(struct i2c_client *client) static int wait_conversion_complete_gpio(struct ak8975_data *data) { struct i2c_client *client =3D data->client; - u32 timeout_ms =3D AK8975_MAX_CONVERSION_TIMEOUT; int ret; + int val; =20 /* 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 -=3D AK8975_CONVERSION_DONE_POLL_TIME; - } - if (!timeout_ms) - return -ETIMEDOUT; + ret =3D readx_poll_timeout(gpiod_get_value, data->eoc_gpiod, val, val != =3D 0, + AK8975_CONVERSION_DONE_POLL_TIME * USEC_PER_MSEC, + AK8975_MAX_CONVERSION_TIMEOUT * USEC_PER_MSEC); + if (ret) + return ret; =20 ret =3D i2c_smbus_read_byte_data(client, data->def->ctrl_regs[ST1]); if (ret < 0) @@ -675,28 +673,23 @@ static int wait_conversion_complete_gpio(struct ak897= 5_data *data) static int wait_conversion_complete_polled(struct ak8975_data *data) { struct i2c_client *client =3D data->client; - u8 read_status; - u32 timeout_ms =3D AK8975_MAX_CONVERSION_TIMEOUT; int ret; + int val; =20 /* Wait for the conversion to complete. */ - while (timeout_ms) { - msleep(AK8975_CONVERSION_DONE_POLL_TIME); - ret =3D 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 =3D ret; - if (read_status) - break; - timeout_ms -=3D AK8975_CONVERSION_DONE_POLL_TIME; + ret =3D read_poll_timeout(i2c_smbus_read_byte_data, val, val !=3D 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; =20 - return read_status; + return val; } =20 /* Returns 0 if the end of conversion interrupt occurred or -ETIMEDOUT oth= erwise */ --=20 2.47.3 From nobody Mon May 4 13:03:49 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23C64388E57; Mon, 4 May 2026 09:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; cv=none; b=Z8SulMnA18DuE4te7O7XTwgeC1bnGqLauFh/Bh1emWOE2GpZ0VPZl33ifs4niNeFCc5DoOL+8a1OWjThOLvzaXv/nhW9iB70pcFMeou00JrIvir4RD4cXMR8GbczibFfQxArLiWNLOwqJ2GScoTcKzrDnvzojHrcCgix7my8aQ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; c=relaxed/simple; bh=BX6L+0VRZLOBzdzNmNxpN3W5QevRtDwGnJi5FHqOvUM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jLMDACBwZm39H+Yw0bwwqucTFJgzVFNO70l8ElmdnaTzbHhMFrCgCizNpMt1RRIWtDVurQQ5yCNzS+aKKDG4MTXHgOwVSbSId3k9nWXRzZ1/fhBYi7qFH/aZMmtoi2cs3GqmiZbV0hwchAmHGyk+K66VMLwIFLHdBXKWbnUa78A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mp5Za5iA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mp5Za5iA" Received: by smtp.kernel.org (Postfix) with ESMTPS id 0481DC2BCFA; Mon, 4 May 2026 09:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777888115; bh=BX6L+0VRZLOBzdzNmNxpN3W5QevRtDwGnJi5FHqOvUM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=mp5Za5iA8XjGQKlqkzMb6YYwF1w2ge0oDFafgc/ZCyBTZea8bmn70tP0JuTLwXk6b Z2x5qR8CdkDjaqoQC7sflDbcUuJgVzN5DDdFm/ybnw0v63dt0nVNfyOsWLo55mIHgh 73tcf58kgkHyIU5Y5bu0gttlk6q1JQzzUF50GqBBqe4EMHFLGu6gNMSf/YNnAZwiz6 cNumpmE673Mf1ZzxTHnglPzelAawae0C1wQbnZcnVXZRizZLvdU1nZ/0UCUB7FPFgo S8za1hS0dqVAi8KTiHOcfjSIVeFFK897Yg1YyAH/HdWgIV60gXzh1QW4U+h5fX+M1l RT0IxN+qYUt7g== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFC82CD342C; Mon, 4 May 2026 09:48:34 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Mon, 04 May 2026 11:48:19 +0200 Subject: [PATCH v4 07/17] iio: magnetometer: ak8975: pass conversion timeouts as arguments Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260504-magnetometer-fixes-v4-7-a291c2a7c71a@gmail.com> References: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> In-Reply-To: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Joshua Crofts , Andy Shevchenko X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777888112; l=4645; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=qxnQu7Xgy4STwvS3w094dryNwTltudyh3dCYho4PdDQ=; b=/ITAHBk2iqVJ1j2YhGo5XfEYvqa0Snbo6i6QIek/THQx6xg6j/4rcNGm0qfuSTN1Ze4BzUUD1 ZoC9Lq6QQpaAxiFaRnRquTCkyyBdQ6W4TIgsNVOVCWU6vpoP0zJAq3N X-Developer-Key: i=joshua.crofts1@gmail.com; a=ed25519; pk=Xd+UVoRPiiI0K3LHQ2XIcXmO0jvVuFTv9eTx3lgBphI= X-Endpoint-Received: by B4 Relay for joshua.crofts1@gmail.com/20260422 with auth_id=746 X-Original-From: Joshua Crofts Reply-To: joshua.crofts1@gmail.com From: Andy Shevchenko Since we have switched to using macros from iopoll.h it's better to use poll and timeout values supplied as parameters to the helper functions. Also added local variables for poll and timeout values to prevent magic number use. Besides that, fix the home grown and obviously wrong in some cases the jiffy-based timeout. Signed-off-by: Andy Shevchenko Co-developed-by: Joshua Crofts Signed-off-by: Joshua Crofts --- drivers/iio/magnetometer/ak8975.c | 38 ++++++++++++++++++++---------------= --- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/a= k8975.c index 2e750c151435da57926969a63ba9fe996d774e7a..e399a6508a3e28931ec2efe0792= 4d5f30cebf442 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -133,13 +134,6 @@ =20 #define AK09912_MAX_REGS AK09912_REG_ASAZ =20 -/* - * Miscellaneous values. - */ -#define AK8975_MAX_CONVERSION_TIMEOUT 500 -#define AK8975_CONVERSION_DONE_POLL_TIME 10 -#define AK8975_DATA_READY_TIMEOUT ((100*HZ)/1000) - /* * Precalculate scale factor (in Gauss units) for each axis and * store in the device data. @@ -650,7 +644,8 @@ static int ak8975_setup(struct i2c_client *client) return 0; } =20 -static int wait_conversion_complete_gpio(struct ak8975_data *data) +static int wait_conversion_complete_gpio(struct ak8975_data *data, int pol= l_ms, + int timeout_ms) { struct i2c_client *client =3D data->client; int ret; @@ -658,8 +653,8 @@ static int wait_conversion_complete_gpio(struct ak8975_= data *data) =20 /* Wait for the conversion to complete. */ ret =3D readx_poll_timeout(gpiod_get_value, data->eoc_gpiod, val, val != =3D 0, - AK8975_CONVERSION_DONE_POLL_TIME * USEC_PER_MSEC, - AK8975_MAX_CONVERSION_TIMEOUT * USEC_PER_MSEC); + poll_ms * USEC_PER_MSEC, + timeout_ms * USEC_PER_MSEC); if (ret) return ret; =20 @@ -670,7 +665,8 @@ static int wait_conversion_complete_gpio(struct ak8975_= data *data) return ret; } =20 -static int wait_conversion_complete_polled(struct ak8975_data *data) +static int wait_conversion_complete_polled(struct ak8975_data *data, int p= oll_ms, + int timeout_ms) { struct i2c_client *client =3D data->client; int ret; @@ -678,8 +674,8 @@ static int wait_conversion_complete_polled(struct ak897= 5_data *data) =20 /* Wait for the conversion to complete. */ ret =3D read_poll_timeout(i2c_smbus_read_byte_data, val, val !=3D 0, - AK8975_CONVERSION_DONE_POLL_TIME * USEC_PER_MSEC, - AK8975_MAX_CONVERSION_TIMEOUT * USEC_PER_MSEC, + poll_ms * USEC_PER_MSEC, + timeout_ms * USEC_PER_MSEC, true, client, data->def->ctrl_regs[ST1]); if (ret) @@ -693,13 +689,14 @@ static int wait_conversion_complete_polled(struct ak8= 975_data *data) } =20 /* Returns 0 if the end of conversion interrupt occurred or -ETIMEDOUT oth= erwise */ -static int wait_conversion_complete_interrupt(struct ak8975_data *data) +static int wait_conversion_complete_interrupt(struct ak8975_data *data, + int timeout_ms) { int ret; =20 ret =3D wait_event_timeout(data->data_ready_queue, test_bit(0, &data->flags), - AK8975_DATA_READY_TIMEOUT); + msecs_to_jiffies(timeout_ms)); clear_bit(0, &data->flags); =20 return ret > 0 ? 0 : -ETIMEDOUT; @@ -708,6 +705,11 @@ static int wait_conversion_complete_interrupt(struct a= k8975_data *data) static int ak8975_start_read_axis(struct ak8975_data *data, const struct i2c_client *client) { + int irq_timeout_ms =3D 100; + int timeout_ms =3D 500; + int poll_ms =3D 10; + int ret; + /* Set up the device for taking a sample. */ int ret =3D ak8975_set_mode(data, MODE_ONCE); =20 @@ -718,11 +720,11 @@ static int ak8975_start_read_axis(struct ak8975_data = *data, =20 /* Wait for the conversion to complete. */ if (data->eoc_irq) - ret =3D wait_conversion_complete_interrupt(data); + ret =3D wait_conversion_complete_interrupt(data, irq_timeout_ms); else if (data->eoc_gpiod) - ret =3D wait_conversion_complete_gpio(data); + ret =3D wait_conversion_complete_gpio(data, poll_ms, timeout_ms); else - ret =3D wait_conversion_complete_polled(data); + ret =3D wait_conversion_complete_polled(data, poll_ms, timeout_ms); if (ret < 0) return ret; =20 --=20 2.47.3 From nobody Mon May 4 13:03:49 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EB98388E6D; Mon, 4 May 2026 09:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; cv=none; b=mcjFlqZLhpkgrHptqoXuFqjyD4py2M3ArY6Qe2fmTSioItzMguhJIP7pIAqLWIfglRoQu0Yy40eHx6ostenwM316dwUYuwsDY0ufjQiwErthRWmsD4wKJLDA9R67osTqVe9QAvFIN/NwxH23bfVL+V1fz1RrIIZvS0wUcPfvMso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; c=relaxed/simple; bh=quDLPvJ1jqF1IEN0sGM2Xcmta6unSwyehYUHPwzXRFg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TMFaWdUGwpw/F0O1MfbzgsR5qgLVhXqRQDvz1Mu/cQck79U820EhOxKRcC1NOENnQO8rN5IRoOtSdD2jCd3GLH7yLNOAN9W4Q0ivtn/MPOP8el1ugcveUpmBph9t8d027N54sIYDuN130FEtp46Sa+rPzPGmVWc22+XeT3ZqSPE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BNYszEkw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BNYszEkw" Received: by smtp.kernel.org (Postfix) with ESMTPS id 121A5C2BCFD; Mon, 4 May 2026 09:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777888115; bh=quDLPvJ1jqF1IEN0sGM2Xcmta6unSwyehYUHPwzXRFg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=BNYszEkwT0vV++4WZqPrlHb3ErAktpJ3zsvhg9k7LW1zwtwaxThE4TtWKin2Kw6rw BtanbK7pIhg3exL6xZhdKQ8zXjVGxh4llat2dbgEJfw/iJnL4SvsWqhesLPiSa9Rvl rcYechXmImNK5SzxK9HIbtU+OoOPd0YST9jdrlW0cQx1xr6a64aax52GbLzC1GUknd D7+lOEGZGW59jhtWl9npAmRIXUGrotSUnErtMfgB7AV5sWB2O5Mhtbjrr/hfhpncDt rY4K9fcM7RxmX/nRw7Q4/vEgt4syd6/V6OPW20d/Zoj25iq/GmfHlpqQzPWR/rxbos FlKDnVQDkWy2Q== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BD71CD3430; Mon, 4 May 2026 09:48:35 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Mon, 04 May 2026 11:48:20 +0200 Subject: [PATCH v4 08/17] iio: magnetometer: ak8975: avoid using temporary variable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260504-magnetometer-fixes-v4-8-a291c2a7c71a@gmail.com> References: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> In-Reply-To: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Joshua Crofts , Andy Shevchenko X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777888112; l=1365; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=DJjDCl9JnP2nB2THH5DHs78YGFDKy3vPdtw59miyMxw=; b=4HuQSJ58ATnlexHcyGIojYi2gWz8oe9LlrfwqQAt5SsEWh81yrPSEQmZGp+CI7uGe23BPng2q DBXxdbBYblIB0p97Vybyf1Z5sqviZu2IcqI7hLGxkX2mZCv3z2VanPs X-Developer-Key: i=joshua.crofts1@gmail.com; a=ed25519; pk=Xd+UVoRPiiI0K3LHQ2XIcXmO0jvVuFTv9eTx3lgBphI= X-Endpoint-Received: by B4 Relay for joshua.crofts1@gmail.com/20260422 with auth_id=746 X-Original-From: Joshua Crofts Reply-To: joshua.crofts1@gmail.com From: Andy Shevchenko Avoid using temporary variable in ak8975_read_axis(). With that being done, the clamp_t() call becomes idiomatic in the driver and can be factored out to a helper later on (and if needed). Signed-off-by: Andy Shevchenko Signed-off-by: Joshua Crofts --- drivers/iio/magnetometer/ak8975.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/a= k8975.c index e399a6508a3e28931ec2efe07924d5f30cebf442..00bee434432f07e8e0bd7fb2b4c= 97cd2995af7a7 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -739,7 +739,6 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, = int index, int *val) const struct i2c_client *client =3D data->client; const struct ak_def *def =3D data->def; __le16 rval; - u16 buff; int ret; =20 pm_runtime_get_sync(&data->client->dev); @@ -776,8 +775,8 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, = int index, int *val) pm_runtime_put_autosuspend(&data->client->dev); =20 /* Swap bytes and convert to valid range. */ - buff =3D le16_to_cpu(rval); - *val =3D clamp_t(s16, buff, -def->range, def->range); + *val =3D clamp_t(s16, le16_to_cpu(rval), -def->range, def->range); + return IIO_VAL_INT; =20 exit: --=20 2.47.3 From nobody Mon May 4 13:03:49 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40D9938947E; Mon, 4 May 2026 09:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; cv=none; b=PNF1cjoCTpNe0BvOfvsqdsNVyn7woxWr1fVGcoXGPvpZnj0i6rvDpzs1Mb8tj4auwbcfQc1mJNI5GqAgyj2eGU0iZwbZ/D+laFVLRIAvTU/1iqI7Qmltt9vBI3GIzTzGJjD6kYvgIhbgrtpPdBL3XrtJ0ib77Yy+zaybsJp7shY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; c=relaxed/simple; bh=lyuOXTCmxft3eK+xg8TLAw16AK1VgQDtQvcn1KArv9c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NpwU+hain1pCDZq4EAd0SjltMVqQ70DvyIkZhBGfsaCLF6qsA8vQi/n7br4ss4IMbiWL+Y6o6UBEIJr1oF6BqD7VHIc6yD+wGra09au3UzpHIFUWDBwgg6crmzD2o7vl1b4HXQKnAx9+Tw+3wSLjfzLV5rLcfymTW4ikns+nPOM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M2t4XQNV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M2t4XQNV" Received: by smtp.kernel.org (Postfix) with ESMTPS id 25496C32781; Mon, 4 May 2026 09:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777888115; bh=lyuOXTCmxft3eK+xg8TLAw16AK1VgQDtQvcn1KArv9c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=M2t4XQNVliQxsrNCp31w7xNSKir/XqGJRt306adT+tVYNg3yPYxpEFWm1b4hp4Hcd N2ic0ZLU5TyCtVXcn5jdkOyvs3ZQQGZ/6mDwo3ZdYHuRg4fH9KUh7DsaxM024jOEMA SzpBfxd/nduBtw89BKljVL2hk2IJ3UD7BRqHabjHnN0wuErw003J/2jBOF/XfVDgn+ lQOoJVt3zVMh2C0Jnsjf4fSyT3lwlLC88UeQW5ZMUbsLFH2ZdvZ8Jjhxk5A+Zy13ak cnOZfP+jJNnMZHrTfAuHR+ZE+bxWRkVgD1h6d83Wt2ahA6jnHjLUh7qa9BM4y0f90V C6h/Zi9H08DLQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C3C1CD3436; Mon, 4 May 2026 09:48:35 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Mon, 04 May 2026 11:48:21 +0200 Subject: [PATCH v4 09/17] iio: magnetometer: ak8975: drop duplicate NULL check Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260504-magnetometer-fixes-v4-9-a291c2a7c71a@gmail.com> References: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> In-Reply-To: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Joshua Crofts , Andy Shevchenko X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777888112; l=997; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=e2CslTguZFmECHppHhG6NXJjVTcak+Q+ZmfU6/H6/tw=; b=wVYp6pg8pGZRPku/IJeaLIlVYeKFKmI5Eb+i2xowE+v/WJpsssvOKlwPcmiLV8TIR2yVjbGOL WTuSECFwctHBrG+dqQrfPa4m3qi0evCA8t+eCRL2hVznoM8j5IL6mTE X-Developer-Key: i=joshua.crofts1@gmail.com; a=ed25519; pk=Xd+UVoRPiiI0K3LHQ2XIcXmO0jvVuFTv9eTx3lgBphI= X-Endpoint-Received: by B4 Relay for joshua.crofts1@gmail.com/20260422 with auth_id=746 X-Original-From: Joshua Crofts Reply-To: joshua.crofts1@gmail.com From: Andy Shevchenko The gpiod_set_consumer_name() is NULL-aware, no need to perform the same check in the caller. Signed-off-by: Andy Shevchenko Signed-off-by: Joshua Crofts --- drivers/iio/magnetometer/ak8975.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/a= k8975.c index 00bee434432f07e8e0bd7fb2b4c97cd2995af7a7..b94b0486421873a4afa41949d95= 6e0bb5dafdb9d 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -916,8 +916,7 @@ static int ak8975_probe(struct i2c_client *client) eoc_gpiod =3D devm_gpiod_get_optional(&client->dev, NULL, GPIOD_IN); if (IS_ERR(eoc_gpiod)) return PTR_ERR(eoc_gpiod); - if (eoc_gpiod) - gpiod_set_consumer_name(eoc_gpiod, "ak_8975"); + gpiod_set_consumer_name(eoc_gpiod, "ak_8975"); =20 /* * According to AK09911 datasheet, if reset GPIO is provided then --=20 2.47.3 From nobody Mon May 4 13:03:49 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D39C38A72A; Mon, 4 May 2026 09:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; cv=none; b=MRm9d22Ls7VN65HMvvDNGoFB04K28Dnk0XVVoAZg8MhVx+w79S9//EMlfmiENvXrIer4eNpvBBPf2b6zPjV7PfP7WxIEV3SInJE5Vj/clyE7KLmIy0jKqykmui3kNme0jRCIGJ7Vufax4ohGZc5SudXmb801vOBrVmikgHxP1S8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; c=relaxed/simple; bh=My+1MqHY4H8Xr3R5BtJ1NtdFqxcnBifL4UHTNFv6AUQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ePjU7KFhbBabnw72JNfjil97znh8cEDDT86Bt6VnTYMWWPlB9HkdkWgLy6PhAVd6jcAEntHV7O1yE/JvlZpcxPLiQUc7lTSac1rjuoXU4PMWfXu//08YsSBJFuTkoqHxLsqPROwpRiCN7sSlnma77fRK1wVRPZNs42/miNSmOhg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BimbLoUe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BimbLoUe" Received: by smtp.kernel.org (Postfix) with ESMTPS id 31749C2BCB9; Mon, 4 May 2026 09:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777888115; bh=My+1MqHY4H8Xr3R5BtJ1NtdFqxcnBifL4UHTNFv6AUQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=BimbLoUesf9d1TxblymmLmT4gwGfDU2qEE9LCfXPXG2iKXT082i7sISSAK9yY1Wg6 HXm4QQxv/F49M1ped2RGfs/H4nm7/VoO3s5L9g9Z9rCvegytiK7XJIJFum65YiONEY CjK32dp1h+mRwO/CJTlLo4tI0b8QvJ48VYSZCG4IfUcqeBO6fNK9bDRz0yIuj2czA3 o3ARMQq2sR3CKXqOqx4RQbJtRWwc+kbg4y7POpRPFDk0yRmsAUKFE03D5opK7b9Wd4 QpECoohDR8Zxr6xPXdItwo3HEpRBCJtw8ovbJJSS02l1y19Bo3XO45YtMLjw0x9/iG UXc0LkWYL6veg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2ADA4CD342C; Mon, 4 May 2026 09:48:35 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Mon, 04 May 2026 11:48:22 +0200 Subject: [PATCH v4 10/17] iio: magnetometer: ak8975: remove duplicate error message Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260504-magnetometer-fixes-v4-10-a291c2a7c71a@gmail.com> References: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> In-Reply-To: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Joshua Crofts , Andy Shevchenko X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777888112; l=1086; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=z9DRykPnGYvT6CD8nI23X4tG9TQg6CGBxpeXGPGfMa8=; b=YpFqTWYwylZsbWv8RaO4XMob29BCL15Oaz2iPgryOjSeEJOxIsvDE8rQ1DWuKR7OGoX+x9X6l QPpysEFvFvDChS9n8T66IfjQHmw5XH378fkI1WcnQdY1LE334KD4NZY X-Developer-Key: i=joshua.crofts1@gmail.com; a=ed25519; pk=Xd+UVoRPiiI0K3LHQ2XIcXmO0jvVuFTv9eTx3lgBphI= X-Endpoint-Received: by B4 Relay for joshua.crofts1@gmail.com/20260422 with auth_id=746 X-Original-From: Joshua Crofts Reply-To: joshua.crofts1@gmail.com From: Andy Shevchenko The devm_request_irq() already prints an error message. Remove the duplicate. Signed-off-by: Andy Shevchenko Signed-off-by: Joshua Crofts --- drivers/iio/magnetometer/ak8975.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/a= k8975.c index b94b0486421873a4afa41949d956e0bb5dafdb9d..c354ebaba11c86c24ebe2dbc2b2= 0c11f18015151 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -584,17 +584,14 @@ static int ak8975_setup_irq(struct ak8975_data *data) rc =3D devm_request_irq(&client->dev, irq, ak8975_irq_handler, IRQF_TRIGGER_RISING, dev_name(&client->dev), data); - if (rc < 0) { - dev_err(&client->dev, "irq %d request failed: %d\n", irq, rc); + if (rc < 0) return rc; - } =20 data->eoc_irq =3D irq; =20 return rc; } =20 - /* * Perform some start-of-day setup, including reading the asa calibration * values and caching them. --=20 2.47.3 From nobody Mon May 4 13:03:49 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F60038B143; Mon, 4 May 2026 09:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; cv=none; b=YgDr8Ld254jYhh6zifLmNb2rjeWFRJPDl8p0iSctA6U+D48zukIHtkVCe/B8uf1ydyBTywdjDwZZzP79frSZvz1mDvfMGgg7bP2iJIXVSoIKL9I1da+F4LD5tiXuTDY1XtjDNU4j1N2UmafuuKaBGD6l0fKrr2M0K+TQyN72bQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; c=relaxed/simple; bh=L2RFxzFqcmR6ZbffbpXe0Lrf2wSpdAmicH5pR+ybaCU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Yit+97TFP2T/66OXWgLR0jMc6wa4xeVQhpYK8bAKM2qxlpcbRQ4doWlIuOiCD31Udtun74cGwOQy1Xgs842oLpc/BXNyK6KRc6XzVbEOoszoekP5PZdzBK+YzRK0i9OphC/CJ39LzMUKkySlPJTsXZDM9cU1rvuwcmSkNeecszo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vB4Wm5Fa; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vB4Wm5Fa" Received: by smtp.kernel.org (Postfix) with ESMTPS id 425CFC2BCF7; Mon, 4 May 2026 09:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777888115; bh=L2RFxzFqcmR6ZbffbpXe0Lrf2wSpdAmicH5pR+ybaCU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=vB4Wm5FaIztozeI2HqhCO06cgx/bEsckMlb2CSRxH7lCKuryuXOQJd0j7O4r3mMjO jacnJNl9HjJ/gpa/aCxOkfwc7lhYlt4quW7JWGQ8OOa3fJFKQxmw0Dh+m5d98DLgEU m8SDkDq54ITZ9TMlEKBMv306T8hLohUDVeZUxSrqEQc+OY3kCSpAlMpBQOj4oE2vFl 4wFaCgq5XEwbnvWQt8CrOzNi3qpX7uDwZRfXfSSS/7P6qlNUGVeGpAWB2+pgFMlxRP Pz023BHYayVq0e+4O7hn0gdo2X6U66hqtKJcb0zExp4OwgsLEMZtHwE16inUG5nCvO /yj6ShvaVB0YQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B1EDCD3430; Mon, 4 May 2026 09:48:35 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Mon, 04 May 2026 11:48:23 +0200 Subject: [PATCH v4 11/17] iio: magnetometer: ak8975: reduce usage of magic lengths of the buffer Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260504-magnetometer-fixes-v4-11-a291c2a7c71a@gmail.com> References: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> In-Reply-To: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Joshua Crofts , Andy Shevchenko X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777888112; l=1861; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=rDrOq3pd2pOssWC4w5NSLBzhEZL5wqsAhnMlBUMsUAw=; b=xpEilhhQQBS1oFvUyZvqUyZ2+4m3gSD+asCKlCr5c66+t7A4uji+HUVwJzDsP1qBlMfPe80w2 yNWRrHkfCXjCIwU14d3WRWK048+Vx/usnyzngqWI5ObB7AQY+p/lKI8 X-Developer-Key: i=joshua.crofts1@gmail.com; a=ed25519; pk=Xd+UVoRPiiI0K3LHQ2XIcXmO0jvVuFTv9eTx3lgBphI= X-Endpoint-Received: by B4 Relay for joshua.crofts1@gmail.com/20260422 with auth_id=746 X-Original-From: Joshua Crofts Reply-To: joshua.crofts1@gmail.com From: Andy Shevchenko Reduce usage of magic lengths of the supplied buffer by replacing them with the corresponding sizeof():s. Signed-off-by: Andy Shevchenko Signed-off-by: Joshua Crofts --- drivers/iio/magnetometer/ak8975.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/a= k8975.c index c354ebaba11c86c24ebe2dbc2b20c11f18015151..5f3e8fadf68e1806841a9561fe6= aacded08c85ac 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -490,8 +490,10 @@ static int ak8975_who_i_am(struct i2c_client *client, * AK8975 | DEVICE_ID | NA * AK8963 | DEVICE_ID | NA */ - ret =3D i2c_smbus_read_i2c_block_data_or_emulated( - client, AK09912_REG_WIA1, 2, wia_val); + ret =3D i2c_smbus_read_i2c_block_data_or_emulated(client, + AK09912_REG_WIA1, + sizeof(wia_val), + wia_val); if (ret < 0) { dev_err(&client->dev, "Error reading WIA\n"); return ret; @@ -610,9 +612,10 @@ static int ak8975_setup(struct i2c_client *client) } =20 /* Get asa data and store in the device data. */ - ret =3D i2c_smbus_read_i2c_block_data_or_emulated( - client, data->def->ctrl_regs[ASA_BASE], - 3, data->asa); + ret =3D i2c_smbus_read_i2c_block_data_or_emulated(client, + data->def->ctrl_regs[ASA_BASE], + sizeof(data->asa), + data->asa); if (ret < 0) { dev_err(&client->dev, "Not able to read asa data\n"); return ret; @@ -863,7 +866,7 @@ static void ak8975_fill_buffer(struct iio_dev *indio_de= v) */ ret =3D i2c_smbus_read_i2c_block_data_or_emulated(client, def->data_regs[0], - 3 * sizeof(fval[0]), + sizeof(fval), (u8 *)fval); if (ret < 0) goto unlock; --=20 2.47.3 From nobody Mon May 4 13:03:49 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7148438B7DA; Mon, 4 May 2026 09:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; cv=none; b=PtjuylKMcs2QU2eLhBOntOTY4CfJG9c5X/wjoN2g9EikXoBNzM0lQeyhJkXIH5hsM/IYTmgd880lHLc2ptWhdnsD7vz6I4PWI3HJqUWWBn0v/zRo4Yfr3hgPaTPGTdirqoJ2LrqM6SZBwwwrIzKMW5KA6P5iSmngv4Bo5m16O2Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; c=relaxed/simple; bh=UnFw9v45kGthdBJ7O4NjM/pbjUux2RBW3WmWhbVkCfE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=V+VtRK43CTvFeatiPZBCp2+untqmJ3CLmtf6nYsyJf68JsyBZjVZa5y48r7/x0Nfu6Flp9htxmipYz4JKXFDyWXIiiqk12CmbTgdC8oYASdK5eBO+nWVBbofAFN52mdlJkKSG181V1HmqEs5eDJJAZiFmakTTwoLgK31loNqdxk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qZUtpyyU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qZUtpyyU" Received: by smtp.kernel.org (Postfix) with ESMTPS id 529BEC2BCF4; Mon, 4 May 2026 09:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777888115; bh=UnFw9v45kGthdBJ7O4NjM/pbjUux2RBW3WmWhbVkCfE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=qZUtpyyUsQ9gGpCIOkSYAxa5IAEII39sD3jQNfF2uN/hKWEcKkLal//Y/Gufz3S+b gGualXHrDXdJFqwhT7fQAj4T7/K6dtJ8uK9DcPdpLz5t7A2WXxmmRVUA+ak5XrrTpm zS3y+lF0FHfJm3Yl4+MYCFOJsxwSZiiKkXIIsJXwAE7JewR2xjIIcjOlkyD34YK8Qy 5tEa4qw+F8gz5fAkKyNhXIOkczzUPcITUiqEboVWah4NGotfoxOiTqiudNz+hEx8R+ 3fxm+YglTsgNueh0kJ/t/4zsXYtRf7vYScjankzUh/jtdxqS5coDJQr3/QLfJRpvo0 2Pquqt9dKBGNA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A7B1FF885A; Mon, 4 May 2026 09:48:35 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Mon, 04 May 2026 11:48:24 +0200 Subject: [PATCH v4 12/17] iio: magnetometer: ak8975: unify return code variable name Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260504-magnetometer-fixes-v4-12-a291c2a7c71a@gmail.com> References: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> In-Reply-To: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Joshua Crofts , Andy Shevchenko X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777888112; l=3874; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=X9iwzqEdmrTAX1cnhe2RRxRV4goKvKzK5U+3+kX4kNo=; b=ptjNCgxm1u+5ArbNIeJM1eO7Fd6+wC2tJEtiBSpbxtSAl1T1Izb+ydlFGkBQLgA1kEcXY2PJa LwHaZSjLPabCYSxeN+ukBGosllR/2/U9HPqZy579hX0JSy+d1wywBKl X-Developer-Key: i=joshua.crofts1@gmail.com; a=ed25519; pk=Xd+UVoRPiiI0K3LHQ2XIcXmO0jvVuFTv9eTx3lgBphI= X-Endpoint-Received: by B4 Relay for joshua.crofts1@gmail.com/20260422 with auth_id=746 X-Original-From: Joshua Crofts Reply-To: joshua.crofts1@gmail.com From: Andy Shevchenko In one case 'rc' is used in the other 'err', the most use 'ret'. Make the latter use the former, id est 'ret'. While at it, drop unneeded ' < 0' checks. Signed-off-by: Andy Shevchenko Signed-off-by: Joshua Crofts --- drivers/iio/magnetometer/ak8975.c | 46 +++++++++++++++++++----------------= ---- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/a= k8975.c index 5f3e8fadf68e1806841a9561fe6aacded08c85ac..44cc3db57c6882b5f8add7943d1= fad594a47ed1a 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -573,8 +573,8 @@ static irqreturn_t ak8975_irq_handler(int irq, void *da= ta) static int ak8975_setup_irq(struct ak8975_data *data) { struct i2c_client *client =3D data->client; - int rc; int irq; + int ret; =20 init_waitqueue_head(&data->data_ready_queue); clear_bit(0, &data->flags); @@ -583,15 +583,15 @@ static int ak8975_setup_irq(struct ak8975_data *data) else irq =3D gpiod_to_irq(data->eoc_gpiod); =20 - rc =3D devm_request_irq(&client->dev, irq, ak8975_irq_handler, - IRQF_TRIGGER_RISING, - dev_name(&client->dev), data); - if (rc < 0) - return rc; + ret =3D devm_request_irq(&client->dev, irq, ak8975_irq_handler, + IRQF_TRIGGER_RISING, + dev_name(&client->dev), data); + if (ret) + return ret; =20 data->eoc_irq =3D irq; =20 - return rc; + return 0; } =20 /* @@ -905,8 +905,8 @@ static int ak8975_probe(struct i2c_client *client) struct iio_dev *indio_dev; struct gpio_desc *eoc_gpiod; struct gpio_desc *reset_gpiod; - int err; const char *name =3D NULL; + int ret; =20 /* * Grab and set up the supplied GPIO. @@ -941,9 +941,9 @@ static int ak8975_probe(struct i2c_client *client) data->reset_gpiod =3D reset_gpiod; data->eoc_irq =3D 0; =20 - err =3D iio_read_mount_matrix(&client->dev, &data->orientation); - if (err) - return err; + ret =3D iio_read_mount_matrix(&client->dev, &data->orientation); + if (ret) + return ret; =20 /* id will be NULL when enumerated via ACPI */ data->def =3D i2c_get_match_data(client); @@ -964,20 +964,20 @@ static int ak8975_probe(struct i2c_client *client) if (IS_ERR(data->vid)) return PTR_ERR(data->vid); =20 - err =3D ak8975_power_on(data); - if (err) - return err; + ret =3D ak8975_power_on(data); + if (ret) + return ret; =20 - err =3D ak8975_who_i_am(client, data->def->type); - if (err < 0) { + ret =3D ak8975_who_i_am(client, data->def->type); + if (ret) { dev_err(&client->dev, "Unexpected device\n"); goto power_off; } dev_dbg(&client->dev, "Asahi compass chip %s\n", name); =20 /* Perform some basic start-of-day setup of the device. */ - err =3D ak8975_setup(client); - if (err < 0) { + ret =3D ak8975_setup(client); + if (ret) { dev_err(&client->dev, "%s initialization fails\n", name); goto power_off; } @@ -990,15 +990,15 @@ static int ak8975_probe(struct i2c_client *client) indio_dev->modes =3D INDIO_DIRECT_MODE; indio_dev->name =3D name; =20 - err =3D iio_triggered_buffer_setup(indio_dev, NULL, ak8975_handle_trigger, + ret =3D iio_triggered_buffer_setup(indio_dev, NULL, ak8975_handle_trigger, NULL); - if (err) { + if (ret) { dev_err(&client->dev, "triggered buffer setup failed\n"); goto power_off; } =20 - err =3D iio_device_register(indio_dev); - if (err) { + ret =3D iio_device_register(indio_dev); + if (ret) { dev_err(&client->dev, "device register failed\n"); goto cleanup_buffer; } @@ -1021,7 +1021,7 @@ static int ak8975_probe(struct i2c_client *client) iio_triggered_buffer_cleanup(indio_dev); power_off: ak8975_power_off(data); - return err; + return ret; } =20 static void ak8975_remove(struct i2c_client *client) --=20 2.47.3 From nobody Mon May 4 13:03:49 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C70638BF8C; Mon, 4 May 2026 09:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; cv=none; b=X+TiWkhA2xoJsL8eIloGvlVJPvhRrW/BFbYd1P5jMbf5TL6HPt9iDNtaLSvextl/liYqKw6OrqY36/X2/ehdPUQBgtd3YaApdmO+e/bSTEV2JbskOoR9BjXMyCtEXGfLG5NSnBXH68QTsyTTd7KaEafjqro21YJIs7vDIghw7BM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; c=relaxed/simple; bh=u0uJyE8kcFirmmMqpP8Uzcn0pgQzEMEnlIg6MBwbbWQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UkX6bvCccYZ8JHu/YQpcEvf2YG+vFLYYGj09nvxhwV4KUnSh77KIYS5lOgFqoawyeRUpKiH8ZXaBrKDyryihOzCwFYX8QJvIKpgoXB4c6fv0Y8NypAJ4E5ryaXMHaxekta0o3oFVK0Ijatq4YZKFCS9gQuqJerdz0csHrzpiMIA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gGYQTEEl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gGYQTEEl" Received: by smtp.kernel.org (Postfix) with ESMTPS id 60F0EC2BCFF; Mon, 4 May 2026 09:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777888115; bh=u0uJyE8kcFirmmMqpP8Uzcn0pgQzEMEnlIg6MBwbbWQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=gGYQTEEliGLxECVpAY7ytDe6Liz9ydFkTwnvstObqN8AU/VyWNLs9d+hFVv2AyfKh LtX8wA9tbMut5tSdre5aimHF1GUPyUz0nikeTsEVyiNim4G6bW4qHHcJG+m3hAeeMa YiP10vuORhY9FsYiDO9/KaCpINmY31xXxbK74lsjlaq3skV/SmphYvQH/8cu73bgQS sJo8AadtreZOpd5hiELfGEnbwNN9RcELNAYF43rmzH58FfSUf59MqoZrlXwjG5WKkG 5SNBDO4gLOaGL73B9AZvmct97FxEOYwtJ3EnYFZhXUelnAUEi03bUCQB7gKNhuD/ET kJTHVBuaz4gzA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59A2BCD3436; Mon, 4 May 2026 09:48:35 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Mon, 04 May 2026 11:48:25 +0200 Subject: [PATCH v4 13/17] iio: magnetometer: ak8975: switch to using managed resources Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260504-magnetometer-fixes-v4-13-a291c2a7c71a@gmail.com> References: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> In-Reply-To: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Joshua Crofts , Andy Shevchenko X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777888112; l=4899; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=6TpM0zCf329yjqO42XoqmwH0Hcl4Oo+PdnJWFfdDbjA=; b=fF001aVZpUwndm3JVHEOJqcC+d6uZrU0gc61SmH8v+XykQK1Y+GlK2ubriwENE6F8MfSEGeNZ vKUGZw1aE+ZBRFk0IbmHtDpUeDkL3fMruLf+cnBbXu1e1KuFCVQWAPs X-Developer-Key: i=joshua.crofts1@gmail.com; a=ed25519; pk=Xd+UVoRPiiI0K3LHQ2XIcXmO0jvVuFTv9eTx3lgBphI= X-Endpoint-Received: by B4 Relay for joshua.crofts1@gmail.com/20260422 with auth_id=746 X-Original-From: Joshua Crofts Reply-To: joshua.crofts1@gmail.com From: Andy Shevchenko Switch the driver to use managed resources (devm_*) which simplifier error handling and allows removing ak8975_remove() method from the driver. Note, on error path we now also set mode to POWER_DOWN state which is fine. Even if the device is in that mode, there is no problem to set that mode again, it should be no-op. Signed-off-by: Andy Shevchenko Co-developed-by: Joshua Crofts Signed-off-by: Joshua Crofts --- drivers/iio/magnetometer/ak8975.c | 77 ++++++++++++++++++++++-------------= ---- 1 file changed, 44 insertions(+), 33 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/a= k8975.c index 44cc3db57c6882b5f8add7943d1fad594a47ed1a..b857f45d0e28b82c9e5be840140= f85ee13b3a14b 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -898,9 +898,27 @@ static irqreturn_t ak8975_handle_trigger(int irq, void= *p) return IRQ_HANDLED; } =20 +static void devm_ak8975_power_off(void *data) +{ + struct ak8975_data *ak =3D data; + struct device *dev =3D &ak->client->dev; + + /* Only power down if currently active */ + if (!pm_runtime_status_suspended(dev)) { + /* + * The device may not be runtime suspended when the driver is + * removed, so we soft-stop the chip before hard-stopping the + * regulators. + */ + ak8975_set_mode(data, POWER_DOWN); + ak8975_power_off(data); + } +} + static int ak8975_probe(struct i2c_client *client) { const struct i2c_device_id *id =3D i2c_client_get_device_id(client); + struct device *dev =3D &client->dev; struct ak8975_data *data; struct iio_dev *indio_dev; struct gpio_desc *eoc_gpiod; @@ -968,10 +986,21 @@ static int ak8975_probe(struct i2c_client *client) if (ret) return ret; =20 + /* + * Set device as active early so pm_runtime_status_suspended() works + * correctly if probe fails before pm_runtime is enabled. Do not attempt + * to move this line lower. + */ + pm_runtime_set_active(dev); + + ret =3D devm_add_action_or_reset(dev, devm_ak8975_power_off, data); + if (ret) + return ret; + ret =3D ak8975_who_i_am(client, data->def->type); if (ret) { dev_err(&client->dev, "Unexpected device\n"); - goto power_off; + return ret; } dev_dbg(&client->dev, "Asahi compass chip %s\n", name); =20 @@ -979,10 +1008,13 @@ static int ak8975_probe(struct i2c_client *client) ret =3D ak8975_setup(client); if (ret) { dev_err(&client->dev, "%s initialization fails\n", name); - goto power_off; + return ret; } =20 - mutex_init(&data->lock); + ret =3D devm_mutex_init(dev, &data->lock); + if (ret) + return ret; + indio_dev->channels =3D ak8975_channels; indio_dev->num_channels =3D ARRAY_SIZE(ak8975_channels); indio_dev->info =3D &ak8975_info; @@ -990,52 +1022,32 @@ static int ak8975_probe(struct i2c_client *client) indio_dev->modes =3D INDIO_DIRECT_MODE; indio_dev->name =3D name; =20 - ret =3D iio_triggered_buffer_setup(indio_dev, NULL, ak8975_handle_trigger, - NULL); + ret =3D devm_iio_triggered_buffer_setup(dev, indio_dev, NULL, + ak8975_handle_trigger, NULL); if (ret) { dev_err(&client->dev, "triggered buffer setup failed\n"); - goto power_off; + return ret; } =20 - ret =3D iio_device_register(indio_dev); + ret =3D devm_iio_device_register(dev, indio_dev); if (ret) { dev_err(&client->dev, "device register failed\n"); - goto cleanup_buffer; + return ret; } =20 /* Enable runtime PM */ - pm_runtime_get_noresume(&client->dev); - pm_runtime_set_active(&client->dev); - pm_runtime_enable(&client->dev); + ret =3D devm_pm_runtime_enable(dev); + if (ret) + return ret; + /* * The device comes online in 500us, so add two orders of magnitude * of delay before autosuspending: 50 ms. */ pm_runtime_set_autosuspend_delay(&client->dev, 50); pm_runtime_use_autosuspend(&client->dev); - pm_runtime_put(&client->dev); =20 return 0; - -cleanup_buffer: - iio_triggered_buffer_cleanup(indio_dev); -power_off: - ak8975_power_off(data); - return ret; -} - -static void ak8975_remove(struct i2c_client *client) -{ - struct iio_dev *indio_dev =3D i2c_get_clientdata(client); - struct ak8975_data *data =3D iio_priv(indio_dev); - - pm_runtime_get_sync(&client->dev); - pm_runtime_put_noidle(&client->dev); - pm_runtime_disable(&client->dev); - iio_device_unregister(indio_dev); - iio_triggered_buffer_cleanup(indio_dev); - ak8975_set_mode(data, POWER_DOWN); - ak8975_power_off(data); } =20 static int ak8975_runtime_suspend(struct device *dev) @@ -1129,7 +1141,6 @@ static struct i2c_driver ak8975_driver =3D { .acpi_match_table =3D ak_acpi_match, }, .probe =3D ak8975_probe, - .remove =3D ak8975_remove, .id_table =3D ak8975_id, }; module_i2c_driver(ak8975_driver); --=20 2.47.3 From nobody Mon May 4 13:03:49 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D49538C2C1; Mon, 4 May 2026 09:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; cv=none; b=mwFGBiGBynGBA28AtwyB5iW4WFOFCLoJ4dkwqZGjAd4H3YYL64N9y0AsoU+qdLGCS2TJZdHnTbAdKCVePlHn1QXjZNHj6jTrygkDQaPKKF3/wjlHYtbxFo6B7LaRkymXznjMpZ8GGlzEdLMkgjf+ASWO4XES5DoQ8Cuwiyv3EKk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; c=relaxed/simple; bh=CzRxCirSvigglYe3sgSHFTfrkTCymawT3CZT6OJhV8c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=o94AMbA39dfxGqs+mrrSyGKrKKr9QxgS4EP/ldsCMLFM6wSMKaeIRbGRS8dbsR7S54R8sgJdA7pclJR+WpGjPW9anTrm6xfo/+c4YYoildnccd196Gd79EKlK3HbLKcxoxoTJZhtOnrzSEDQ9mYfwsA6O1pSXtVs9baf3FEMvuA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LY+JXoIU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LY+JXoIU" Received: by smtp.kernel.org (Postfix) with ESMTPS id 6F4B9C32781; Mon, 4 May 2026 09:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777888115; bh=CzRxCirSvigglYe3sgSHFTfrkTCymawT3CZT6OJhV8c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=LY+JXoIUfuxrj+2/bJ0YTG3JDkF7rNpOXovc9ivAggkeASsFHAedEND0PjrA5GPPS oyqAw0QfwEBVib7A1XR4lwB/Nd0P4z0NU1ULNNYBCCveABwKNs9OkeJ/ZOfeYX6a80 K32STrhvWLx8pti5qEeb83ZFmkl9R4qqIcRF4CVHsH5DSCl1+H3RL9NqxIRoTQ/+1T /pr8KnZWNYFizy5cXbhIiuWtE6+/u4QC5Sts+Ok6LqL59rJ/IAam5fo1euMCS0KH+t /Ro8G9unm1LD1RKiGy367e07onCcQiDEOuawRBvJ+C9K6t7JoWYL3UeeueHB/MN9Dh yHXn6yHKoDqeA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 686B2CD3438; Mon, 4 May 2026 09:48:35 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Mon, 04 May 2026 11:48:26 +0200 Subject: [PATCH v4 14/17] iio: magnetometer: ak8975: consistently use 'data' parameter Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260504-magnetometer-fixes-v4-14-a291c2a7c71a@gmail.com> References: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> In-Reply-To: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Joshua Crofts , Andy Shevchenko X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777888112; l=3406; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=LxVBVHjGbJ5kfuufAZAJrGZpW4vqzoL13ekQ8xspHYU=; b=0NpOKLHisAizi5TSSbK7Gvp0/l7lvE4RjRnljF9CL/ratlV7ZEXANJt1gAB8/DHcC1CoJ1YlJ IefX61bzZJ1Bx1UIsdoHS3F10bldmbGpvl1X2hzfvyGE5Z8Q4sXNMun X-Developer-Key: i=joshua.crofts1@gmail.com; a=ed25519; pk=Xd+UVoRPiiI0K3LHQ2XIcXmO0jvVuFTv9eTx3lgBphI= X-Endpoint-Received: by B4 Relay for joshua.crofts1@gmail.com/20260422 with auth_id=746 X-Original-From: Joshua Crofts Reply-To: joshua.crofts1@gmail.com From: Andy Shevchenko Some of the functions use 'client', some use 'data', and some use both. Refactor the driver to consistently use 'data' in all cases. Signed-off-by: Andy Shevchenko Signed-off-by: Joshua Crofts --- drivers/iio/magnetometer/ak8975.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/a= k8975.c index b857f45d0e28b82c9e5be840140f85ee13b3a14b..6fba20c613aa40b07771fe9d7eb= fc29d8a2a2b7d 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -474,9 +474,10 @@ static void ak8975_power_off(const struct ak8975_data = *data) * Return 0 if the i2c device is the one we expect. * return a negative error number otherwise */ -static int ak8975_who_i_am(struct i2c_client *client, +static int ak8975_who_i_am(const struct ak8975_data *data, enum asahi_compass_chipset type) { + struct i2c_client *client =3D data->client; u8 wia_val[2]; int ret; =20 @@ -598,10 +599,9 @@ static int ak8975_setup_irq(struct ak8975_data *data) * Perform some start-of-day setup, including reading the asa calibration * values and caching them. */ -static int ak8975_setup(struct i2c_client *client) +static int ak8975_setup(struct ak8975_data *data) { - struct iio_dev *indio_dev =3D i2c_get_clientdata(client); - struct ak8975_data *data =3D iio_priv(indio_dev); + struct i2c_client *client =3D data->client; int ret; =20 /* Write the fused rom access mode. */ @@ -702,8 +702,7 @@ static int wait_conversion_complete_interrupt(struct ak= 8975_data *data, return ret > 0 ? 0 : -ETIMEDOUT; } =20 -static int ak8975_start_read_axis(struct ak8975_data *data, - const struct i2c_client *client) +static int ak8975_start_read_axis(struct ak8975_data *data) { int irq_timeout_ms =3D 100; int timeout_ms =3D 500; @@ -711,8 +710,7 @@ static int ak8975_start_read_axis(struct ak8975_data *d= ata, int ret; =20 /* Set up the device for taking a sample. */ - int ret =3D ak8975_set_mode(data, MODE_ONCE); - + ret =3D ak8975_set_mode(data, MODE_ONCE); if (ret < 0) { dev_err(&client->dev, "Error in setting operating mode\n"); return ret; @@ -745,7 +743,7 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, = int index, int *val) =20 mutex_lock(&data->lock); =20 - ret =3D ak8975_start_read_axis(data, client); + ret =3D ak8975_start_read_axis(data); if (ret) goto exit; =20 @@ -856,7 +854,7 @@ static void ak8975_fill_buffer(struct iio_dev *indio_de= v) =20 mutex_lock(&data->lock); =20 - ret =3D ak8975_start_read_axis(data, client); + ret =3D ak8975_start_read_axis(data); if (ret) goto unlock; =20 @@ -997,7 +995,7 @@ static int ak8975_probe(struct i2c_client *client) if (ret) return ret; =20 - ret =3D ak8975_who_i_am(client, data->def->type); + ret =3D ak8975_who_i_am(data, data->def->type); if (ret) { dev_err(&client->dev, "Unexpected device\n"); return ret; @@ -1005,7 +1003,7 @@ static int ak8975_probe(struct i2c_client *client) dev_dbg(&client->dev, "Asahi compass chip %s\n", name); =20 /* Perform some basic start-of-day setup of the device. */ - ret =3D ak8975_setup(client); + ret =3D ak8975_setup(data); if (ret) { dev_err(&client->dev, "%s initialization fails\n", name); return ret; --=20 2.47.3 From nobody Mon May 4 13:03:49 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A44338C2DB; Mon, 4 May 2026 09:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; cv=none; b=XlcV1oqsFECPy+oL+LE7K6p/uZyeE6OREK357he40jWbyEclXXFGxvK/St8DNdKziAYlfkiFQU9phzRoqKtiLbUdYZlxYtFJ/mL0sO36bOTuLgaHlTtZ6kmAhBnl/cRh3bZLXG90dSwxX/i+wCCPvu6jU7PSOlvQmEInD8mKAV0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; c=relaxed/simple; bh=XCHZSzX0B6av20cy7yBlmtD8BkdxfmtbL9aw51ux5E8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FfiJ7jDJnfGierxmAImE2MdjRfxjDUkcziOtprRcStZeXLKq7SA6gvvFbDe9SUbC5kxrQgPsDIqaAmRJmneuJYIuVj18ME+HAa9s+AeAbZ+VeNYhMs1feULg+yAKGLD/Ol+hh8VFUrnFpuXHPPB9ovYkAQ8cq4JfVS8TYe++UKw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=S4n0IGbe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="S4n0IGbe" Received: by smtp.kernel.org (Postfix) with ESMTPS id 7D16CC2BCFD; Mon, 4 May 2026 09:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777888115; bh=XCHZSzX0B6av20cy7yBlmtD8BkdxfmtbL9aw51ux5E8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=S4n0IGbexSsLbfAK5DXgeckuyuBsPXaImPZlj30HSccWy2VitPo9eTCxQN/nJJYkt Y1cTbwMGqiC5S8lAOx3MeKMb3lTzZfnZce6GYnPpwiyKN+8ChcX+gWn/io8+to2BfN CjTkaWFPPZItqadDYMnJ/KmaYlcVVSfZX+I7dAu0vN/2W8Rz6BdRJliiF1hN6qpWdC yPC7gsoHjZyEMb1a+0YkRo2fscxXCwUuKdTd7HvMegN+bPKz9sN7gbt0UM0QcJ1gpo s7teWbDKASoXtdAzzzhSq/R62LeYjV3uKCJBbFNEOvvVQZGOwz8XROiOXHKV4XBi+Y H64N3eOSpo4Rg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76412CD3430; Mon, 4 May 2026 09:48:35 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Mon, 04 May 2026 11:48:27 +0200 Subject: [PATCH v4 15/17] iio: magnetometer: ak8975: unify messages with help of dev_err_probe() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260504-magnetometer-fixes-v4-15-a291c2a7c71a@gmail.com> References: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> In-Reply-To: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Joshua Crofts , Andy Shevchenko X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777888112; l=2364; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=D4aD3QXa789hKTdTDhB5MScOEW0jAsWOxyrjZ2UQS+w=; b=6N32LwsLjmDxnBC/w/lu8/5k/WIOAk53PKhxC5V0K8jdlijmx6SPIWDCkEmu/fqFrOPMMV5X9 vsr78MZxfiiBDjY7KahVXpajsm0pQTrMVrIEZPVLdKb7TCFLxbItMhV X-Developer-Key: i=joshua.crofts1@gmail.com; a=ed25519; pk=Xd+UVoRPiiI0K3LHQ2XIcXmO0jvVuFTv9eTx3lgBphI= X-Endpoint-Received: by B4 Relay for joshua.crofts1@gmail.com/20260422 with auth_id=746 X-Original-From: Joshua Crofts Reply-To: joshua.crofts1@gmail.com From: Andy Shevchenko Unify error messages that might appear during probe phase by switching to use dev_err_probe(). Signed-off-by: Andy Shevchenko Signed-off-by: Joshua Crofts --- drivers/iio/magnetometer/ak8975.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/a= k8975.c index 6fba20c613aa40b07771fe9d7ebfc29d8a2a2b7d..861a12ba8cfcc3724573b332b3f= 5bc243b67b1de 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -495,10 +495,8 @@ static int ak8975_who_i_am(const struct ak8975_data *d= ata, AK09912_REG_WIA1, sizeof(wia_val), wia_val); - if (ret < 0) { - dev_err(&client->dev, "Error reading WIA\n"); - return ret; - } + if (ret < 0) + return dev_err_probe(&client->dev, ret, "Error reading WIA\n"); =20 if (wia_val[0] !=3D AK8975_DEVICE_ID) return -ENODEV; @@ -996,18 +994,14 @@ static int ak8975_probe(struct i2c_client *client) return ret; =20 ret =3D ak8975_who_i_am(data, data->def->type); - if (ret) { - dev_err(&client->dev, "Unexpected device\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "Unexpected device\n"); dev_dbg(&client->dev, "Asahi compass chip %s\n", name); =20 /* Perform some basic start-of-day setup of the device. */ ret =3D ak8975_setup(data); - if (ret) { - dev_err(&client->dev, "%s initialization fails\n", name); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "%s initialization fails\n", name); =20 ret =3D devm_mutex_init(dev, &data->lock); if (ret) @@ -1022,16 +1016,12 @@ static int ak8975_probe(struct i2c_client *client) =20 ret =3D devm_iio_triggered_buffer_setup(dev, indio_dev, NULL, ak8975_handle_trigger, NULL); - if (ret) { - dev_err(&client->dev, "triggered buffer setup failed\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "triggered buffer setup failed\n"); =20 ret =3D devm_iio_device_register(dev, indio_dev); - if (ret) { - dev_err(&client->dev, "device register failed\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "device register failed\n"); =20 /* Enable runtime PM */ ret =3D devm_pm_runtime_enable(dev); --=20 2.47.3 From nobody Mon May 4 13:03:49 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6E4438C40C; Mon, 4 May 2026 09:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; cv=none; b=j1evEdsTkiYZ5aYE+ju+3HAcUEu6bogJ3jlVyW/oamz323K8vDq2PbblPUjKBkTxxK2reMF646rQ7bnBEAqDkgDF28+2XimZ5ckG7PPVhixqahIK8dJPqgehSGTY1h/6qAoPAwVF7B2pc24AANQwsTboM68kppm5eM1zH+GhK8c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; c=relaxed/simple; bh=jJOK4EKOiFnLitV7IrIKbmuIYRNLHhPHtAA4rtRQ9Mo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jvNWneSZQ+kAfXPo3TPdUo1SFda1KPMMGiwyfiStp7ewyQUU+cIJ9n3fjNpoe24xblanjHvPlkH0HI99SDhzDUEEnQtDFomGt6P4gV1IW2d9RexHQLP8HzORxWHi+Fi7W2j9J7DCTljidA+XVuADONyG92vIeL0uc9lQmYA7wk8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FUMjnStd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FUMjnStd" Received: by smtp.kernel.org (Postfix) with ESMTPS id 8BCAFC2BCF6; Mon, 4 May 2026 09:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777888115; bh=jJOK4EKOiFnLitV7IrIKbmuIYRNLHhPHtAA4rtRQ9Mo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=FUMjnStdUT7tIUMqEP0fy0t0EV5YNPU3C7Lu65os7UJlttgDUpS8otP4JIwHACmb/ h1ZJxE6L2oNoOLcGwMbyxOiP4YPrcioeQibp2r8Zx8N+kPZ3yo1FhXpS1Hpm4xjOjf ypo7U34t+1FRMVKmAK5X9zok8po27OQxCOhiJyQo3nBJVvH+36GXPrAZQ3NNEFVKot SJ3Wa/8ClyBJRY+uHkV9pZBzEOEyt9J3p8XAKl7C2MliNuiw7ks+3gt469gdJ8Zc5q 3t6tfISB9/tsJKxtNbEluETTro9EudKfc8cAaSpQ5I/bR4yY8f/fjZl2IWJGCZTs46 PKAg/JttToflg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84E11CD342C; Mon, 4 May 2026 09:48:35 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Mon, 04 May 2026 11:48:28 +0200 Subject: [PATCH v4 16/17] iio: magnetometer: ak8975: use temporary variable for struct device Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260504-magnetometer-fixes-v4-16-a291c2a7c71a@gmail.com> References: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> In-Reply-To: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Joshua Crofts , Andy Shevchenko X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777888112; l=8160; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=ZIjjlK4lqPm5GPnjOqsL9uedRjeeuBQYI6+/jZg3Zf4=; b=yZ5TBht8iOnXt4ibwEfHqovnnvD5F+P4Mv2z3JoVWHDJ8cGCDlDxTGn6UBkkf3vQVLZJtL88j 93ksiT+O+ABAGDx2xEz6+fFz+f3KDnyYN1so5x/EfwbmpmREP2JJlCX X-Developer-Key: i=joshua.crofts1@gmail.com; a=ed25519; pk=Xd+UVoRPiiI0K3LHQ2XIcXmO0jvVuFTv9eTx3lgBphI= X-Endpoint-Received: by B4 Relay for joshua.crofts1@gmail.com/20260422 with auth_id=746 X-Original-From: Joshua Crofts Reply-To: joshua.crofts1@gmail.com From: Andy Shevchenko Use temporary variable for struct device to make code neater. Signed-off-by: Andy Shevchenko Signed-off-by: Joshua Crofts --- drivers/iio/magnetometer/ak8975.c | 61 +++++++++++++++++++----------------= ---- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/a= k8975.c index 861a12ba8cfcc3724573b332b3f5bc243b67b1de..eeaf7cd5e36dc0e09f4bc588edc= eeb66501b8bef 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -433,18 +433,17 @@ struct ak8975_data { /* Enable attached power regulator if any. */ static int ak8975_power_on(const struct ak8975_data *data) { + struct device *dev =3D &data->client->dev; int ret; =20 ret =3D regulator_enable(data->vdd); if (ret) { - dev_warn(&data->client->dev, - "Failed to enable specified Vdd supply\n"); + dev_warn(dev, "Failed to enable specified Vdd supply\n"); return ret; } ret =3D regulator_enable(data->vid); if (ret) { - dev_warn(&data->client->dev, - "Failed to enable specified Vid supply\n"); + dev_warn(dev, "Failed to enable specified Vid supply\n"); regulator_disable(data->vdd); return ret; } @@ -572,6 +571,7 @@ static irqreturn_t ak8975_irq_handler(int irq, void *da= ta) static int ak8975_setup_irq(struct ak8975_data *data) { struct i2c_client *client =3D data->client; + struct device *dev =3D &client->dev; int irq; int ret; =20 @@ -582,9 +582,8 @@ static int ak8975_setup_irq(struct ak8975_data *data) else irq =3D gpiod_to_irq(data->eoc_gpiod); =20 - ret =3D devm_request_irq(&client->dev, irq, ak8975_irq_handler, - IRQF_TRIGGER_RISING, - dev_name(&client->dev), data); + ret =3D devm_request_irq(dev, irq, ak8975_irq_handler, IRQF_TRIGGER_RISIN= G, + dev_name(dev), data); if (ret) return ret; =20 @@ -600,12 +599,13 @@ static int ak8975_setup_irq(struct ak8975_data *data) static int ak8975_setup(struct ak8975_data *data) { struct i2c_client *client =3D data->client; + struct device *dev =3D &client->dev; int ret; =20 /* Write the fused rom access mode. */ ret =3D ak8975_set_mode(data, FUSE_ROM); if (ret < 0) { - dev_err(&client->dev, "Error in setting fuse access mode\n"); + dev_err(dev, "Error in setting fuse access mode\n"); return ret; } =20 @@ -615,22 +615,21 @@ static int ak8975_setup(struct ak8975_data *data) sizeof(data->asa), data->asa); if (ret < 0) { - dev_err(&client->dev, "Not able to read asa data\n"); + dev_err(dev, "Not able to read asa data\n"); return ret; } =20 /* After reading fuse ROM data set power-down mode */ ret =3D ak8975_set_mode(data, POWER_DOWN); if (ret < 0) { - dev_err(&client->dev, "Error in setting power-down mode\n"); + dev_err(dev, "Error in setting power-down mode\n"); return ret; } =20 if (data->eoc_gpiod || client->irq > 0) { ret =3D ak8975_setup_irq(data); if (ret < 0) { - dev_err(&client->dev, - "Error setting data ready interrupt\n"); + dev_err(dev, "Error setting data ready interrupt\n"); return ret; } } @@ -734,10 +733,11 @@ static int ak8975_read_axis(struct iio_dev *indio_dev= , int index, int *val) struct ak8975_data *data =3D iio_priv(indio_dev); const struct i2c_client *client =3D data->client; const struct ak_def *def =3D data->def; + struct device *dev =3D &data->client->dev; __le16 rval; int ret; =20 - pm_runtime_get_sync(&data->client->dev); + pm_runtime_get_sync(dev); =20 mutex_lock(&data->lock); =20 @@ -755,20 +755,20 @@ static int ak8975_read_axis(struct iio_dev *indio_dev= , int index, int *val) /* Read out ST2 for release lock on measurement data. */ ret =3D i2c_smbus_read_byte_data(client, data->def->ctrl_regs[ST2]); if (ret < 0) { - dev_err(&client->dev, "Error in reading ST2\n"); + dev_err(dev, "Error in reading ST2\n"); goto exit; } =20 if (ret & (data->def->ctrl_masks[ST2_DERR] | data->def->ctrl_masks[ST2_HOFL])) { - dev_err(&client->dev, "ST2 status error 0x%x\n", ret); + dev_err(dev, "ST2 status error 0x%x\n", ret); ret =3D -EINVAL; goto exit; } =20 mutex_unlock(&data->lock); =20 - pm_runtime_put_autosuspend(&data->client->dev); + pm_runtime_put_autosuspend(dev); =20 /* Swap bytes and convert to valid range. */ *val =3D clamp_t(s16, le16_to_cpu(rval), -def->range, def->range); @@ -777,7 +777,7 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, = int index, int *val) =20 exit: mutex_unlock(&data->lock); - dev_err(&client->dev, "Error in reading axis\n"); + dev_err(dev, "Error in reading axis\n"); return ret; } =20 @@ -927,7 +927,7 @@ static int ak8975_probe(struct i2c_client *client) * We may not have a GPIO based IRQ to scan, that is fine, we will * poll if so. */ - eoc_gpiod =3D devm_gpiod_get_optional(&client->dev, NULL, GPIOD_IN); + eoc_gpiod =3D devm_gpiod_get_optional(dev, NULL, GPIOD_IN); if (IS_ERR(eoc_gpiod)) return PTR_ERR(eoc_gpiod); gpiod_set_consumer_name(eoc_gpiod, "ak_8975"); @@ -937,13 +937,12 @@ static int ak8975_probe(struct i2c_client *client) * deassert reset on ak8975_power_on() and assert reset on * ak8975_power_off(). */ - reset_gpiod =3D devm_gpiod_get_optional(&client->dev, - "reset", GPIOD_OUT_HIGH); + reset_gpiod =3D devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(reset_gpiod)) return PTR_ERR(reset_gpiod); =20 /* Register with IIO */ - indio_dev =3D devm_iio_device_alloc(&client->dev, sizeof(*data)); + indio_dev =3D devm_iio_device_alloc(dev, sizeof(*data)); if (indio_dev =3D=3D NULL) return -ENOMEM; =20 @@ -955,7 +954,7 @@ static int ak8975_probe(struct i2c_client *client) data->reset_gpiod =3D reset_gpiod; data->eoc_irq =3D 0; =20 - ret =3D iio_read_mount_matrix(&client->dev, &data->orientation); + ret =3D iio_read_mount_matrix(dev, &data->orientation); if (ret) return ret; =20 @@ -965,16 +964,16 @@ static int ak8975_probe(struct i2c_client *client) return -ENODEV; =20 /* If enumerated via firmware node, fix the ABI */ - if (dev_fwnode(&client->dev)) - name =3D dev_name(&client->dev); + if (dev_fwnode(dev)) + name =3D dev_name(dev); else name =3D id->name; =20 /* Fetch the regulators */ - data->vdd =3D devm_regulator_get(&client->dev, "vdd"); + data->vdd =3D devm_regulator_get(dev, "vdd"); if (IS_ERR(data->vdd)) return PTR_ERR(data->vdd); - data->vid =3D devm_regulator_get(&client->dev, "vid"); + data->vid =3D devm_regulator_get(dev, "vid"); if (IS_ERR(data->vid)) return PTR_ERR(data->vid); =20 @@ -996,7 +995,7 @@ static int ak8975_probe(struct i2c_client *client) ret =3D ak8975_who_i_am(data, data->def->type); if (ret) return dev_err_probe(dev, ret, "Unexpected device\n"); - dev_dbg(&client->dev, "Asahi compass chip %s\n", name); + dev_dbg(dev, "Asahi compass chip %s\n", name); =20 /* Perform some basic start-of-day setup of the device. */ ret =3D ak8975_setup(data); @@ -1032,8 +1031,8 @@ static int ak8975_probe(struct i2c_client *client) * The device comes online in 500us, so add two orders of magnitude * of delay before autosuspending: 50 ms. */ - pm_runtime_set_autosuspend_delay(&client->dev, 50); - pm_runtime_use_autosuspend(&client->dev); + pm_runtime_set_autosuspend_delay(dev, 50); + pm_runtime_use_autosuspend(dev); =20 return 0; } @@ -1048,7 +1047,7 @@ static int ak8975_runtime_suspend(struct device *dev) /* Set the device in power down if it wasn't already */ ret =3D ak8975_set_mode(data, POWER_DOWN); if (ret < 0) { - dev_err(&client->dev, "Error in setting power-down mode\n"); + dev_err(dev, "Error in setting power-down mode\n"); return ret; } /* Next cut the regulators */ @@ -1072,7 +1071,7 @@ static int ak8975_runtime_resume(struct device *dev) */ ret =3D ak8975_set_mode(data, POWER_DOWN); if (ret < 0) { - dev_err(&client->dev, "Error in setting power-down mode\n"); + dev_err(dev, "Error in setting power-down mode\n"); return ret; } =20 --=20 2.47.3 From nobody Mon May 4 13:03:49 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5A2A38C426; Mon, 4 May 2026 09:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; cv=none; b=U3qH3We2IWZ5RqLshjn+GPJSzCXrNFcweXDHRVDaa4v2eaVPvGcOHm0e+oR5b6cik2XPfV2QxYV/djQg3vfaAPkCk0enTJij+5xdkRCn0VsOC2ObJ1AiFWvzzjaozfHJ3Va8C/GKt0SJW0UyfUXGbU1/zzBm5UaHTN0OJugVvVs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888115; c=relaxed/simple; bh=zmJEtSB0T2YuJW2BxSdMSZv6WW8eov8Luau/IiqB+Wk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SnCOf4/2hQ5STYG1Jrp14+FbMIKmTaElEcMA20NkC0VZRWtgsjdpEJIrHSB7i5lYIbbHue9agXoqRpaWh2WSfLUXfnKZmp3ib0f0gohZ5wBpF0019MRS/A45kw7FD16k50GVEiD9wXUsdemR6/kn1gClHF7N3EvVaFDzUzrihi0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bbiigpuO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bbiigpuO" Received: by smtp.kernel.org (Postfix) with ESMTPS id 9992CC2BCF4; Mon, 4 May 2026 09:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777888115; bh=zmJEtSB0T2YuJW2BxSdMSZv6WW8eov8Luau/IiqB+Wk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=bbiigpuO2fywxKXc5QsPaTkqoM97jRcUDARcWPde6IDHE//sIS2ERr+BtpU75TeTn Hye55DmE+Hw1RfUv8lvcd0WjFNqIEONqBAa+5XYiAeEz5AiDzrLjdBqDBqGLA9muRD qt91KBwf11xJOY3H8/w5Jux76Tj6Loy2T7D1aaSPFHIHmcTC/CLRqwpYiwlxTQnX+y uRX0wPrA3TZ7duIcFEsZ4OUfuPmVc1jd1x6TRtfzjIV0pGr4hKSfsTKA6yzfFXW2zI kYCUpscRNhmip1FSarPOVceKOiaWOLctNRg0rOtBb2XelJUGR1eULMmg0GSEbRfg8r EkSG+Msid4hXw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93452FF885A; Mon, 4 May 2026 09:48:35 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Mon, 04 May 2026 11:48:29 +0200 Subject: [PATCH v4 17/17] iio: magnetometer: ak8975: make use of the macros from bits.h Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260504-magnetometer-fixes-v4-17-a291c2a7c71a@gmail.com> References: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> In-Reply-To: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Joshua Crofts , Andy Shevchenko X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777888112; l=2953; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=FYcHPKDQ0L5hi3cZ5Q/MrcN4lIp6bx9WNHjfUJ4/iTo=; b=B9pEHPtR7Oq4u6jiOpVmmQUkPGQGZH5Iyyt8P9il0YfrHr7LUfZ1O0BKSxGvEhYIEJJ7TPLAA 37X1uuvWQ6bDz05jTMwO3abVfmhfF9fLBkyxQ2sJEmMu4N417UHnlz0 X-Developer-Key: i=joshua.crofts1@gmail.com; a=ed25519; pk=Xd+UVoRPiiI0K3LHQ2XIcXmO0jvVuFTv9eTx3lgBphI= X-Endpoint-Received: by B4 Relay for joshua.crofts1@gmail.com/20260422 with auth_id=746 X-Original-From: Joshua Crofts Reply-To: joshua.crofts1@gmail.com From: Andy Shevchenko Make use of BIT() and GENMASK() where it makes sense. Signed-off-by: Andy Shevchenko Co-developed-by: Joshua Crofts Signed-off-by: Joshua Crofts --- drivers/iio/magnetometer/ak8975.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/a= k8975.c index eeaf7cd5e36dc0e09f4bc588edceeb66501b8bef..ab400c107a2154b791d969f1df1= 6f96ef139c5b2 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -45,8 +45,7 @@ #define AK8975_REG_INFO 0x01 =20 #define AK8975_REG_ST1 0x02 -#define AK8975_REG_ST1_DRDY_SHIFT 0 -#define AK8975_REG_ST1_DRDY_MASK (1 << AK8975_REG_ST1_DRDY_SHIFT) +#define AK8975_REG_ST1_DRDY_MASK BIT(0) =20 #define AK8975_REG_HXL 0x03 #define AK8975_REG_HXH 0x04 @@ -55,15 +54,12 @@ #define AK8975_REG_HZL 0x07 #define AK8975_REG_HZH 0x08 #define AK8975_REG_ST2 0x09 -#define AK8975_REG_ST2_DERR_SHIFT 2 -#define AK8975_REG_ST2_DERR_MASK (1 << AK8975_REG_ST2_DERR_SHIFT) +#define AK8975_REG_ST2_DERR_MASK BIT(2) =20 -#define AK8975_REG_ST2_HOFL_SHIFT 3 -#define AK8975_REG_ST2_HOFL_MASK (1 << AK8975_REG_ST2_HOFL_SHIFT) +#define AK8975_REG_ST2_HOFL_MASK BIT(3) =20 #define AK8975_REG_CNTL 0x0A -#define AK8975_REG_CNTL_MODE_SHIFT 0 -#define AK8975_REG_CNTL_MODE_MASK (0xF << AK8975_REG_CNTL_MODE_SHIFT) +#define AK8975_REG_CNTL_MODE_MASK GENMASK(3, 0) #define AK8975_REG_CNTL_MODE_POWER_DOWN 0x00 #define AK8975_REG_CNTL_MODE_ONCE 0x01 #define AK8975_REG_CNTL_MODE_SELF_TEST 0x08 @@ -95,8 +91,7 @@ =20 #define AK09912_REG_ST1 0x10 =20 -#define AK09912_REG_ST1_DRDY_SHIFT 0 -#define AK09912_REG_ST1_DRDY_MASK (1 << AK09912_REG_ST1_DRDY_SHIFT) +#define AK09912_REG_ST1_DRDY_MASK BIT(0) =20 #define AK09912_REG_HXL 0x11 #define AK09912_REG_HXH 0x12 @@ -107,8 +102,7 @@ #define AK09912_REG_TMPS 0x17 =20 #define AK09912_REG_ST2 0x18 -#define AK09912_REG_ST2_HOFL_SHIFT 3 -#define AK09912_REG_ST2_HOFL_MASK (1 << AK09912_REG_ST2_HOFL_SHIFT) +#define AK09912_REG_ST2_HOFL_MASK BIT(3) =20 #define AK09912_REG_CNTL1 0x30 =20 @@ -117,8 +111,7 @@ #define AK09912_REG_CNTL_MODE_ONCE 0x01 #define AK09912_REG_CNTL_MODE_SELF_TEST 0x10 #define AK09912_REG_CNTL_MODE_FUSE_ROM 0x1F -#define AK09912_REG_CNTL2_MODE_SHIFT 0 -#define AK09912_REG_CNTL2_MODE_MASK (0x1F << AK09912_REG_CNTL2_MODE_SHIFT) +#define AK09912_REG_CNTL2_MODE_MASK GENMASK(4, 0) =20 #define AK09912_REG_CNTL3 0x32 =20 @@ -836,7 +829,7 @@ static const struct iio_chan_spec ak8975_channels[] =3D= { IIO_CHAN_SOFT_TIMESTAMP(3), }; =20 -static const unsigned long ak8975_scan_masks[] =3D { 0x7, 0 }; +static const unsigned long ak8975_scan_masks[] =3D { GENMASK(2, 0), 0 }; =20 static const struct iio_info ak8975_info =3D { .read_raw =3D &ak8975_read_raw, --=20 2.47.3