From nobody Sat Jun 13 20:57:55 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 08686395DBE; Tue, 5 May 2026 11:46:01 +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=1777981562; cv=none; b=bF3r9ZXgZMhCql6FsBknvIDPVmdz4SotxPaEMpGpKQix5Mkpe/ZJ5H6cTTTcGC7kvp1bJImBCpgXmwXRhc9a+7jxnMSBpzlTPqh4+D6DwP5XrkZccgkGKXYZlbusSw0I1ahMhG0as+YHWwzl8BNCgUWI5Y+V0g8oMEHpgsXNyHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777981562; 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=oTMhxxuba6++VoUGd/5pAmntKKIq+vEPH54rOMcAxBpXu28PnT4yqn8AKTKrf4IzLWz7EZlydHjgBZqhTKQLoMeYB01/F8sa5Ofkkb2B3GnHHAjQ1/THxnm/8HqmgQu8ABwmJdMkxpxVNDtFpnfqzjsE1Hu7GY543MublHxB5tw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JIlCwusT; 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="JIlCwusT" Received: by smtp.kernel.org (Postfix) with ESMTPS id A9A52C2BCC7; Tue, 5 May 2026 11:46:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777981561; bh=XoUSz6+rVgZOj9EzZCIx9qvAwS9jQ+z9/pQSL9KW+tY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=JIlCwusTE4h6VubI6/AAYGN0tirR81X9POT/w6NMgYrYXjVAZwqcTNw9Pn4yH2MdH pWiyBGCHQ9wvzk65+gvYeUFE2zuqd/RkJ9SwWv62biQbaXJ5g9kyGONFFNhxLpvLM+ pIUcLUhY66eMpAmtOHQz9/r/IdNJX6daFmVz+Cmb45EqSBRxqdCPfV2xBBKGHR3nsQ OGSI0QVgH0O7gXQgza/9UgYt1UYNFtoJnuDqGkMyItqTFo6oQgJL1lpwXbj/Ka+nxl DkDN7lBJ5NGv3cFqI6GcnMP3hf7f4zkVNoly20UInfEzhXFZvW0XgtTMrZMkU+2XJP rcb+cEZekAX/Q== 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 961E7FF885A; Tue, 5 May 2026 11:46:01 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Tue, 05 May 2026 13:45:57 +0200 Subject: [PATCH v5 01/18] 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: <20260505-magnetometer-fixes-v5-1-831b9b5550fc@gmail.com> References: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@gmail.com> In-Reply-To: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@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=1777981558; l=1542; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=ifC04FwraxdTSdGAo9jIXh6jMIMFxT5mVabPgLPFhPM=; b=JP0N5GLtTNzsJeZEjiK8ZoTjo6aSOZnFtmfohwVm/Y3hKL+nPqM/yyC9PsbhlFDAWz6dcVtYW GTFwNtlUOKbBhNfwz7rdhJ+ytWoFkrcuylZsEQxBiZgGBwJkdgLbiWf 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 Reviewed-by: Maxwell Doose --- 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 Sat Jun 13 20:57:55 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 08730396590; Tue, 5 May 2026 11:46:01 +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=1777981562; cv=none; b=s/oUDjEUGnhYIl1LP60f0ldVUALOJx9IQ5OzH9WGdpWHiqIJ25vXl8ouSKMVP2eCxMYkN6y8/JYYvXnrUgGVMzQ7w9rkKpx5qsu8gv7ar9Tl3aoedEgbMHC/zIyak+aNrsSGivQvvZcDyTTibG+7lbG8N9ZjEf0jcC/AVpwdxtM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777981562; c=relaxed/simple; bh=KTpXdGTT6B3eCbkI8WxFGVAXXF1bB/qEk4KzDV7o/5A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YWrOQvh0Gu2tqd0M+q3114pAd9g0O6GgERmtEO06+xXfdE0hfeoUl8IShe73GaWHFMXYbvctnV+CsKWNfOzOZQC9cO5JumbaKeoQRnzKr5YabPqz9XG1mG6uhZ29PBeNT5uNTFaE56dF+AF29LhwFrhfk9iiK1htnZ7TF9JZYzA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RrKNz/dU; 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="RrKNz/dU" Received: by smtp.kernel.org (Postfix) with ESMTPS id BABADC2BCC9; Tue, 5 May 2026 11:46:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777981561; bh=KTpXdGTT6B3eCbkI8WxFGVAXXF1bB/qEk4KzDV7o/5A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=RrKNz/dUdKJNZedEaCkLBQfsemknoWd16QBD/Fywm4E7skpmAjbYpLs5K1izQGBbI UdkAY1sK5Bs2tBcCeAm8O/ji49SNOqYp9F7WjhQaiJ0wNguWtaqQ2h7/bUZOb32Rbt tHbndHoWuMMVsgsSbqtGY7qmB4eSPUjjyR411W1NbZ93w1l+7x/1yMRuPt6pDkJcXr 0oQvV40I8JhDZyKhknG4zVD3NomhbgMBw50wqB3GSGEyy6r3dAk0y+iYU7VGpp8Jgl D6Cibok6OQdxZeRKXQTV4Rwi5ddGrW1Pn2mlMSyXNso+cZuuD0kDP29ojHetjSE2a0 f/BiwAfLzGhBg== 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 AB176CD3436; Tue, 5 May 2026 11:46:01 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Tue, 05 May 2026 13:45:58 +0200 Subject: [PATCH v5 02/18] 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: <20260505-magnetometer-fixes-v5-2-831b9b5550fc@gmail.com> References: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@gmail.com> In-Reply-To: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@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=1777981558; l=1704; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=0t8AkWNcobfyp296krmxpLOOL2U/ytoZq42+8WVejEI=; b=7iGbjPrCqbvNZrE9OPJp/OVmMtq+HP/+pouWpH5DELGeOnotFWy/DS01iiM+0okxDOX64xCw9 IGZPpoa+ct2B6r6m9fJVaUpEb+y5Qb5Lph3PJ6YRpZqcseFaNWDUVLL 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. Reviewed-by: Andy Shevchenko Signed-off-by: Joshua Crofts Reviewed-by: Maxwell Doose --- 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 Sat Jun 13 20:57:55 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 087C7396B73; Tue, 5 May 2026 11:46:01 +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=1777981562; cv=none; b=Dnwe3L8VhEjeNHQIIHcXvHFRB77wJdVodiLbpo/t5YaPad5FkVZcBbfzMm0d439/aYG5TvF8XkH9nvVeMIGRh00tUPLaDLzlRJQJVDnF8Yi7+0CVN0jPffXVMNeORHAiAi77SlM7atq57B/9ExptGOG9cVxXvZ5M7HTj1E8gE7o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777981562; c=relaxed/simple; bh=IQqw8dqzN87N3kyvLEEH/hIdLkUDhN+PIO0XcgQOetQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZVvjtHfU0x7H44DJDxem5SoZcm8LL9wXeUPJoFQ5dgVdB7A3YzPrDojVlkUyoD7H2KKKmnKyXWuwYWXEKCzGVx5DYOkIOsS1nk0p2B34Jb0QMy5wBEbiV1V23k80YSK4sOB06iTCo6mMaVwVQucYXQFuqMtsYtpOBG51syDZEZc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qFG3K0de; 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="qFG3K0de" Received: by smtp.kernel.org (Postfix) with ESMTPS id CA615C4AF09; Tue, 5 May 2026 11:46:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777981561; bh=IQqw8dqzN87N3kyvLEEH/hIdLkUDhN+PIO0XcgQOetQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=qFG3K0deDUufe7Ch18mPxEFdeX4CQbEdP0ukXDku7VRZdsDISaUKX4PfzIuujk5uZ pMgLkqJ/dF/Lh56b1qRHREuCn79e7zmGiL+XTBO6hjfiIfmQuwPaWhhJSr69WbH1ii NrjYUv1m4fmJvLb34aOHeenpQHOAl5B8IQWWwZVt6qZyoit+/sJwcGJrIW4zRsn+7r tab4wDi1AcSem/9Yns+S2RDW16tfx1Pt4lCCQuuBzKuBIAgQMdmzV1FynNB+t5esAt T0rLG4ViBQTRmuvGIarStGMv4mOvfnWPtUQqkAAetslOlmOpNBZLsHYIiDgOVB91J0 KGimHTv4JDBfA== 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 BF4CDCD3430; Tue, 5 May 2026 11:46:01 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Tue, 05 May 2026 13:45:59 +0200 Subject: [PATCH v5 03/18] 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: <20260505-magnetometer-fixes-v5-3-831b9b5550fc@gmail.com> References: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@gmail.com> In-Reply-To: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@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=1777981558; l=1188; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=pYNXSLcsScB1UFEjU4yV7Zvmf3IflZ84nydrNj+FmrM=; b=wvpjzx4+gaHs/FYy/Y7NJ62of+Dey/92o5FsA17FklklNFHVdaMH8Lxy/O65/HU3+uEwXljJW DI7Cq5uhJ7jD1QsR24OGh/SpwMqY9G/kipKBhBloPNaIAnKMN+wPLoZ 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 Sat Jun 13 20:57:55 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 1A184397688; Tue, 5 May 2026 11:46:02 +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=1777981562; cv=none; b=ljceYs+BjGFrJyCbPmLqTMkCYS0xzq4Ol7UMGo8ioBZE5rRJxgXSFnQ0WJnedHZSJxBC3M1C+VR0DNOVLNrGUcoaqg63xdO8HSBA42y7iCTnRraY5ZPSI9I0MDh6D630F4zzJ+bq89S3DcFbYMu+0kMLJ5DzhU6kpYWeJq/wjP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777981562; c=relaxed/simple; bh=LzFzwM1vVt7yzGjBEJMTkXfLayEfGMNdWc3OJe6lpjQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=liOgbPEBVm/aehDTJXEZulZxwLuZGheX4YN9AfesvHWVOob4t8UIbEtBUMrWz8wRIYu2N0++Res+Nf6ymAdhnP3vz/E5uE6XkzIdqYQeJZHocK0mlaLHGXRDJlrmfii9AQnJhM7rI200nj280Ci0TKyMB1SylV8bVKOH3u8GSpo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OunIMiE9; 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="OunIMiE9" Received: by smtp.kernel.org (Postfix) with ESMTPS id DAA3AC2BCB9; Tue, 5 May 2026 11:46:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777981561; bh=LzFzwM1vVt7yzGjBEJMTkXfLayEfGMNdWc3OJe6lpjQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=OunIMiE9nwynj+ST5l49FSWNPGfeFRfFpxzurZI0T4x9x+gCVC60cOqJMt1R0ZTU6 eNi+9Rzv8aDhJHH0FspSgnEbIO4/dxC8zUMymiJ2kztbJ97p7ZHwZ+KWbSU/uidJzJ oMGa5kpEHQH1ywXTFHMoYGzGYlNxXziDGpvSjv806f+X8gC1wQmQ5e05F/C4qNZ0l9 1vfjgUItL8TGcwzx+nTJo+wRpIx++tjtL7DEX6TFHuBB7hzsJMMbSKkt7RXxLsp0xU Pdb0ZLWwc+0rt7v+QJp7bsb9FBpTUuMVsGQHqkhsepwKxVx1gb2bESBmyyJd0dogWO AEkxDKPpgWnvg== 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 D0391CD343C; Tue, 5 May 2026 11:46:01 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Tue, 05 May 2026 13:46:00 +0200 Subject: [PATCH v5 04/18] 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: <20260505-magnetometer-fixes-v5-4-831b9b5550fc@gmail.com> References: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@gmail.com> In-Reply-To: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@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=1777981558; l=1056; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=Wdt8KANnDoSFXBcgrJIrMksQrP9sjlwOf4hExOFf40Y=; b=M7KAiGPTTXPM3TeKKNkwu0h0VKki3nc7Ksn7ZOWxI5nq8pa0kF+5UyDj4bc4dvZQGC2NwY1+f 06jKMy6kTxHDwVmsUGmVWfVohTE0uk+C0LTNdF7yLbP4BEhB+5X6SM6 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 Reviewed-by: Andy Shevchenko Reviewed-by: Maxwell Doose --- 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 Sat Jun 13 20:57:55 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 2F96439935E; Tue, 5 May 2026 11:46:02 +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=1777981562; cv=none; b=smGpGLVB74zeVZEKtINrsgI2HIVuuBY/lZ6tc1ZOV5GHWfaOZR7nTv6j55texCfxlITOtw5gJ39bDTGBkk5hCSpsfaPGTbiJyub/X9rKdDTwWB8ShXi88oCdGVp6Ntji8ckYe5tuMlVGa3R8ysn4g8epCP51AydSw3XPFKXJuhI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777981562; c=relaxed/simple; bh=iKsneH3hjX3g0hqlLVA2JH8ISXd4JIrC/rCQfH+Avwc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CYioEs+Rzf3KqUpFcCZdnazYQlvVUUWw7tuLBiqv/OU/gbYHimtiXKoI2fUoCkOvoC4jqwvyqzSNGypqgS0T5NHeTKdA9w7Vt6t5G9TkhziDMl5IcYw+WbqXwDd+od1pJ0TSpwEzwU5UZVCzWJB9E5nX9zlpxFwcvXl1rHvFrbE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UfPN2Qf6; 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="UfPN2Qf6" Received: by smtp.kernel.org (Postfix) with ESMTPS id E7C80C2BCFC; Tue, 5 May 2026 11:46:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777981562; bh=iKsneH3hjX3g0hqlLVA2JH8ISXd4JIrC/rCQfH+Avwc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=UfPN2Qf6/4eyMkAvbgJaijHQ07pm/SUaO66PPi/Hidwi7l0sAx5SgNK27awA3o6kB ndP5e+34qgdgEQlbsj5AArkjXn6xZ0fWYq1K1P3jzjY9XCTf3WxEPboG3Rf6hWGAAM skty8TVWdbPd3Me739JggHmkXzAKM37nmD2QrK27K/t0uT06LrtnVTxYVvGgrP14Gz 5nEldRmdUANdbfES3bRQpRqcr8HVb/7k0+YM2xhnyk+6BI92kc6d/43aen9L9AngTu nNeO6ym3Lxt76j12qdTQc7M0j9M5fvRimTZWk+WDOOHwvQOLePPvrXL5GThvzXLFoB 9L3/QPNPYL2kA== 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 E0702CD342F; Tue, 5 May 2026 11:46:01 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Tue, 05 May 2026 13:46:01 +0200 Subject: [PATCH v5 05/18] 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: <20260505-magnetometer-fixes-v5-5-831b9b5550fc@gmail.com> References: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@gmail.com> In-Reply-To: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@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=1777981558; l=2130; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=8BWMSJrKx3tcT795wZWjnllxfUR1fD05C91F7y5HJAA=; b=5qu3HWzIigqhQMlmqXYJTFKN8DFPG0fo5wwkRWhRd/CK9TafFmtpBMComlcxDdUr3niE0t4/T xP7D2xkGU5IB4Rd25Y+gQFuyL0KWpf1qeq8QoNeLwfr50cXVEsC/iNV 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 Reviewed-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 Sat Jun 13 20:57:55 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 2F884399357; Tue, 5 May 2026 11:46:02 +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=1777981562; cv=none; b=hNMqfCn2yr5VsW73UEsAIudWhnXdVqTANDjqpK1C79tQrvwlismxHkstePHklj5gAoodM1UVeiNj4NU6GmPytK8JlKPBXqLY5vpNwRCmq1R+bj2uJ/jzqBUjvgGGeyCaZqA86VylXxeCyzlVErhE7dLhDpKdg+133D4T7E0o36w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777981562; c=relaxed/simple; bh=pLp5TLFzkBen5my7x1WblpGjzZO6ZpAuuKQED5eqk2Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sHCQ0b81JTbiUHXbCKKNpDMS+wWisPIXBegfefbc/nFgbjYaPgh83gf56zERKs22jUqGcw33f8t6WqXtK4jUZNHrvs7Wu+dU0TeyVPS1XijvDy/4TYqsH/D1myjI35JF3tD/dsZ4MZaXXudMJNXX0ujdul/3qXxJG6MS07OqcPk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XwlL3r9T; 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="XwlL3r9T" Received: by smtp.kernel.org (Postfix) with ESMTPS id 0498CC4AF0D; Tue, 5 May 2026 11:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777981562; bh=pLp5TLFzkBen5my7x1WblpGjzZO6ZpAuuKQED5eqk2Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=XwlL3r9TbZ2MOLQDT3hn266x6le6pv9xchcfFlrKzoMUWJk/r1IJGEVAypdAG3iM/ gfzrHCJUC3xPm/iA5TdUcJm1vgX1SzwT5W5Axj2HDZEJpBE7THzUIZEeSeO4UFKGNV 41qJvfdKVD1DbyVixpR4CGTcnUZiEic9Qd/gA3RSqOo91uHEUuDsUYEq/yepFr8QZD bwjP4Ks2nOSTsPI6KoSWb2owdRfUlN48vHR1OezV9vTcux/bPejDM1rVBcDtYOnlz2 F7b7tRo0QTc8ncRaat/3kqCHA35dzkbOv3uP2f4JTlYj0u7g0WMQdrlOS01jPm+JwO 2TclTszg6+Zdg== 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 F0FD3FF885A; Tue, 5 May 2026 11:46:01 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Tue, 05 May 2026 13:46:02 +0200 Subject: [PATCH v5 06/18] 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: <20260505-magnetometer-fixes-v5-6-831b9b5550fc@gmail.com> References: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@gmail.com> In-Reply-To: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@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=1777981558; l=4851; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=pvNZI200r8juauqZArl2DmxC7e++xAb3H/RtbpQciUg=; b=aYMM8qM+7B28lJ7PQlF3m16HPgb685QIroTfwoULTujyvHqetl7XjY2PJB3Q3R5ZdEj8PcoUn PO2lPAuTVwODfUO5t5N1IQpZvPDvMw4ZNZuYOY5F7lgnMPMBE/oM00W 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 Refactor wait_conversion_complete*_() helper function to accept poll and timeout values directly as parameters. This improves the readability of the code and does not rely on hardcoded macros. Besides that, fix the home grown and obviously wrong in some cases the jiffy-based timeout. Co-developed-by: Andy Shevchenko Signed-off-by: Andy Shevchenko Signed-off-by: Joshua Crofts --- drivers/iio/magnetometer/ak8975.c | 42 +++++++++++++++++++----------------= ---- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/a= k8975.c index 57f50c09cca539c3733f516a1617375e9134c349..83878ea28b91d8316d2cc31e57f= de6da957af689 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -132,13 +133,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. @@ -649,18 +643,19 @@ 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, + unsigned int poll_ms, + unsigned int timeout_ms) { struct i2c_client *client =3D data->client; - u32 timeout_ms =3D AK8975_MAX_CONVERSION_TIMEOUT; int ret; =20 /* Wait for the conversion to complete. */ while (timeout_ms) { - msleep(AK8975_CONVERSION_DONE_POLL_TIME); + msleep(poll_ms); if (gpiod_get_value(data->eoc_gpiod)) break; - timeout_ms -=3D AK8975_CONVERSION_DONE_POLL_TIME; + timeout_ms -=3D poll_ms; } if (!timeout_ms) return -ETIMEDOUT; @@ -672,16 +667,17 @@ static int wait_conversion_complete_gpio(struct ak897= 5_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, + unsigned int poll_ms, + unsigned int timeout_ms) { struct i2c_client *client =3D data->client; u8 read_status; - u32 timeout_ms =3D AK8975_MAX_CONVERSION_TIMEOUT; int ret; =20 /* Wait for the conversion to complete. */ while (timeout_ms) { - msleep(AK8975_CONVERSION_DONE_POLL_TIME); + msleep(poll_ms); ret =3D i2c_smbus_read_byte_data(client, data->def->ctrl_regs[ST1]); if (ret < 0) { @@ -691,7 +687,7 @@ static int wait_conversion_complete_polled(struct ak897= 5_data *data) read_status =3D ret; if (read_status) break; - timeout_ms -=3D AK8975_CONVERSION_DONE_POLL_TIME; + timeout_ms -=3D poll_ms; } if (!timeout_ms) return -ETIMEDOUT; @@ -700,13 +696,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, + unsigned 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; @@ -715,9 +712,10 @@ 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) { - /* Set up the device for taking a sample. */ - int ret =3D ak8975_set_mode(data, MODE_ONCE); + int ret; =20 + /* Set up the device for taking a sample. */ + ret =3D ak8975_set_mode(data, MODE_ONCE); if (ret < 0) { dev_err(&client->dev, "Error in setting operating mode\n"); return ret; @@ -725,11 +723,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, 100); else if (data->eoc_gpiod) - ret =3D wait_conversion_complete_gpio(data); + ret =3D wait_conversion_complete_gpio(data, 10, 500); else - ret =3D wait_conversion_complete_polled(data); + ret =3D wait_conversion_complete_polled(data, 10, 500); if (ret < 0) return ret; =20 --=20 2.47.3 From nobody Sat Jun 13 20:57:55 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 33A8B39A06A; Tue, 5 May 2026 11:46:02 +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=1777981562; cv=none; b=LhRy+k3ww0FozNnjPAIB3fgnW6kZreI90h7vS7Yskdx451ccLg60JxvL/RAUCN7KPhBj1PPrY6H3wdd37ObFtui17KZQJEOSFgtv/twHPNN+CfMOiaVl3cMJ0CPOTjlC2OGCcg4DXdCwEWwXSoQC8Alv9V907lJCtKZzgfoxq5Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777981562; c=relaxed/simple; bh=9npR7wrcacX2lmVhsXinZNG2gouAhwEMn2L3fI5GMlc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bvRarX5A0v2Jkb9JEdL1mY2rl6yFShPrVJM47GcM8r0+Qvoqa2zh78xhNN8QAIduTqP/csUVvC0nmf1La2lsXXF5jLl0eKFVQ6w5JLP+AKfObrKn2XbCsTYmSyQAvDX5tJ5I5eeGbl8taoth4JUbfHpDfaA1P5nHYH/pZILAKWA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fpmlTFFJ; 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="fpmlTFFJ" Received: by smtp.kernel.org (Postfix) with ESMTPS id 13F93C2BCFB; Tue, 5 May 2026 11:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777981562; bh=9npR7wrcacX2lmVhsXinZNG2gouAhwEMn2L3fI5GMlc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=fpmlTFFJYxJyQI5aqmH49oOpSzM0Vt/NkRlXxB19xTb92D2HS4fDQu9LLveD8fRzm NBWYgm9NqdvHsZ8JA+thqGrq2vtR4gopR9Eo1hmfd8X7Itd+lBK7RrpvOqmpF24EU2 ufcfZdE9Zlh0VVvep/kvbtUjhmJPGM+8Wyuz91GG0Q2ZREE5wGBpDf5BqRkh7YEJ13 p2TOHN5pz4T8LKGFh5jln3JeuvgET9udrRjhSKSHm/okdiIQtjshbEXMbGBXHSu6ZM CxMY2UjwQBAh9VUXY9r4GYEJD9S4pQfrazsxvlJBYLlio0ZpFpyXgvn6u07GnBGOee Iicu81W1RW0BA== 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 0DB20CD3436; Tue, 5 May 2026 11:46:02 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Tue, 05 May 2026 13:46:03 +0200 Subject: [PATCH v5 07/18] 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: <20260505-magnetometer-fixes-v5-7-831b9b5550fc@gmail.com> References: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@gmail.com> In-Reply-To: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@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=1777981558; l=2913; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=V41QhCKldiQvyAMY8Wu1TqUXJlT45yolrTnhX4Txgr8=; b=BqJ2KGQy3/p/0g3joi4VPc0mD29AXJAYWOiDU9iOTwAoxTwiphXL3qsqyfj70EzO5uq6jZDX1 9ogfvjyMexJDsteFregXyvvgYDrrF++cOOJZjSh6X7cLlLJysyQqH8P 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 Reviewed-by: Andy Shevchenko Signed-off-by: Joshua Crofts --- drivers/iio/magnetometer/ak8975.c | 43 +++++++++++++++++------------------= ---- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/a= k8975.c index 83878ea28b91d8316d2cc31e57fde6da957af689..129c98c97071b4cf8efa3abf236= 4a3abbde129ba 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include =20 @@ -649,16 +650,14 @@ static int wait_conversion_complete_gpio(struct ak897= 5_data *data, { struct i2c_client *client =3D data->client; int ret; + int val; =20 /* Wait for the conversion to complete. */ - while (timeout_ms) { - msleep(poll_ms); - if (gpiod_get_value(data->eoc_gpiod)) - break; - timeout_ms -=3D poll_ms; - } - if (!timeout_ms) - return -ETIMEDOUT; + ret =3D readx_poll_timeout(gpiod_get_value, data->eoc_gpiod, val, val != =3D 0, + poll_ms * USEC_PER_MSEC, + timeout_ms * USEC_PER_MSEC); + if (ret) + return ret; =20 ret =3D i2c_smbus_read_byte_data(client, data->def->ctrl_regs[ST1]); if (ret < 0) @@ -672,27 +671,23 @@ static int wait_conversion_complete_polled(struct ak8= 975_data *data, unsigned int timeout_ms) { struct i2c_client *client =3D data->client; - u8 read_status; int ret; + int val; =20 /* Wait for the conversion to complete. */ - while (timeout_ms) { - msleep(poll_ms); - 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 poll_ms; + ret =3D read_poll_timeout(i2c_smbus_read_byte_data, val, val !=3D 0, + poll_ms * USEC_PER_MSEC, + timeout_ms * 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 Sat Jun 13 20:57:55 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 3FB3E39A06F; Tue, 5 May 2026 11:46:02 +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=1777981562; cv=none; b=ILAZe57Y2ghAhvMX25x6Ea2Qe/nYfH5PfqZ9PYGWwRC1OrEFsQcxT8OLNMUSvj2GOei15wDMZGVs+sNJneD8zPVOXcVidpEsqY2xdCZ46c1AQO5B2Yeld4bDgzXTm3jgQ8Ob+xg1YhAFLOGGmWi/hMXm78JI9Y3zDzf0u6fLX9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777981562; c=relaxed/simple; bh=kDDrvck3zNcILrzQWfrEiyjO2FiM4dDc+fCM67atdWs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PYRFsDU0wcEpRuykTFKgT5wyldSDRQPWm4GHnBRvQKCI1RPqpgwuX/C5768Li5f0TENTRW2n/qD1mKkJePLSfEWifUwu0y5JGXCRchX4BZ0mdHaRw2VJ/J+HlYXzUaMz+DIWpVPpihCSc8fqRT9uBLRAao+ZkT8WY7q/EfdMsA8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=h+TMCAc2; 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="h+TMCAc2" Received: by smtp.kernel.org (Postfix) with ESMTPS id 24920C4AF0B; Tue, 5 May 2026 11:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777981562; bh=kDDrvck3zNcILrzQWfrEiyjO2FiM4dDc+fCM67atdWs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=h+TMCAc2KqPtF4NpmRBlkB5fyguuNIs3sEm+5CMZBwPXiLaz89WW9sZF7WyqgrykG EQR9jr2UeJz4p5308FrkJLxHhADFqT7ojClDNbiGlvrwG643m1tkm5uXrn4ooj5RBZ 17B2s4i3zCkxCYkco/n31mH3sgCsFET33QAYJpMRNcCYWi+YVZNhBMYLhvWEjsaL6I pNh0xwl2QoNLZahRgU0PEGAt6w1bJD62yTyjz+SLLP+Z1/vULuSqHdYP0F39RHhdx1 tXVKnfV3/04x+rfpZDuQvavhunz0NdAsE6XhakZZ9LT6W3E2HDSy3vCazj1e29BAeL ms55s3/3kDQcw== 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 1C2CECD3430; Tue, 5 May 2026 11:46:02 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Tue, 05 May 2026 13:46:04 +0200 Subject: [PATCH v5 08/18] iio: magnetometer: ak8975: check if gpiod read was successful 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: <20260505-magnetometer-fixes-v5-8-831b9b5550fc@gmail.com> References: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@gmail.com> In-Reply-To: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@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=1777981558; l=936; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=vu8QJb1yuLyFcW/eHFRBV7iWnKQKcFBYR1HYOhcgk3k=; b=jlstmsmr9rHtjiwZtiji7dUG6o95VqrdldlZGMejda7uEfI6j239WLxuLEgzK2rbL2sj4UGh8 yoMoPqGfnE8DZaKj0Q87Tm9nfP6y0sAQ1ooDKifiCxwHwIrDY/1ta45 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 Add a check that ensures that valid data has been read from GPIOD. If not, log an error and return the negative read value. Suggested-by: Jonathan Cameron Signed-off-by: Joshua Crofts Reviewed-by: Maxwell Doose --- drivers/iio/magnetometer/ak8975.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/a= k8975.c index 129c98c97071b4cf8efa3abf2364a3abbde129ba..b3caf5f3ebf29bf701bb214aa48= 0fa7afb2651c6 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -658,6 +658,10 @@ static int wait_conversion_complete_gpio(struct ak8975= _data *data, timeout_ms * USEC_PER_MSEC); if (ret) return ret; + if (val < 0) { + dev_err(&client->dev, "Error in reading GPIOD\n"); + return val; + } =20 ret =3D i2c_smbus_read_byte_data(client, data->def->ctrl_regs[ST1]); if (ret < 0) --=20 2.47.3 From nobody Sat Jun 13 20:57:55 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 53A3039B96D; Tue, 5 May 2026 11:46:02 +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=1777981562; cv=none; b=oMYcdc4TAnGPMo91KACKdpQSX4oHncjrRcsddi6kTEys5JV5SullLPu6IFZ0JDhlZRya4Sh8CMfNjTFpRtEsA4CxitzTqw9iuxXzZ/jhMZZG5oGN9MFIIZYBTMQHB495K4dJ3RgV2i2czHR2atdVC52f5DJWR6m6QWU48l05HDQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777981562; c=relaxed/simple; bh=6PPZ8OIbllbC/AgJ1WUIv1DKozXjBUAztl8j/VavP7E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Er3ymusFgS03VqVTPMKVzK0/fduzh2AZ4OVnwF5o2tHM7dlVb+dAMY58BW41iRZAC6L5aCpyfsMxowCtNkCKxk6Z7uOMVDHK6XHQdf7lAm6OtOQJFIQ7Is9+nCzQE68tZxZ1jiOdr+PYRx9qCqLFoUI0Wgq2yqjHQjN230z+JAE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IJEcnj9E; 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="IJEcnj9E" Received: by smtp.kernel.org (Postfix) with ESMTPS id 33D5AC2BCC9; Tue, 5 May 2026 11:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777981562; bh=6PPZ8OIbllbC/AgJ1WUIv1DKozXjBUAztl8j/VavP7E=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=IJEcnj9EujS0wDtaysupWD6APgzasJ2nsxX5AhQZaHUxeA4JLT8AEqFAgazEpLZY6 6vWzqgPoXZkjJu29mCKKNw/Aok8XWBg8AB+4mu9xH6v784vQuWMkKPDU7XL0Qt8NkI ar0aMWwcqvdEDiVSJGrJHaGil2BDlhsLbzBhwtdinv2mLao+41tzb2eDJ9/SzIbi0N XtKKWw4Wp4qK8l3dXuUNRwZrAxtiWPLfXOUBl9d2WYhfTOsEKOymAgoP37ja1GCpzD ICSFmv1ND+PVSKnUxRz+hpI/G7RHBdBCgpn9Sw6GIW1+59FTbeUogOn2M1SuLjz+7G DaOEgBTUwsfSg== 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 2B848CD343C; Tue, 5 May 2026 11:46:02 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Tue, 05 May 2026 13:46:05 +0200 Subject: [PATCH v5 09/18] 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: <20260505-magnetometer-fixes-v5-9-831b9b5550fc@gmail.com> References: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@gmail.com> In-Reply-To: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@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=1777981558; l=1365; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=8tLL2kiAufULoRZYDYBqjmCH5Df7RX705WCjX2nmy9g=; b=HLjOdUCGBtz8iLcZ+OEaf1xTWD7x6kYzf+n26VECoqWCYM3it9G6K88sc0rW0u/ZIVMsl5cmN dM0foXTlMeNCzMmKQTJGuFZ5U1LgQ8mu/uBogWI3uu3vkvCIzoRZIWw 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 b3caf5f3ebf29bf701bb214aa480fa7afb2651c6..c36d068081066ef6b42cc2f9c3c= 2e8978ec51623 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -741,7 +741,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); @@ -778,8 +777,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 Sat Jun 13 20:57:55 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 929853A3E87; Tue, 5 May 2026 11:46:02 +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=1777981562; cv=none; b=eO2hn6SP5+9DNOcJdg60rPBL+8Vxp11ghgjK7tqyUIedkFBIxBxlICU/5og50UVjZevaksmutHAg7TNShH+txBRYg/WqnGvJWCwEEBHHLQWA5Jb0X2VCUV1XgrJEYOips9SgT/xHD8a6U7wAaOMktf9Q0HLIryr4+T3EHrGK02o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777981562; c=relaxed/simple; bh=MPXjkBJADgIt/wERiH+9oxvomnnB/9cU+fY4E1zlxkU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iidYMgN0P1zzs3Y070mUbg+RiMmXOfHxBth8bW0nyur2aHFLjG7qVuYBFHxiO8ib1Gopz3UtzMfh+dhz6d47ghTXNvJqImUk8lcqDXa8f1VpH4ts/ifvo+/Cht6KTOTQU3FoNOZiUxNiZlcBSpiUSGA4FJfXT3RjGZYVVneslHo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FwIMK9A0; 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="FwIMK9A0" Received: by smtp.kernel.org (Postfix) with ESMTPS id 42729C2BCB4; Tue, 5 May 2026 11:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777981562; bh=MPXjkBJADgIt/wERiH+9oxvomnnB/9cU+fY4E1zlxkU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=FwIMK9A0IZX4h3jKvx2QjDBoDCbJvQGBimI/aTPikClpie06qappMz35fkFf+3nJ6 6p8b3aZlii4F+Gn63px2zpp1+nvSv+Wp3Um4dl87arT2E/JqAp7FvqoY5CQv2eMiJI dk5RPqfN4Vc0W+zAqM7JsZBmv+EgNpMNe3/KsJzH3eY9tEn3P7Ujo8kOzhoF56ZneH 8UbZKstm6olnfThzPkI08LW5GafXpZ8uTLcuMh5Wk9Xi5Ecn65SESjsJUPGbDn+gml xPBvejAZ+OZ9ufCnr+a1yG/Y/BRFKZnwLlXe9LHhii87VYXDA26qix59WrqatktnZu IxR0PE0D00rVQ== 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 3A22FFF885A; Tue, 5 May 2026 11:46:02 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Tue, 05 May 2026 13:46:06 +0200 Subject: [PATCH v5 10/18] 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: <20260505-magnetometer-fixes-v5-10-831b9b5550fc@gmail.com> References: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@gmail.com> In-Reply-To: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@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=1777981558; l=997; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=XCs0GN+NbiGoXI2dfBbrODJcBvdjPZeVOf17jMKlR/o=; b=dHnX2TM5lF4yuVOe+fssLPd8Vy7wN2ARVf04Zv71ct3NnRWHaMx6oTNgTU5h10ownvM7cYjFV +xqmgtS7nGaAECPiU5bEmyk2CZzCIMAcuchUpRTMHzVQAKnbZry4SQL 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 c36d068081066ef6b42cc2f9c3c2e8978ec51623..7a971de2eebf127fc8ab68300fb= 82f38d9476c0c 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -918,8 +918,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 Sat Jun 13 20:57:55 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 928F33A3E81; Tue, 5 May 2026 11:46:02 +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=1777981562; cv=none; b=E0w44ibr5/t8rmPS5BACtk6qUch0QRjsAww6fxbx/+tEv3hKXS52RZHjdbyYwhvZwEqKc+Q8FAaONpJcwkPp+LNbMBQEoK/o2KbzAZY0XmoqvDOJ8ZvMMS+FIEFNbmyGfwHgjgZPR15AokMoEqfZXRQcrtrqrUMFDgoeJ7y/rnQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777981562; c=relaxed/simple; bh=h/d77N1gpx+E2O8RHYU+Ry71bdmStInC98q+cc/PY5I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=a+junFXhFxGYoURFDHZeIQouEGuWevNq0Pz3xHzYBz9QN1PS+liBjFl4TMCpkTopR9RQVFcGNsdR2uFMHo4NlltqvjIT/9KxsnG0RpgfCQIl8GyWhQ7iDwW2J+jaQ5F4NMULW4AH1a2BykkDUHhzcPVxoXx2D/22OaK5OtaWr4I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Lw3acUxo; 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="Lw3acUxo" Received: by smtp.kernel.org (Postfix) with ESMTPS id 51294C2BCB9; Tue, 5 May 2026 11:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777981562; bh=h/d77N1gpx+E2O8RHYU+Ry71bdmStInC98q+cc/PY5I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Lw3acUxo861Wa0PAm1dxJ3fM2plFa33KJygeKgVm/hlrU8Xq3OOCUNQFssiIG8873 zhi3BzguTiNfMdKDIfyqRBlfKGqXrxhktFpKXiIUbfpawDOpc29UALcdDEyDTP2Tu+ akLnLbLjqCpU5JDbzjcoqP7qrV1WUdXmaFcI1oXrGOUgnbvaT9gXkFKlEd3f5RG5Un ozcX4Ef/ds/8mQrZx5nMLGyFIQWCcbx5VSZmaPo+Rd2UKAhj1YtnC4KkItL5tyeAK9 PMckvvpHcPk9Z/oFC8vl6uMUGZsjLa+qJgd0ZoPqMlJOvvllgvVVnQgOFCi41ntDpE m4EQQeQNWoZeg== 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 4A618CD342F; Tue, 5 May 2026 11:46:02 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Tue, 05 May 2026 13:46:07 +0200 Subject: [PATCH v5 11/18] 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: <20260505-magnetometer-fixes-v5-11-831b9b5550fc@gmail.com> References: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@gmail.com> In-Reply-To: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@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=1777981558; l=1086; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=TunL/JHu5yEjyxC5fcTuS8qbC8VTvXFU4WWogOsSh38=; b=UWFAVkyfhVY7WQOqC9mXRginoYEKuqTo2p0VDaaIBSJ5Zm/jvrPxKsD44HgDgKFOoFO71NwAi 5HAuO9g3dqrAFNrs5Y9fvzSI9Pwk81hVzflsSbx9D2SK63v1dJYIE3t 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 7a971de2eebf127fc8ab68300fb82f38d9476c0c..f58cbafb491a5e039b22fc928a6= c58dd6ec0f297 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 Sat Jun 13 20:57:55 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 A3DF33A4505; Tue, 5 May 2026 11:46:02 +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=1777981562; cv=none; b=oXSYYUVsaCoycQmAfjqY4s/niokHTcXDmGb3XYYbEac1fUL3O6XEPwm6GFPj0eij6RuJNjS48jdKMOzlPNdmAlxmk/2MIGJAcIvzrBb3bdcTwHoJZJLyqISOJ6GUaN7CkASx2B7AL4MgIWVW/N+lTLo6TfCdFco+fWuuBNYNO4M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777981562; c=relaxed/simple; bh=6BYp57FnTqY7dgYDlLvbafCG2WJR3R2gjLjC2EAy1+w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jsVV4t2BLafwV/ljC+/yfYsITooYX0Hh7a+gsFKA56VqVS40NyAma6f+0m0j4LpztOIaapkHWgeZB8q04rXKn1n9FDon73q6uERpbDNgVlbo6PO5LnIsEGNp63I140mQouX+EEUkcqjZuIddq+qKN06Kbu5JJA8o1FdKimbRE44= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hcBl102s; 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="hcBl102s" Received: by smtp.kernel.org (Postfix) with ESMTPS id 6165BC2BCFA; Tue, 5 May 2026 11:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777981562; bh=6BYp57FnTqY7dgYDlLvbafCG2WJR3R2gjLjC2EAy1+w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=hcBl102s8LeEPFN5V7tEDB90hZDGtEZcYIiScxxKrxGNTXfHZVpEzDxr0AKhJWO8g zmRE7jEbipjAfDGnEAgQ71iau/Vxdv903quWAFuJWHMfzuMi1wkZnoegQtdEgO+Alb /qT4ZP2c9+Lk/tFxU5gM1fKkWbHPExViIbTxZelQYTt/lMsbjOuhAipNU02dTwmofj 5JrsL8JyD9lqJkTJAyRItRoLtWcztqigf5vJvn24v2MADqOJ0Mzg0Y3e4UWkRrT9WO 5xbWfa8zA6P8acu8T2XyhasJnRTUut/HKp2o9FGK7F4+VQwQxmuhQUhNzg1d6XaamG 86SpkNwS9057A== 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 5AB34CD3430; Tue, 5 May 2026 11:46:02 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Tue, 05 May 2026 13:46:08 +0200 Subject: [PATCH v5 12/18] 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: <20260505-magnetometer-fixes-v5-12-831b9b5550fc@gmail.com> References: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@gmail.com> In-Reply-To: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@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=1777981558; l=1861; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=P6PO1KE4H4WDkhTj6+xQlfOfvlMXOvBEi4lRcvei5IU=; b=EPi0Cf7mrBm0kIxFMtxtyS+LX6hMb7+g6zg9/5dV/86rvw4lpkM1CEP3RFyPFuZuibB+cSm82 0i2jUH4muV8CZCgbF2S0QrvHRi8WrYd7PkxFtMepTBwYxQlZy7Ogloc 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 f58cbafb491a5e039b22fc928a6c58dd6ec0f297..fd42e20cd145860bdd1b143409d= e24b7145f8252 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; @@ -865,7 +868,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 Sat Jun 13 20:57:55 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 B72103A545E; Tue, 5 May 2026 11:46:02 +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=1777981562; cv=none; b=YfnQ7o0RpyUyBfNKemaskpytIPXIxCFebY7xWwUvMa77Fq0c4BK0mBOt4S/aKT6PIS+WvntcNym0sac+NYZKwR9f7v/zoVGzKuma3YxGxKG9uogZUdDG5VedxQy5yjbF9wGQo5y6U4SOe4K5h/JnfOyyW2VfKhGd+y40GFZifBA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777981562; c=relaxed/simple; bh=Rpo5ezj3iTFoZ6Doy8L/NCVYOf5Mzo80aZhNp14VQ1U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=o88uSx4QGTyjegeAlAf6R0SKp8THGVKKXiGC3byLjGYgAHy82dUtlJM5GPTvSHXjKlqyNn22d+NWxZIJ95piMKr1Z30UHTQDCTt7skaj3ejgnkSjcv9BbHmeuTs8EJ6iEqLRWBgPeUg1YEh9cq72W2lBJ5O5UoF+NeBvYyQra6o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iGgjjhZE; 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="iGgjjhZE" Received: by smtp.kernel.org (Postfix) with ESMTPS id 83A96C4AF0E; Tue, 5 May 2026 11:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777981562; bh=Rpo5ezj3iTFoZ6Doy8L/NCVYOf5Mzo80aZhNp14VQ1U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=iGgjjhZEALw3BVRSiFOQXedZLgjkWaeAbdPZHFPhUCTziUEUpYw4R20mW2HWL94HE OPkRs7vUJvvRXAQWpT051xeGclaazw4SHPzv4U9Hy8/P9EYdyaI4+rTdNal0DuOxw8 9JLIXxm0NkHHVhQdrDorP0X2q/EMozEROjiSy2lXa6sFR9D8H5IiJ2V8/GQbeztMDj 5SS3eP118CXYttjlCchSJ22M5T8xfEFjyuIUoWZ1pko1cKxzFW+iBr9PWhRnoVFO3n W48uVMZX982xPLGGxCKZQp3chvio+7Wj8C5gmKQVJltXHQxkLRoHJCW470RgUfw+jX CAygOaSUF5GKA== 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 6A2AACD3436; Tue, 5 May 2026 11:46:02 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Tue, 05 May 2026 13:46:09 +0200 Subject: [PATCH v5 13/18] 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: <20260505-magnetometer-fixes-v5-13-831b9b5550fc@gmail.com> References: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@gmail.com> In-Reply-To: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@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=1777981558; l=3874; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=zJS2KqDDT1z1i5VXAW3dS5pr9tJ2+OIn3A8VgRS0jH0=; b=o/H8uQyzWX+bu56yNSMWhJHXkGlqLCQoAESUvP1L72fdjxyffrc70uYoQ/6rrz2TAyY75/KVc IcjIEjBxZPGCBVkcch/PvGI7+zHC3TnIvRzTs9dVO9KTpaBNhizSUCR 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 fd42e20cd145860bdd1b143409de24b7145f8252..1c05e380a4d4f968f505a7d5c0a= cbec86ad949e1 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 /* @@ -907,8 +907,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. @@ -943,9 +943,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); @@ -966,20 +966,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; } @@ -992,15 +992,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; } @@ -1023,7 +1023,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 Sat Jun 13 20:57:55 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 B72DD3A545F; Tue, 5 May 2026 11:46:02 +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=1777981562; cv=none; b=fLRGpnN1Gd9pV9IZIKlzFvLFi7BQQhEnPvXkn04Yc5O6gjneFMfGfbicJpg+IjgDGYjxmWzS7Ot0yNbjcHJMHoWfCjtP+3aXn0HdFArLfN26WaPcnYMg5nAOflbRtdiBFh5L/GkhPvV/kZJPMN0iOHT4jEoHFeoryoJn+Tv9j10= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777981562; c=relaxed/simple; bh=OYLRKn4vbj+SBx2isq71Gqq202dPeBmD9CR9r4Nte4k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KWTzCyK9ZmWH5r8jIaWxCVXtUlpVVOohu5rhWxNZ6AgP0i+uV4IYHV4HmhOC5wFix5SuMaP3D6yQblYmcr0z/NQJitAWCUMyl5q/XBNUJpe6MT8g4jVU0/DGUpTe1uVIC35VibAWCxSWMuFKvSEuhZ1TVNZr+TjF7lst0pW/mVo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X/zi/wpQ; 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="X/zi/wpQ" Received: by smtp.kernel.org (Postfix) with ESMTPS id 88A43C4AF0B; Tue, 5 May 2026 11:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777981562; bh=OYLRKn4vbj+SBx2isq71Gqq202dPeBmD9CR9r4Nte4k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=X/zi/wpQnEBp91Ggr5+PXaNI6bVoXGTgr7lFWQ6GDLEQS5PSHEIWUvLYD5AcuROnK /6wHRqi0dnB3HIGuG5EJB7lTHeKkMECP5RAX29xu7nym8aVrrv6xgkOFaYPXeMXuc2 0uStfdsNcOR+QfOwRZDU7fcLCFguonT3iFcjr7N4PjNdc/vSCFH+K7LY/0imslQbaG dtoAhTRR0DqG4IEquj+DmWUs41x1Py+8xMyaFbE9haspe79q+YusBsJTrNC3Vtp+VA R3CsvzUjFFMnSh6sm9+0alNicK9LkuA0qYFQ7/W3SXYBuoMDxFzopvp+G55ZTgDRxy FYHAYk61+Ci3g== 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 7A407CD343E; Tue, 5 May 2026 11:46:02 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Tue, 05 May 2026 13:46:10 +0200 Subject: [PATCH v5 14/18] 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: <20260505-magnetometer-fixes-v5-14-831b9b5550fc@gmail.com> References: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@gmail.com> In-Reply-To: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@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=1777981558; l=4896; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=+GB+FsZGH67OE5uz28cNhIr2N9StqeThAUxU0HlP7Cg=; b=/n3oWfmRrTTK4KTVsXUaFxtso+wvG1iHahOXaB8FM3yI4zqOXWToUkBRGQQIc6bsW5pkjbTCv sPRN56Fl40GCdpozC1WgD1dyHK1QpY2ba8mPTAcBlmuVp13P6T68/Xx 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 1c05e380a4d4f968f505a7d5c0acbec86ad949e1..84ccbca758b0121a9c4930a368c= b113471d389da 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -900,9 +900,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)) + return; + /* + * 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; @@ -970,10 +988,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 @@ -981,10 +1010,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; @@ -992,52 +1024,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) @@ -1131,7 +1143,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 Sat Jun 13 20:57:55 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 C20CE3A63F2; Tue, 5 May 2026 11:46:02 +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=1777981562; cv=none; b=c5cxwlsYX/u0PcxrigPxZGgai1pTaX1Pp+6SJdp+IekLsyuKLXRMZAoz10LkoXiWnaIZYrZPkMjsaPMeBcuDOMHPF9n/DSFTXA/SSB59csYWRQzBNqkvCks6wIyrEfwjuf+/q3nIlmCnD3WD8DDTFjVqMKvq5OkHGN0RVp9oqFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777981562; c=relaxed/simple; bh=XuxK1om5igY73A5db3176rapoJfEk9AM5Vw3ShphxAI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oks2INdsxpbFABy6Gest6POGzTDJjhU9aSR0Vv0Qv/3ZBiVnLXpQ0kS3C8b2jTT1CYXrLD9E9WNtBXr/POPIUT6uHY5vbNau5wIm2spRNnPfK3vm9H4/26uX29m0jNl73eacOOIvSRnUkcldX2hXqzCM6EJMqh1uCkndqdAmZpA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=u6L7z8i6; 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="u6L7z8i6" Received: by smtp.kernel.org (Postfix) with ESMTPS id 944C3C4AF0F; Tue, 5 May 2026 11:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777981562; bh=XuxK1om5igY73A5db3176rapoJfEk9AM5Vw3ShphxAI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=u6L7z8i66pH7Die5IVwRtDgNBvZo3Kji8Rerred01PPNOxCiyzauSRcO4R3G12JxN +ZDAqUSASB8Kcv2/rmObA6tK+jqPj/HJo2FVRAYh5Ztn52DaTXYrRj6PscH+Drh+6B svHd2kbrCk41h8zJDMgLRwpliA4YtMsZ7XSscSFifEx3jxru7ut73hB8FXwjxpgc31 SSVk01wqD9CP+6R3BqZDOkEwuO086y0EFNqMY1UiUXw82kFujTaP1TV/9D0RlHFdHy uXDvCyOoX1rPQhNrGi8G87OLWQ8GZxQK5FcvTyjt9QKQk9suJunPu+V1lyxVzKxOsS fx/w4IEl7shjg== 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 8BC4CCD343C; Tue, 5 May 2026 11:46:02 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Tue, 05 May 2026 13:46:11 +0200 Subject: [PATCH v5 15/18] 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: <20260505-magnetometer-fixes-v5-15-831b9b5550fc@gmail.com> References: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@gmail.com> In-Reply-To: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@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=1777981558; l=2222; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=umiM7hdXq27k5Ls/2JriqoMfYhs0WQ5fuFisplUXSUk=; b=pViVm2bgoTcd5BujlnxkRjcjkw3jbyboSsEk3PwDlDpSOaJEWcE5AQfiu9JePWFiGg5bg76SF Va1v8PodAjMCoN3avupeLxHuUOdJ8RF3ZzywdXv/GR7vaydBAk1yuDN 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 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/a= k8975.c index 84ccbca758b0121a9c4930a368cb113471d389da..d40ce26e3a47d5a5c9c81d49c12= 8d136208a343a 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. */ @@ -999,7 +999,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; @@ -1007,7 +1007,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 Sat Jun 13 20:57:55 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 C8E1C3A641E; Tue, 5 May 2026 11:46:02 +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=1777981562; cv=none; b=dxSqHD9cZxIah7LalsgWohGOYx1MPa6ih6IVtlrHmebTbIhDyKFC33a1d47rbUivLH140CBQEq34IgOOJCnRN/gaaBWfg2/RHrY/eYCkmaqiTqu8iD7Mrw4tMMxrgM3R1itJ3gK6VssFaFMAOV8hD2AsHPECicJIURzzj57RKiQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777981562; c=relaxed/simple; bh=inKDluvXa76v5UHw9SYDmF5MZCASWBiheZYFTk5wU38=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HwBw0eT+Xoub3RpJvYdudaekRC6Wv+bxNRoTr/hXCGp5Ct/WDqip3i4NYf0pCg+Ht8ENeJW6rQdtuL67NBgGwbh9ujsRaTRaLflrHxd1M8QjIOY/YLvdI98jkYy0yewZz+xPas9UtT0gaSChEguEFm5T+H7iJzS5rIGn+A3GOUg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ad8Hj/s4; 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="Ad8Hj/s4" Received: by smtp.kernel.org (Postfix) with ESMTPS id A6D35C2BCF4; Tue, 5 May 2026 11:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777981562; bh=inKDluvXa76v5UHw9SYDmF5MZCASWBiheZYFTk5wU38=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Ad8Hj/s41ggIKx3ADY6jTzmZQp1blibCCDDdazrKeN22V2mCmMUN5lG5oX3/LdR6U RT5bQH0twf1UKyJkz8OFfIC2yX2SgqCByVQGHY9L6kfsm/aH8SxfzZCtxCNjIa0anI Ea2jiRO1fD35RTtVZWd/0sytrbkBIifbPKmavbsuLI9shbBUHQyuwIKo1quIU0y5MV xXFpHXQrklzBm2r0nmjbIGx/nu20oOPCmPIdkdGHL5arW1nkk7grM/yfv6iDKacQ6K qePPkJjd7FDKoZT5hwG2kl7wLWCr4k2Nh36xulOynOyajNsVDTjlffavzo7TxSM2gI 5rd6HMqCpY9jw== 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 9B400CD342F; Tue, 5 May 2026 11:46:02 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Tue, 05 May 2026 13:46:12 +0200 Subject: [PATCH v5 16/18] 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: <20260505-magnetometer-fixes-v5-16-831b9b5550fc@gmail.com> References: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@gmail.com> In-Reply-To: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@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=1777981558; l=2365; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=QXRp1LyBYRg3HTLkNNYzGDmrtdFNc64EP3iXI14714g=; b=5XkRmo07oyEz7nwKjgh5Pj/Dpau6Rt+NliEtkKKnGMVqIgJ8SbHnuLrtfjxXuhR6jQ9fLhgRt HR54xu84JpbAiG7U958QP/HLJhQdrSyuIoNJ9sBem9uDYpaB5Y4Dzaw 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 d40ce26e3a47d5a5c9c81d49c128d136208a343a..b07c56312f7df07ea21c3f378b5= 721568cb66454 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; @@ -1000,18 +998,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) @@ -1026,16 +1020,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 Sat Jun 13 20:57:55 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 CF6623A873C; Tue, 5 May 2026 11:46:02 +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=1777981562; cv=none; b=uDjbk86GRSz4yCd2sR5CO5SUanANosZWvfwGQG2oCFuqRP7ZvdQ2MFMTvA/F5eJj7SxojI0fHWN245NAPDOTvrj8y6BkGk7eJi7Y+bKhdmrfZg6bP6x1Rv2Lmmyx7uezBmzxG2q6YJfl1nD10FPNBabfCodvg5WprDcSx6TKAhw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777981562; c=relaxed/simple; bh=SfD1eCWzmDKgXn0lXqZ7itucjkBD5oyjQHFRRTTooUE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pCvjkFSU6M89Wt0wqc+Znq785gEr4EdB4clYW8MLqIKUYvvL1tykWJ+aknHjC6XbZet5EalqP68XuDGGent1mWCqQiMNMxzUGvFQunZ3kt5C7RZrEIDVTLYMxJWFDJehefK2YSAOVpQniRW7sI+tlQ5aLNqv1nZadddd7kYmB/A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=B4TqK81Z; 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="B4TqK81Z" Received: by smtp.kernel.org (Postfix) with ESMTPS id B13E7C2BD00; Tue, 5 May 2026 11:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777981562; bh=SfD1eCWzmDKgXn0lXqZ7itucjkBD5oyjQHFRRTTooUE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=B4TqK81ZL6+E2gL0h69ofmNS1J1f2pE1RAB2H+QpDccsWQmPEsLzZkpmCTfnAOiL/ ejmw+GIXecuzAE7O6HNbf91r5NLgMPc0u7CD1QZDqlsplqvW10/tsCTvDdOEhJUGqe Xyj3fPzyVsDTReQPxJXxT+Xf4yzVNE8YfiT68YLePXOmCPkz3XX1evsGDo84PzA/2B WcoRrli6hrZeeC2rz7wwOecdpdIeO01pizmGLj6dvx5x88KG4rpEt70PhIL5HNwOyo Gdeb0sxxgWeMWoNiYGuHK9ysxDEQ9luJV34G0aL5tBHlnTetN3tr6zw7MWTYXtXW42 d2U3OpCINIVTA== 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 AA4ADCD3436; Tue, 5 May 2026 11:46:02 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Tue, 05 May 2026 13:46:13 +0200 Subject: [PATCH v5 17/18] 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: <20260505-magnetometer-fixes-v5-17-831b9b5550fc@gmail.com> References: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@gmail.com> In-Reply-To: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@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=1777981558; l=8161; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=H+QWGt8mbZRrUGCSM+ZLlp9/QnpbwzjCj+ksDGVuWNY=; b=PB3t7fvLlLHxsee7rFnopmsryN4L1N5RVqSdVkLqY2rodBktyokeLmq0rWCiSAV1EM6AV5+A6 FyAHcMNkjQDBGyF/WwZnjLHlMmb8h6XznzXfxL3a0Z6xyLuWHXBa5Nw 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 b07c56312f7df07ea21c3f378b5721568cb66454..1c96df3e1ad95d268470609c61b= e8ee4a709675d 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; } } @@ -738,10 +737,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 @@ -759,20 +759,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); @@ -781,7 +781,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 @@ -931,7 +931,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"); @@ -941,13 +941,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 @@ -959,7 +958,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 @@ -969,16 +968,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 @@ -1000,7 +999,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); @@ -1036,8 +1035,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; } @@ -1052,7 +1051,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 */ @@ -1076,7 +1075,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 Sat Jun 13 20:57:55 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 E7AB53AC0EF; Tue, 5 May 2026 11:46:02 +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=1777981563; cv=none; b=PZa5fYNvANdRAhGTgFnTocqhFpKnFHXyX+J2qyt3kJaehd9BrMzCwWCpPqkulWuTFlMGKJBWRhrdDD0WP6HGV3Rw9RKfdaCFV4fTql/YNwlPOiW41uz1hc4alkkd5W18NKyyTkVgdePVhxPuJvoWX2F8fedXfHppK1P5K5pZdIY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777981563; c=relaxed/simple; bh=jxemnGlxdQDKX+SQrBXX2o9wKXyK41fprOUR1S3+MiA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XIzYJPfzuXznRv9C9hMIfCFXqMHwSP9MSV85Ha4FOjJJAOBUaw0O8AMdeX5t6BBNLb+W6q+fPij8IlfS7Fb0ubYgtjjrZ5eWrP6O64UbicYQTrMP2x+WIZeybHRd/sK9TFtDwGnsCWIHX/dzdKsUc8UWMv3ZmGHZsxO8I6Z6/jc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cbud6Iwa; 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="cbud6Iwa" Received: by smtp.kernel.org (Postfix) with ESMTPS id C3969C2BCFD; Tue, 5 May 2026 11:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777981562; bh=jxemnGlxdQDKX+SQrBXX2o9wKXyK41fprOUR1S3+MiA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=cbud6Iwa4wFEHfHitabiUEI3zL/66wSqQTyMYmL0vFUnqH5Mo/Db9gJ8m2ZqrBQPv PqVI2SIFLfuPX1uFrQR5zgNWXAeqIWmCUtctga1QCNs4QqDiYLwVaAinCOZNXCoDVg lVLmKW2tezc2bMgNt1POCNlfmvkEtGtbXw9nnyZJBXosouTVBoWNL3BekJDt6FMcEp sMvT5o+Zd7XwHRB+SeAX+TUitxxOh0r5m7G2oHaESlXL+nyzrQBHrYaaiT65YtMS+6 OEK7QEJxAlXQaABq4dyFLyC9ftkwOl6Wu5UNQq97ah/kknANFFOZIQfpk2nJoLU6sL BfYGMWZhYXwJg== 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 B8AFEFF885A; Tue, 5 May 2026 11:46:02 +0000 (UTC) From: Joshua Crofts via B4 Relay Date: Tue, 05 May 2026 13:46:14 +0200 Subject: [PATCH v5 18/18] 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: <20260505-magnetometer-fixes-v5-18-831b9b5550fc@gmail.com> References: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@gmail.com> In-Reply-To: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@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=1777981558; l=2953; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=7tIHbpJzTq6eyf+S362H0gx+618ZgmkBgJqjoS1nCrQ=; b=cAge5PY5Rx6PwGz4MQm/l6nZOrDeK8tTEFIq487hceR75CoDITWN6UblUEeYcQkbZcLGiJ1Iw 0fdFkgs9wP2DtbSitudVfiW99wB8TAUjuo1q7eTIZ3YDZafbBV5dNjZ 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 1c96df3e1ad95d268470609c61be8ee4a709675d..ea024390b36d4a13185ec605de9= d808655cab261 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 @@ -840,7 +833,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