From nobody Sun Feb 8 18:31:30 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 57DFE224AF2; Mon, 26 Jan 2026 19:32:57 +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=1769455977; cv=none; b=Wmhsuz4DmGubZTzLZACBb8ZURUh4eCl+x1A7rUzvfqfMQaTHZ0YJJB6xvxxTd2FSmkla5hWA5X7NKGz9QR90o+abGLlgTPlXRFK3CUdcn/JlNjoLOKtY/1tDGXQAkv6hELWFwTS61DCU3IqYgg5exULmmL86ki9L3K9LVOBJJUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769455977; c=relaxed/simple; bh=3KqnVWEI82PftnocqjwUUeyuXpn7Shz/eThc3+dzqD8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=T9qk4Sh1yrAL4QLDfbZnz/sCW9xRKs8jbVFaRwNm+xX25IWUQBg6OtIeEU6f68kd1Hk7XQZqxoW9ypKHgRDxSV7pqyIpcFz4VfY5RFfmywDHH1p1BamdxBB49njsANEbwmIm5m6Mf23dYuH4wCqnw+5eONFCWjJhsSv/dNyz5Oc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kWUFRD46; 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="kWUFRD46" Received: by smtp.kernel.org (Postfix) with ESMTPS id F3C83C19425; Mon, 26 Jan 2026 19:32:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769455977; bh=3KqnVWEI82PftnocqjwUUeyuXpn7Shz/eThc3+dzqD8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=kWUFRD46hBWiLdRPzkEi6aMyW9MtuKk0+3FA9PTVKhf2CBeJOd4n1D5Ijbvjjk5/B xkbuq6/FDB7O0yPYy45ScCEVJ4NOKRFnu8X3XGD0hioVOAhwvU32bBUn0KBu+z1o8m jxXKmYwVhyI5IIVsxNqIQyPQlj9blxfFXVw5ltGbOzYds/IDr79lSbfYyZswfcYCCf ZDu88INb8cx/3zMOYoPK0HGqBqz/aNFD0j5Splfb33eSHRmoV0hhpIEYOczil8FzIw bAkOinASlfPTSGqBP7yQiseN2hB6sW+6FpgKxzVq6I5ahKIhfIR9qXEmEFdPs0DwHu SP5KhNzPrhU2A== 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 E19E3D19510; Mon, 26 Jan 2026 19:32:56 +0000 (UTC) From: Shrikant Raskar via B4 Relay Date: Tue, 27 Jan 2026 01:02:15 +0530 Subject: [PATCH v7 1/6] iio: proximity: rfd77402: Reorder header includes 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: <20260127-b4-rfd77402_v5-v7-1-3e7f2d452da2@gmail.com> References: <20260127-b4-rfd77402_v5-v7-0-3e7f2d452da2@gmail.com> In-Reply-To: <20260127-b4-rfd77402_v5-v7-0-3e7f2d452da2@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: skhan@linuxfoundation.org, david.hunter.linux@gmail.com, raskar.shree97@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Andy Shevchenko X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1769455974; l=791; i=raskar.shree97@gmail.com; s=20260101; h=from:subject:message-id; bh=S7gtwc1iB+CgJhiOpqTwX/EfJ8gcFTrqsLvOeW1favY=; b=bM6G3jW8/2Dp4soyoClWEZX1X1+Rm54+TAc/MdoEkTPJ620fJe45L/T52SXx0CjGcmLaz9nPR jV8Gy+y0p3BA0tfv/ZMbSrracAS0Hzzm4RtSgI/TXpqLonziAKgOI4w X-Developer-Key: i=raskar.shree97@gmail.com; a=ed25519; pk=4m2wXDvY0vlXefvRRzawNcNAif88Cy4XvbLkU6iMG/Y= X-Endpoint-Received: by B4 Relay for raskar.shree97@gmail.com/20260101 with auth_id=589 X-Original-From: Shrikant Raskar Reply-To: raskar.shree97@gmail.com From: Shrikant Raskar Reorder header includes to follow kernel include ordering conventions. Reviewed-by: Andy Shevchenko Signed-off-by: Shrikant Raskar --- drivers/iio/proximity/rfd77402.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/proximity/rfd77402.c b/drivers/iio/proximity/rfd77= 402.c index aff60a3c1a6f..69cc1505b964 100644 --- a/drivers/iio/proximity/rfd77402.c +++ b/drivers/iio/proximity/rfd77402.c @@ -10,9 +10,9 @@ * https://media.digikey.com/pdf/Data%20Sheets/RF%20Digital%20PDFs/RFD7740= 2.pdf */ =20 -#include -#include #include +#include +#include =20 #include =20 --=20 2.43.0 From nobody Sun Feb 8 18:31:30 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 57D3B217723; Mon, 26 Jan 2026 19:32:57 +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=1769455977; cv=none; b=EBSTXwBC56c56kxw/G/vuwB1yyFWr1E/t90KiHxnTPwnGKn2K+YSEdmtk1bQ7dURKg1+YM0Pam155GgpIGgJJboQ+nmCBQ3E85H2cPogZoDArOaq5O87RMPMzAU2u3FbZLoBKe26osjh8fePJ6FfwrSVs8RRJBGpkzI0W8w35lk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769455977; c=relaxed/simple; bh=YRoFlaSObNKoiaRKLIvX+0H6yPlDWAYqMv2+vEKHEew=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eCX69eVcPDWy3kXNoUtWCW3S9k832FzO7QklPED4TyBDkdhOdo19Wq0eehhEen0g1QJ/wYhsZPnRJQfEupsU9x3NOiw585kHdNLPObdy+Ue8mxfDLGeU8lDzIzfdKpkv1mmQV2hi0VhHuw9x1dLjzT/7hRiNQp8RWilGlA0ssJ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z9EKH6Yz; 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="Z9EKH6Yz" Received: by smtp.kernel.org (Postfix) with ESMTPS id 10DCDC19422; Mon, 26 Jan 2026 19:32:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769455977; bh=YRoFlaSObNKoiaRKLIvX+0H6yPlDWAYqMv2+vEKHEew=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Z9EKH6YzeAIac9FnAltNMwelo0mMyBIObejSjcPRKiWklBS5VR/YC6BAecv61mgg8 2nE8XDcShelEXWnp55jH4rtePZq2MkzaagyK+ow9Fo+9ieabRJTX5qNomWh4XTWTyq WjrpP3Swnu7K9z7DenKBhhc/HMsjnMilFT9gTeo/4vGOAMc7Nsh2GYxg7+zqisZV2e K1mgqbcj8hBqvPRCWImlJFP6b43qNKgn9/Muw1k0MSkdnydKlIjKxw+QtEE6qG9FSW doZiICF80LEU9XvnnzyolWKD16ZYf48wpPyHSLhgLZLoPhUI+gW08t8gH6P1/FRRvm ZZVz6N2OezYBw== 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 02280D19515; Mon, 26 Jan 2026 19:32:57 +0000 (UTC) From: Shrikant Raskar via B4 Relay Date: Tue, 27 Jan 2026 01:02:16 +0530 Subject: [PATCH v7 2/6] iio: proximity: rfd77402: Align polling timeout with datasheet 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: <20260127-b4-rfd77402_v5-v7-2-3e7f2d452da2@gmail.com> References: <20260127-b4-rfd77402_v5-v7-0-3e7f2d452da2@gmail.com> In-Reply-To: <20260127-b4-rfd77402_v5-v7-0-3e7f2d452da2@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: skhan@linuxfoundation.org, david.hunter.linux@gmail.com, raskar.shree97@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1769455974; l=667; i=raskar.shree97@gmail.com; s=20260101; h=from:subject:message-id; bh=TaE9gAMSfYWdrqq17KNOJs0YkY1PEqKmG/gPTNBcwIU=; b=CWkUr6w16yGAeDFoPX3hanjbzQ3l9UN8Ao5BJmpx82u+yiJWbcTKshE34IQGcdpwPGlqQ4jyW TUN5z49hnVUC5YtZmGMXe5oB/krpUig4e++bTS8DXSo4aHamujqoshZ X-Developer-Key: i=raskar.shree97@gmail.com; a=ed25519; pk=4m2wXDvY0vlXefvRRzawNcNAif88Cy4XvbLkU6iMG/Y= X-Endpoint-Received: by B4 Relay for raskar.shree97@gmail.com/20260101 with auth_id=589 X-Original-From: Shrikant Raskar Reply-To: raskar.shree97@gmail.com From: Shrikant Raskar Update the polling delay to use a 100 ms timeout, as specified in the RFD77402 datasheet. Signed-off-by: Shrikant Raskar --- drivers/iio/proximity/rfd77402.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/proximity/rfd77402.c b/drivers/iio/proximity/rfd77= 402.c index 69cc1505b964..3e14660a4bb1 100644 --- a/drivers/iio/proximity/rfd77402.c +++ b/drivers/iio/proximity/rfd77402.c @@ -132,7 +132,7 @@ static int rfd77402_measure(struct i2c_client *client) goto err; if (ret & RFD77402_ICSR_RESULT) break; - msleep(20); + msleep(10); } =20 if (tries < 0) { --=20 2.43.0 From nobody Sun Feb 8 18:31:30 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 57E6D229B36; Mon, 26 Jan 2026 19:32:57 +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=1769455977; cv=none; b=QErnZTq8A+0SHDNrSNgzzrrUc82Wysq4w+OPZK8efppzzIyA5n7ERLKn5cL3GfntpxP92eEQUQ4O4vBv+EsV768pWF5N1vshhlsxbtm3LFOlvbljOXkSgW3STXzvKJCwyHIsR2JiNi/Uua8svXkii4Ofu45wBTXcP5+6+ebT1Hc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769455977; c=relaxed/simple; bh=zrUq5ENAi3Z+qXaInwuaEEZHH0IudunLkXOrczIMXE8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ScWQiuW58CfC3P7Xk+WYYkhmww+7POIlM7kG4snVCaFg9zFY3HpsgabHyHug4nNtfX2Pcmmp5LzOhU5h5lR8CeMcwUPeLZKw+eiWNQCU8sIEv4clihZIvjTJ//iB4RQwEkKWZdY1Uss0yTTlPRfL+XuZAMRG3I5PV6m/00EdtHE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Kc4Dp4rU; 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="Kc4Dp4rU" Received: by smtp.kernel.org (Postfix) with ESMTPS id 2560DC2BC87; Mon, 26 Jan 2026 19:32:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769455977; bh=zrUq5ENAi3Z+qXaInwuaEEZHH0IudunLkXOrczIMXE8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Kc4Dp4rUD69ploPqIqucHlbbhutzWSZF5Ts7z1dRkSHCoB6srZTi823ABn069yDib 1kwdVbPbbVRJ7RnQ45hrkDJAZzzOtg38u3+Ezisb2zhMgguMd0GCJY6x9dMGfW+pa6 Vxy0TAIxrmhe7Qak3CdfJRyE8iimHwytiNOOxPPEg2JQX/L+r9KbDscnY6iaoWVngr 9pFOliNLYE4RWedati4RRYeKSMdu8DtNQ5PdfVcWjaw2q0mGEB9rkLPzSdrd8VTOPt m2PGZqJrwFRmPIDXS4C4SMvvcTjykaP5XQyRqFPwTYFGfGjd66d1WlvczjZk5VRIcY YK3C2wpej5Fiw== 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 18CF9D19516; Mon, 26 Jan 2026 19:32:57 +0000 (UTC) From: Shrikant Raskar via B4 Relay Date: Tue, 27 Jan 2026 01:02:17 +0530 Subject: [PATCH v7 3/6] iio: proximity: rfd77402: Use kernel helper for result polling 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: <20260127-b4-rfd77402_v5-v7-3-3e7f2d452da2@gmail.com> References: <20260127-b4-rfd77402_v5-v7-0-3e7f2d452da2@gmail.com> In-Reply-To: <20260127-b4-rfd77402_v5-v7-0-3e7f2d452da2@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: skhan@linuxfoundation.org, david.hunter.linux@gmail.com, raskar.shree97@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1769455974; l=2451; i=raskar.shree97@gmail.com; s=20260101; h=from:subject:message-id; bh=GyqcFmUsAy59m10EhtcPMTwAsyYHutaUajRpRjdu6Ms=; b=+Huqw5P4nCzHOOIQ/ElzXdFHwhrzWHrCzDNxAqiic/8Kg9/mktXpRLmKMC21Vb5buHJEVMRju 3frLnqujykkBBq+tgFIWg+SSP+vo4/sSbECyAolSKtO/zTrjKXSKGMC X-Developer-Key: i=raskar.shree97@gmail.com; a=ed25519; pk=4m2wXDvY0vlXefvRRzawNcNAif88Cy4XvbLkU6iMG/Y= X-Endpoint-Received: by B4 Relay for raskar.shree97@gmail.com/20260101 with auth_id=589 X-Original-From: Shrikant Raskar Reply-To: raskar.shree97@gmail.com From: Shrikant Raskar Replace the manually written polling loop with read_poll_timeout(), the kernel's standard helper for waiting on hardware status.This makes the code easier to read. Move the polling logic into a dedicated helper function, as it will be reused by future updates. Signed-off-by: Shrikant Raskar Reviewed-by: Andy Shevchenko --- drivers/iio/proximity/rfd77402.c | 38 +++++++++++++++++++++++-------------= -- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/iio/proximity/rfd77402.c b/drivers/iio/proximity/rfd77= 402.c index 3e14660a4bb1..6b23fb3bfe1d 100644 --- a/drivers/iio/proximity/rfd77402.c +++ b/drivers/iio/proximity/rfd77402.c @@ -12,6 +12,7 @@ =20 #include #include +#include #include =20 #include @@ -110,10 +111,27 @@ static int rfd77402_set_state(struct i2c_client *clie= nt, u8 state, u16 check) return 0; } =20 -static int rfd77402_measure(struct i2c_client *client) +static int rfd77402_wait_for_result(struct rfd77402_data *data) { + struct i2c_client *client =3D data->client; + int val, ret; + + ret =3D read_poll_timeout(i2c_smbus_read_byte_data, val, + (val < 0) || (val & RFD77402_ICSR_RESULT), + 10 * USEC_PER_MSEC, + 10 * 10 * USEC_PER_MSEC, + false, + client, RFD77402_ICSR); + if (val < 0) + return val; + + return ret; +} + +static int rfd77402_measure(struct rfd77402_data *data) +{ + struct i2c_client *client =3D data->client; int ret; - int tries =3D 10; =20 ret =3D rfd77402_set_state(client, RFD77402_CMD_MCPU_ON, RFD77402_STATUS_MCPU_ON); @@ -126,19 +144,9 @@ static int rfd77402_measure(struct i2c_client *client) if (ret < 0) goto err; =20 - while (tries-- > 0) { - ret =3D i2c_smbus_read_byte_data(client, RFD77402_ICSR); - if (ret < 0) - goto err; - if (ret & RFD77402_ICSR_RESULT) - break; - msleep(10); - } - - if (tries < 0) { - ret =3D -ETIMEDOUT; + ret =3D rfd77402_wait_for_result(data); + if (ret < 0) goto err; - } =20 ret =3D i2c_smbus_read_word_data(client, RFD77402_RESULT_R); if (ret < 0) @@ -168,7 +176,7 @@ static int rfd77402_read_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_RAW: mutex_lock(&data->lock); - ret =3D rfd77402_measure(data->client); + ret =3D rfd77402_measure(data); mutex_unlock(&data->lock); if (ret < 0) return ret; --=20 2.43.0 From nobody Sun Feb 8 18:31:30 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 5D84722A4E1; Mon, 26 Jan 2026 19:32:57 +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=1769455977; cv=none; b=h1gL8tW+S6ucxhf8GnfZAoZM2ZbwPTlEztdETDKAP6iCDZh/pko0UPzj+YzWU6y1QQhDo7r8hQqqQPMa5RG2qPIAk+y4wt8WEnAn1ajuJbUBE1XSGn/CO2+ndE1zfDqxnTPnhEQNMfX96dCjx5T336ct+90y9cKHsqYN1XXIEes= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769455977; c=relaxed/simple; bh=9zO5JxPpwU9Bq+Dt2g2d2UItDDZIf0gZvWrs+ZUdDhw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=T+wxAHBV0Jy1nFdSXW7Y8FfhyPrjSub+sep4bbYDyPN9lEnH0cuttKNC2ryKqbeM9MLy3E8SDO6kWOwS2SQ4H9avDTNDFeakqxIcxbF/kKwxpxNxMw5zut/8G+I3lleqZ5ZimhwcFTVR1fBnqbXUn5PvQ/zLrzpgMAMBBQDgGlU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rSa5HiAF; 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="rSa5HiAF" Received: by smtp.kernel.org (Postfix) with ESMTPS id 37E96C2BC9E; Mon, 26 Jan 2026 19:32:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769455977; bh=9zO5JxPpwU9Bq+Dt2g2d2UItDDZIf0gZvWrs+ZUdDhw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=rSa5HiAFYctZBqwafZ3aaPAOIYPTK9b7H5UCcKWM7Eu0ornSqkBHo+OPdwHqZxweO EmP0bXY6v2WoB/boULIR6aNvRCQGcP9seCYuLnun7NNJjj2bJ9KTxciRRSayAhLgfX JNJqE09E2T3FsdmKF07OgLvo0XKAL92rgCOEfKXb/lwvRQqvbpREMlH3gEjB/VeDny hperuCU9ud2Xvz9fK2OxH+eS1fnGUHyiQawM++zFzqDGMXXO6vhxzlrWHCvLJlKsvs CeDRRsEL46Tve+TSDNZajtREw1vejtqypuuZCONhuQc41yYYWO2BemOn33eMm5zklK NBIsqk06tILzQ== 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 2DD33D19510; Mon, 26 Jan 2026 19:32:57 +0000 (UTC) From: Shrikant Raskar via B4 Relay Date: Tue, 27 Jan 2026 01:02:18 +0530 Subject: [PATCH v7 4/6] iio: proximity: rfd77402: Use devm-managed mutex initialization 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: <20260127-b4-rfd77402_v5-v7-4-3e7f2d452da2@gmail.com> References: <20260127-b4-rfd77402_v5-v7-0-3e7f2d452da2@gmail.com> In-Reply-To: <20260127-b4-rfd77402_v5-v7-0-3e7f2d452da2@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: skhan@linuxfoundation.org, david.hunter.linux@gmail.com, raskar.shree97@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Andy Shevchenko X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1769455974; l=895; i=raskar.shree97@gmail.com; s=20260101; h=from:subject:message-id; bh=O017TADCPm7We8ptZ3sfVe3HpHsX8WgePZRWSMO2cOY=; b=9q2fvQNYPt8+mTL/6LaSpidrj6knnXaEw49OvM6Eb+pllpWrpj7k4fws6wTdVUaJpuZD+T43D JDuQRHZJw+CBlIgilfuL87P5bQ65JSrfW7fD4F8FaG8M4A/3nqlxJgH X-Developer-Key: i=raskar.shree97@gmail.com; a=ed25519; pk=4m2wXDvY0vlXefvRRzawNcNAif88Cy4XvbLkU6iMG/Y= X-Endpoint-Received: by B4 Relay for raskar.shree97@gmail.com/20260101 with auth_id=589 X-Original-From: Shrikant Raskar Reply-To: raskar.shree97@gmail.com From: Shrikant Raskar Use devm_mutex_init() to tie the mutex lifetime to the device and improve debugging when CONFIG_DEBUG_MUTEXES is enabled. Reviewed-by: Andy Shevchenko Signed-off-by: Shrikant Raskar --- drivers/iio/proximity/rfd77402.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/iio/proximity/rfd77402.c b/drivers/iio/proximity/rfd77= 402.c index 6b23fb3bfe1d..a374a7389c33 100644 --- a/drivers/iio/proximity/rfd77402.c +++ b/drivers/iio/proximity/rfd77402.c @@ -283,7 +283,10 @@ static int rfd77402_probe(struct i2c_client *client) =20 data =3D iio_priv(indio_dev); data->client =3D client; - mutex_init(&data->lock); + + ret =3D devm_mutex_init(&client->dev, &data->lock); + if (ret) + return ret; =20 indio_dev->info =3D &rfd77402_info; indio_dev->channels =3D rfd77402_channels; --=20 2.43.0 From nobody Sun Feb 8 18:31:30 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 824C02749C1; Mon, 26 Jan 2026 19:32:57 +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=1769455977; cv=none; b=LVHUEqDNFPJ9WbDOBvp7CK6HiO661WcYTbdgJXGVIXwtk+eCPiv8pZVjQWCB+j/NbjBDk/AjOFbt8kvSV7T1IFKPZZZjRbRR2b5Q5q+cDaBjBSbc5BkGnKGvKj8x1Z4g78D+6Bb337T19ttHfFf6oecL6Kb05RO7YB0nkabz+4s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769455977; c=relaxed/simple; bh=4PtBuP67jDG6cx0eqtotDQ2qzFrmXgxQTJ8ZGnhryIs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kGg8yjg+zrj9Ql/tVLuHOIlGAEyMCGTpA2AYp5Zjvl/Uz8CnLdTHlNzwGIhnM0glw4UOTIDZBFLPSTHN+PRx0PTTxQ/QjohG45jYfqIrQiWVdDiyVs+zI8hh0RRdb1tjgxnWTnFbJrT/sRqsASDOHADPJ6VSsefvXk/GKhrF0DU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=By1233Nr; 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="By1233Nr" Received: by smtp.kernel.org (Postfix) with ESMTPS id 4A318C4AF09; Mon, 26 Jan 2026 19:32:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769455977; bh=4PtBuP67jDG6cx0eqtotDQ2qzFrmXgxQTJ8ZGnhryIs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=By1233NrQxZbF/mfUrRGMVHM4lxNnWnsUmDoba2TDEgvMYyN4U/8SIRwUBS0yf2KP DigzfnufVH39eCmGy2Z352o+JbqfxghHOUgAnxtDvzKyOqG3mbIxSCnXw0gskrtXvJ Pb4I7Wsr0YH06/LDiUJCnv2LeNY5WfSIfyWCFq8COln/US98PgCWmzmQRG5F60oUbv +9IeCcBv8hM+3XKBVUmGSCkpX643Ytnv+TM4X6PyKDGPADgbh7qdut/52ht9VEBjeJ +5qQyqrX0jsKS8OQARWFIyM2dGSBGR8q+1liytL7s40OgUJzblBbMNhjIt6sM6CRZj jx/hPw3bqn/BA== 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 3F220D19517; Mon, 26 Jan 2026 19:32:57 +0000 (UTC) From: Shrikant Raskar via B4 Relay Date: Tue, 27 Jan 2026 01:02:19 +0530 Subject: [PATCH v7 5/6] iio: proximity: rfd77402: Document device private data structure 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: <20260127-b4-rfd77402_v5-v7-5-3e7f2d452da2@gmail.com> References: <20260127-b4-rfd77402_v5-v7-0-3e7f2d452da2@gmail.com> In-Reply-To: <20260127-b4-rfd77402_v5-v7-0-3e7f2d452da2@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: skhan@linuxfoundation.org, david.hunter.linux@gmail.com, raskar.shree97@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Andy Shevchenko X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1769455974; l=906; i=raskar.shree97@gmail.com; s=20260101; h=from:subject:message-id; bh=x84MD8DpzwahLxBpvUlfo99iVRVFury7i1rHYa+sduo=; b=Kp+HUTXxhY7dmoqXgMysY8BD9gNXw8gXihQvmoeORL5P1bDjBhhQeYHPPSnt9tSJtC+Dizqud ZZfSQyXukXPDSbW5cQrxRc1eWdUCYX4gism7Ergh2re313Dhk6ntF6s X-Developer-Key: i=raskar.shree97@gmail.com; a=ed25519; pk=4m2wXDvY0vlXefvRRzawNcNAif88Cy4XvbLkU6iMG/Y= X-Endpoint-Received: by B4 Relay for raskar.shree97@gmail.com/20260101 with auth_id=589 X-Original-From: Shrikant Raskar Reply-To: raskar.shree97@gmail.com From: Shrikant Raskar Add kernel-doc style comments for struct rfd77402_data to describe the purpose of each member. Reviewed-by: Andy Shevchenko Signed-off-by: Shrikant Raskar --- drivers/iio/proximity/rfd77402.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/iio/proximity/rfd77402.c b/drivers/iio/proximity/rfd77= 402.c index a374a7389c33..c29ae9af4a90 100644 --- a/drivers/iio/proximity/rfd77402.c +++ b/drivers/iio/proximity/rfd77402.c @@ -77,9 +77,13 @@ static const struct { {RFD77402_HFCFG_3, 0x45d4}, }; =20 +/** + * struct rfd77402_data - device-specific data for the RFD77402 sensor + * @client: I2C client handle + * @lock: mutex to serialize sensor reads + */ struct rfd77402_data { struct i2c_client *client; - /* Serialize reads from the sensor */ struct mutex lock; }; =20 --=20 2.43.0 From nobody Sun Feb 8 18:31:30 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 7F50327281E; Mon, 26 Jan 2026 19:32:57 +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=1769455977; cv=none; b=ixhTrOb8bIqRxPI8qDszp3EVSGuQdoG1g5KhmxQ28ins1w/9/hgbI03Ir2ruL9fruHs8FFRhUdN3TNmWybMp74VI1HYnPzECSuSIc+QM20FlaLYpCOQbZxY7N2bk2x4xNZlmBuu6gl2+EiZ8E8zcBilXYf0Qil8stylg7CcrEQs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769455977; c=relaxed/simple; bh=KIW8/dKTa1YNKlK58MwInmmKjgMUS2SczSqpAXZtH4A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hdnSZFH3dK2/5g60Hr5QinqUWAUznuOsT9KEl6RYe6WbyQvflYtUZt32O7fSH8VXdJ/4hmX9lEGMoO1ajJj3hZBwO+kbAeNUwGJ8K3GW7dzGVY/cEZP1rv6GDAItognqLaqUhm9l9qW9SjYgBQ6i1llyx7wTDgrlSUHEdvC4KaU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DnOu60tL; 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="DnOu60tL" Received: by smtp.kernel.org (Postfix) with ESMTPS id 5DE5DC2BC86; Mon, 26 Jan 2026 19:32:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769455977; bh=KIW8/dKTa1YNKlK58MwInmmKjgMUS2SczSqpAXZtH4A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=DnOu60tLBuDDNaxPi3r20WL38rLAJkPcvw15iWAKjKH+vGO/JMqa8GiLJAfRtsxeS ovtBYgKA8C9yVaBJMjzlNamzZ6qjH5GsHm6DR6L4afNHGaL3NB3ViMmY4Bb2hhE/OY wj2OQc5oNP1+ezEcWecjLvg58b4E+n6OrtsvVETwGIafHlUYx6vqim6+3KRGYbfib9 7zhZKiE2+R+LWBAkNFmBmiVh3dI5n/l3NUzk2xkzMw2a0IgYUFiRB2uI+53WkygDE4 lgSG3zr5LkRXOFue5x9zekA3pO8LU3C7HXOs8JTm95JZxszLNJY8H8lgFBsmdFVS6Q D7jNZJZAxdwbQ== 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 54E92D19518; Mon, 26 Jan 2026 19:32:57 +0000 (UTC) From: Shrikant Raskar via B4 Relay Date: Tue, 27 Jan 2026 01:02:20 +0530 Subject: [PATCH v7 6/6] iio: proximity: rfd77402: Add interrupt handling support 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: <20260127-b4-rfd77402_v5-v7-6-3e7f2d452da2@gmail.com> References: <20260127-b4-rfd77402_v5-v7-0-3e7f2d452da2@gmail.com> In-Reply-To: <20260127-b4-rfd77402_v5-v7-0-3e7f2d452da2@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: skhan@linuxfoundation.org, david.hunter.linux@gmail.com, raskar.shree97@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1769455974; l=6529; i=raskar.shree97@gmail.com; s=20260101; h=from:subject:message-id; bh=PXRuCHQwhL0RvoseV0P0rP1fSG0LvtG292soIV5X2ZE=; b=HFphvdYoSUNInrvf9j6d4SOGmCHBKv6z0JvGECmHnUj5x1jFFfKXIAkbcVhHMv3qJWqj/hWNn yIToHCuJFAeCBSjJpWl+N1tF11fC0+8/qeX1WtYexXMUPKRKvBdHBmf X-Developer-Key: i=raskar.shree97@gmail.com; a=ed25519; pk=4m2wXDvY0vlXefvRRzawNcNAif88Cy4XvbLkU6iMG/Y= X-Endpoint-Received: by B4 Relay for raskar.shree97@gmail.com/20260101 with auth_id=589 X-Original-From: Shrikant Raskar Reply-To: raskar.shree97@gmail.com From: Shrikant Raskar Add interrupt handling support to enable event-driven data acquisition instead of continuous polling. This improves responsiveness, reduces CPU overhead, and supports low-power operation by allowing the system to remain idle until an interrupt occurs. Signed-off-by: Shrikant Raskar Reviewed-by: Andy Shevchenko --- drivers/iio/proximity/rfd77402.c | 121 +++++++++++++++++++++++++++++++++++= +--- 1 file changed, 113 insertions(+), 8 deletions(-) diff --git a/drivers/iio/proximity/rfd77402.c b/drivers/iio/proximity/rfd77= 402.c index c29ae9af4a90..53dff934d66d 100644 --- a/drivers/iio/proximity/rfd77402.c +++ b/drivers/iio/proximity/rfd77402.c @@ -6,20 +6,28 @@ * * 7-bit I2C slave address 0x4c * - * TODO: interrupt * https://media.digikey.com/pdf/Data%20Sheets/RF%20Digital%20PDFs/RFD7740= 2.pdf */ =20 +#include +#include #include +#include +#include #include +#include #include +#include #include +#include =20 #include =20 #define RFD77402_DRV_NAME "rfd77402" =20 #define RFD77402_ICSR 0x00 /* Interrupt Control Status Register */ +#define RFD77402_ICSR_CLR_CFG BIT(0) +#define RFD77402_ICSR_CLR_TYPE BIT(1) #define RFD77402_ICSR_INT_MODE BIT(2) #define RFD77402_ICSR_INT_POL BIT(3) #define RFD77402_ICSR_RESULT BIT(4) @@ -27,6 +35,12 @@ #define RFD77402_ICSR_H2M_MSG BIT(6) #define RFD77402_ICSR_RESET BIT(7) =20 +#define RFD77402_IER 0x02 +#define RFD77402_IER_RESULT BIT(0) +#define RFD77402_IER_M2H_MSG BIT(1) +#define RFD77402_IER_H2M_MSG BIT(2) +#define RFD77402_IER_RESET BIT(3) + #define RFD77402_CMD_R 0x04 #define RFD77402_CMD_SINGLE 0x01 #define RFD77402_CMD_STANDBY 0x10 @@ -81,10 +95,14 @@ static const struct { * struct rfd77402_data - device-specific data for the RFD77402 sensor * @client: I2C client handle * @lock: mutex to serialize sensor reads + * @completion: completion used for interrupt-driven measurements + * @irq_en: indicates whether interrupt mode is enabled */ struct rfd77402_data { struct i2c_client *client; struct mutex lock; + struct completion completion; + bool irq_en; }; =20 static const struct iio_chan_spec rfd77402_channels[] =3D { @@ -95,6 +113,41 @@ static const struct iio_chan_spec rfd77402_channels[] = =3D { }, }; =20 +static irqreturn_t rfd77402_interrupt_handler(int irq, void *pdata) +{ + struct rfd77402_data *data =3D pdata; + int ret; + + ret =3D i2c_smbus_read_byte_data(data->client, RFD77402_ICSR); + if (ret < 0) + return IRQ_NONE; + + /* Check if the interrupt is from our device */ + if (!(ret & RFD77402_ICSR_RESULT)) + return IRQ_NONE; + + /* Signal completion of measurement */ + complete(&data->completion); + return IRQ_HANDLED; +} + +static int rfd77402_wait_for_irq(struct rfd77402_data *data) +{ + int ret; + + /* + * According to RFD77402 Datasheet v1.8, + * Section 3.1.1 "Single Measure" (Figure: Single Measure Flow Chart), + * the suggested timeout for single measure is 100 ms. + */ + ret =3D wait_for_completion_timeout(&data->completion, + msecs_to_jiffies(100)); + if (ret =3D=3D 0) + return -ETIMEDOUT; + + return 0; +} + static int rfd77402_set_state(struct i2c_client *client, u8 state, u16 che= ck) { int ret; @@ -120,6 +173,11 @@ static int rfd77402_wait_for_result(struct rfd77402_da= ta *data) struct i2c_client *client =3D data->client; int val, ret; =20 + if (data->irq_en) { + reinit_completion(&data->completion); + return rfd77402_wait_for_irq(data); + } + ret =3D read_poll_timeout(i2c_smbus_read_byte_data, val, (val < 0) || (val & RFD77402_ICSR_RESULT), 10 * USEC_PER_MSEC, @@ -200,8 +258,20 @@ static const struct iio_info rfd77402_info =3D { .read_raw =3D rfd77402_read_raw, }; =20 -static int rfd77402_init(struct i2c_client *client) +static int rfd77402_config_irq(struct i2c_client *client, u8 csr, u8 ier) { + int ret; + + ret =3D i2c_smbus_write_byte_data(client, RFD77402_ICSR, csr); + if (ret) + return ret; + + return i2c_smbus_write_byte_data(client, RFD77402_IER, ier); +} + +static int rfd77402_init(struct rfd77402_data *data) +{ + struct i2c_client *client =3D data->client; int ret, i; =20 ret =3D rfd77402_set_state(client, RFD77402_CMD_STANDBY, @@ -209,10 +279,26 @@ static int rfd77402_init(struct i2c_client *client) if (ret < 0) return ret; =20 - /* configure INT pad as push-pull, active low */ - ret =3D i2c_smbus_write_byte_data(client, RFD77402_ICSR, - RFD77402_ICSR_INT_MODE); - if (ret < 0) + if (data->irq_en) { + /* + * Enable interrupt mode: + * - Configure ICSR for auto-clear on read and + * push-pull output + * - Enable "result ready" interrupt in IER + */ + ret =3D rfd77402_config_irq(client, + RFD77402_ICSR_CLR_CFG | + RFD77402_ICSR_INT_MODE, + RFD77402_IER_RESULT); + } else { + /* + * Disable all interrupts: + * - Clear ICSR configuration + * - Disable all interrupts in IER + */ + ret =3D rfd77402_config_irq(client, 0, 0); + } + if (ret) return ret; =20 /* I2C configuration */ @@ -292,13 +378,29 @@ static int rfd77402_probe(struct i2c_client *client) if (ret) return ret; =20 + init_completion(&data->completion); + + if (client->irq > 0) { + ret =3D devm_request_threaded_irq(&client->dev, client->irq, + NULL, rfd77402_interrupt_handler, + IRQF_ONESHOT, + "rfd77402", data); + if (ret) + return ret; + + data->irq_en =3D true; + dev_dbg(&client->dev, "Using interrupt mode\n"); + } else { + dev_dbg(&client->dev, "Using polling mode\n"); + } + indio_dev->info =3D &rfd77402_info; indio_dev->channels =3D rfd77402_channels; indio_dev->num_channels =3D ARRAY_SIZE(rfd77402_channels); indio_dev->name =3D RFD77402_DRV_NAME; indio_dev->modes =3D INDIO_DIRECT_MODE; =20 - ret =3D rfd77402_init(client); + ret =3D rfd77402_init(data); if (ret < 0) return ret; =20 @@ -316,7 +418,10 @@ static int rfd77402_suspend(struct device *dev) =20 static int rfd77402_resume(struct device *dev) { - return rfd77402_init(to_i2c_client(dev)); + struct iio_dev *indio_dev =3D dev_get_drvdata(dev); + struct rfd77402_data *data =3D iio_priv(indio_dev); + + return rfd77402_init(data); } =20 static DEFINE_SIMPLE_DEV_PM_OPS(rfd77402_pm_ops, rfd77402_suspend, --=20 2.43.0