From nobody Mon Feb 9 10:30: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 2289A331A40; Thu, 15 Jan 2026 08:28:14 +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=1768465695; cv=none; b=RxW9ea2PCRA0T8WWCSwTjdmrrePPZD5H+sYtZZsLHLYy1pTiakFxoX6G4hmwi4p7W2gt1q/37VgxxyWpS+7X03be/BJ//jaaPZcVfCfshBwYSslMsSXbWV/8+qm/wgCYT4hqQYJ5efKrB3dtGzXXhT0PM54Dtnw7sYM4mcevO/c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768465695; c=relaxed/simple; bh=pqesYkOyVAJlJuBSd/pYdq0RswcQK/wRmOsqk0CswSk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Z2wJIqwxxLs9IETulSkIQkMWPnzs06RhnkuA0oMzxUYuPRcxxauPQ99Q2ey+y//XIVeaq3d8FToUm7M61genugKtllTD9P/mW9kmUT0dDgemKxmE+ogcY3b6AZ1d9eyErvHwWcXRUSEDkZiXWHjIXirL/vNVH+SPCr+CqtnAwm4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FSCNu5VO; 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="FSCNu5VO" Received: by smtp.kernel.org (Postfix) with ESMTPS id A4616C19424; Thu, 15 Jan 2026 08:28:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768465694; bh=pqesYkOyVAJlJuBSd/pYdq0RswcQK/wRmOsqk0CswSk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=FSCNu5VOPHH+wx/fE+z892jHRBYBXr++YyaylE5SI1OR26u+ntixNuXLmJaYG5FK8 Gt5zj81n5VXJaRO7hDk+ferYSTk6k/FctzGJ28abSk1fLmcyk4mB0U3c5vM9BFU346 983/xp26xW584KZz8GYILRIR+kKiR7IwUaIJuVK8eWOUm5IpzVq0SqDVi4MQbF02DJ y4HNjGEPWDy4HTXW84KFp8ECY5ZRlLTfOwVszhkROO1wIv+sWyCXaWBpONs0Enh8YD HGuRTRdQJ9HlC8YtszdcDCHlEQL9M58PL6tm9mKqAfkvqM3WEsSSS8Cr9bNnBFRGzj 5ykiYyjScIlwA== 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 96D59D31A0B; Thu, 15 Jan 2026 08:28:14 +0000 (UTC) From: Shrikant Raskar via B4 Relay Date: Thu, 15 Jan 2026 13:57:37 +0530 Subject: [PATCH v5 1/5] 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: <20260115-rfd77402_v5-v5-1-594eb57683e4@gmail.com> References: <20260115-rfd77402_v5-v5-0-594eb57683e4@gmail.com> In-Reply-To: <20260115-rfd77402_v5-v5-0-594eb57683e4@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=1768465693; l=731; i=raskar.shree97@gmail.com; s=20260101; h=from:subject:message-id; bh=1WNye2DOeFW/tlwxc8iPRX7QNJxVc1IW/3mxJqW60zY=; b=rrm1rItG1GfzqGT1zVuMewMc/40jeE3cxt9zSturbshZGH8vhfcZjgkEyY+Ur02/SeyS/zKMQ LRboUZUrYK5CFtqtIkCIBCaUWTxDmo+ODTzkcnLZReroatkxH2Pjv9w 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. 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 3262af6f6882..4499939215e7 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 Mon Feb 9 10:30: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 4A26B333752; Thu, 15 Jan 2026 08:28:15 +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=1768465695; cv=none; b=Y72v2wUBwH7gxtJcT8TqA9kc9Ikktlq8p7ud+SVmDbtn3bsBA6ox9oRFWQhFGan25ZhhW7Go2T/AAw1v+fw9BlAJMdZZGTQIoT2/DT+HZlrtPu2S1azjAaqVTFzg4NC5O5rlL/GVQy/D+gWBGeqAwEjSuFtPkAgfsr/w4wmk/mk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768465695; c=relaxed/simple; bh=KPba62IqbsuMVgb2wGwXvzb3M/gVX4dJMynxBAA3LPo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZDPmU1sMigRgbTOT4s6N69zey38QYiGAhnP9jlq/CvjWaitQsj+dzvCPF+pHzaMZRNED558z8/DYNkBWzwLjO1ye3Rd7kX4w4Gy3uRA/X/DKzTmzYsKHEw+1HmhMdUfNMbm0i1M4HSZC7lfYWvGYnOZTdEKmuLcHJAP1JneAB8k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MZ+etE21; 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="MZ+etE21" Received: by smtp.kernel.org (Postfix) with ESMTPS id B015EC19425; Thu, 15 Jan 2026 08:28:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768465694; bh=KPba62IqbsuMVgb2wGwXvzb3M/gVX4dJMynxBAA3LPo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=MZ+etE21wNpL8XZQ7h6oAEglSFipXYVYXcQ9HgUdXIiHqDEYrLD/uvPUDsb+hmXEA IQgUFC5AUS+S1PQai+7dxjcsFLmPx28ASzgPdCH+ukBJ/2Z5TaDXb39hzFX3X9NEQF VvbvP/fvO0ygVnH2ghuuAvByTKMV52lDaI90ya4Dx7cR5RjIOrBx4tqCHXNLYZzFOZ khVH988zCRvOnMDqj4NAppYgemPtY9TEm6G0YgeEe148RSbF12BWZP3YQR6/wLxX6G XOSE76NjEwy+Gvkv9WPnDhyAYr5AXOcI/yIb+635hAUY2PB6H4G/7SRVzZMvDpTkYF pb11+G+4yiNzA== 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 A449CD3CC9F; Thu, 15 Jan 2026 08:28:14 +0000 (UTC) From: Shrikant Raskar via B4 Relay Date: Thu, 15 Jan 2026 13:57:38 +0530 Subject: [PATCH v5 2/5] 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: <20260115-rfd77402_v5-v5-2-594eb57683e4@gmail.com> References: <20260115-rfd77402_v5-v5-0-594eb57683e4@gmail.com> In-Reply-To: <20260115-rfd77402_v5-v5-0-594eb57683e4@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=1768465693; l=2336; i=raskar.shree97@gmail.com; s=20260101; h=from:subject:message-id; bh=LaZ44z8hgRMvbV0yeT+/nj7G5ikDhjSZuco4zkRzSNU=; b=p2RHYl6Q3UQP7UvUpegS5IEklJMs2jFdiZSdUE2+j+s+Hac63yQxUSvKxZCUpHwkVNikVCBIi 4YdXBLhzVN4Coj85CJWiXhfiCw3dFowxCSUo0YOuWmffm63ic+AeXNW 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 and avoids repeating the same polling code in the driver. Signed-off-by: Shrikant Raskar --- drivers/iio/proximity/rfd77402.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/drivers/iio/proximity/rfd77402.c b/drivers/iio/proximity/rfd77= 402.c index 4499939215e7..8c6379bebcc3 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,23 @@ 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 ret; + + return read_poll_timeout(i2c_smbus_read_byte_data, ret, + ret & RFD77402_ICSR_RESULT, + 10 * USEC_PER_MSEC, + 10 * 10 * USEC_PER_MSEC, + false, + client, RFD77402_ICSR); +} + +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 +140,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(20); - } - - 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 +172,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 Mon Feb 9 10:30: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 8FF4E334698; Thu, 15 Jan 2026 08:28:15 +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=1768465695; cv=none; b=rRmMe/qVMz+g3xa4bJZnxGzJaTEkOFrPCnyaNg0Or5Nsz5Da7fVGbdfTUjreLfLfUvWdEwLVoNzi0nleVzQ4KFWhJnatHpSxoTxMV5SriCq4lwTmyjHLcatC+6wRWplxovbhXutWScpN+htU/9+FkIrl0ntNh/jaxrYO7XOdTAs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768465695; c=relaxed/simple; bh=qcVt3Bv5jfMgQ/y4iZfPhQtIVMFB8I5f+l/a4BsqWCY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bg7nPqPKRbrsRCCqN4cAhu6VSIkJPD3324OPqe5vjr3tF/whRBwOE2605tELs6plxU1dAk8Neelsv9ojN7snqxK9mDrZSTUW3r3ZEM8xDl6T4LdZTcD1kRL3BzDIS9D48q7kV6L070mdIBfaPsNM05Ao86uXnmPaGDYirRRcu6Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EFOSpwvU; 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="EFOSpwvU" Received: by smtp.kernel.org (Postfix) with ESMTPS id BBEC8C2BC9E; Thu, 15 Jan 2026 08:28:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768465694; bh=qcVt3Bv5jfMgQ/y4iZfPhQtIVMFB8I5f+l/a4BsqWCY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=EFOSpwvUNDxS5bPbBcpTE+lIzfst+2x5UCrl1ketCouK27oN36840LrbReaB11y5C A0HAZA0r9PczneUCEBd+s8IxpGIaUSU7bPQUOeng6WRuOwI1p1D0Wa1uVlQ5bINk1y wkY8/JD9gn9jmAQSiANdBboEhNL+5LG8ar83nzLxuEtEwqna9Tzf4GWZiRdjbUTZxy CFN1xRBp342jbWd5Lc5s2HmYlAmV+8Ke7xlBLZ53168KGtqpUYJh08I0uGEfrGdqWE H49oHb/L1KEcLu5oEEfBUPPbXTQ9ezj0fotKNNo49Z7D9MQeeYypKiMETi7XGTANDl fEsPqFAPYrsww== 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 B0EBED39010; Thu, 15 Jan 2026 08:28:14 +0000 (UTC) From: Shrikant Raskar via B4 Relay Date: Thu, 15 Jan 2026 13:57:39 +0530 Subject: [PATCH v5 3/5] 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: <20260115-rfd77402_v5-v5-3-594eb57683e4@gmail.com> References: <20260115-rfd77402_v5-v5-0-594eb57683e4@gmail.com> In-Reply-To: <20260115-rfd77402_v5-v5-0-594eb57683e4@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=1768465693; l=5569; i=raskar.shree97@gmail.com; s=20260101; h=from:subject:message-id; bh=C3tD21DVcrSgT7m49qVjA0qq6ip8LRECwCOFJRa5kpU=; b=YzqmiZnqruOfQ4IhPBdUKSBTAUT1KokSQay9Ysl8YoAgUAwWHT/0sBRqpR1J+H4FKvHFLZSRj NYx4X11SAP6AKlGixVoxmANGcuQvQBRGmmreRZsDrhFrThX2Z1F7poB 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 --- drivers/iio/proximity/rfd77402.c | 106 +++++++++++++++++++++++++++++++++++= ++-- 1 file changed, 101 insertions(+), 5 deletions(-) diff --git a/drivers/iio/proximity/rfd77402.c b/drivers/iio/proximity/rfd77= 402.c index 8c6379bebcc3..dd79c9ee838b 100644 --- a/drivers/iio/proximity/rfd77402.c +++ b/drivers/iio/proximity/rfd77402.c @@ -6,12 +6,13 @@ * * 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 =20 @@ -20,6 +21,8 @@ #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 +30,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,6 +90,8 @@ struct rfd77402_data { struct i2c_client *client; /* Serialize reads from the sensor */ struct mutex lock; + struct completion completion; + bool irq_en; }; =20 static const struct iio_chan_spec rfd77402_channels[] =3D { @@ -91,6 +102,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; @@ -116,6 +162,11 @@ static int rfd77402_wait_for_result(struct rfd77402_da= ta *data) struct i2c_client *client =3D data->client; int ret; =20 + if (data->irq_en) { + reinit_completion(&data->completion); + return rfd77402_wait_for_irq(data); + } + return read_poll_timeout(i2c_smbus_read_byte_data, ret, ret & RFD77402_ICSR_RESULT, 10 * USEC_PER_MSEC, @@ -192,8 +243,21 @@ static const struct iio_info rfd77402_info =3D { .read_raw =3D rfd77402_read_raw, }; =20 +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 i2c_client *client) { + struct iio_dev *indio_dev =3D i2c_get_clientdata(client); + struct rfd77402_data *data =3D iio_priv(indio_dev); int ret, i; =20 ret =3D rfd77402_set_state(client, RFD77402_CMD_STANDBY, @@ -201,10 +265,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 */ @@ -280,6 +360,22 @@ static int rfd77402_probe(struct i2c_client *client) data =3D iio_priv(indio_dev); data->client =3D client; mutex_init(&data->lock); + init_completion(&data->completion); + i2c_set_clientdata(client, indio_dev); + + 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"); + } =20 indio_dev->info =3D &rfd77402_info; indio_dev->channels =3D rfd77402_channels; --=20 2.43.0 From nobody Mon Feb 9 10:30: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 8FACC334694; Thu, 15 Jan 2026 08:28:15 +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=1768465695; cv=none; b=HYaNHbOVTJkfy1go86RyJ0Rc9bPpSODuPe7s8jRiagKGn4csQ+xIgVJxB38C34qGAhNsYUmYNtgKAXEYU45dzDcSh63m1yGMi02F1PGypG6m+s/MnEN9pvy5j90ihq2SGI6l10v4ETGTWiOvx35azSuEUkp00ts6LDzuJuQwC5Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768465695; c=relaxed/simple; bh=8KqJ2pAVkZmMUBGEofrU94g2ybwyVL8+Pr16hfWd92M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Lnsae3fxLvswLzNZxYhtbvjeYajcy+n0T/7iKRQSmX2hYGM5FqYsBZwzM3cjz2ihpbzTxNHPpLV6QLxXlc3OiJhIaRHPccz3OTMqIVI6dYz0A5TXQQQCsUBQJ8NmRBKeEsxZQr2pg5VZ5VArBchU5ahS3mlXrTPxMSZ78lXJ/Lc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MzOfft6N; 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="MzOfft6N" Received: by smtp.kernel.org (Postfix) with ESMTPS id C5BB5C2BCAF; Thu, 15 Jan 2026 08:28:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768465694; bh=8KqJ2pAVkZmMUBGEofrU94g2ybwyVL8+Pr16hfWd92M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=MzOfft6NG+dAlVVeFvdsEQNCt5mOIGIcDSX9D+u9N/WgEabo3WMXfGR29nx2zvI9V OdAq61sDB0npM1SYIfs9xWr13TJObGZl+dDs9O5cmwWzw9VXMMsS4Gd4HWim3AdopV 0WpI43jAK/OtnJXErDTHzADSRsrPs6IJTF/35ltdCLwHDHltMX6LTxIhgLhLDuK4Kz kR8FVnBDtnqQwNtV0TC0gslAcn6+F8CmfU/3/HJJygmAHxCShrUgHQ/ycoDHYC29AE 0//8V1dD0sFw+CSvpHT4SBI8ayqYsIP3ce10dAtgj7adoNMQYRI+1l3RG+b4XhiSQZ HneMAKJDWXAWg== 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 BF418D33A02; Thu, 15 Jan 2026 08:28:14 +0000 (UTC) From: Shrikant Raskar via B4 Relay Date: Thu, 15 Jan 2026 13:57:40 +0530 Subject: [PATCH v5 4/5] 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: <20260115-rfd77402_v5-v5-4-594eb57683e4@gmail.com> References: <20260115-rfd77402_v5-v5-0-594eb57683e4@gmail.com> In-Reply-To: <20260115-rfd77402_v5-v5-0-594eb57683e4@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=1768465693; l=818; i=raskar.shree97@gmail.com; s=20260101; h=from:subject:message-id; bh=k49VHFrDJjFFj/mgpbeRdvQKWZLsslBIKwH8rf7C0xA=; b=MXcNHdrkfwXyMt0tXfP3jClJ8j7XUeEIoX8XU60MwpRiDF+eQGxH3/WpDGOi4iVrDowaM4yv5 S89IXle5RaJC6xq67Kwwt1K2+f/7WYeSCJ8s40M6y1izmK+a/SHIOlP 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 simplify resource lifetime management. 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 dd79c9ee838b..43ace2beef7e 100644 --- a/drivers/iio/proximity/rfd77402.c +++ b/drivers/iio/proximity/rfd77402.c @@ -359,7 +359,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; + init_completion(&data->completion); i2c_set_clientdata(client, indio_dev); =20 --=20 2.43.0 From nobody Mon Feb 9 10:30: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 8FEA4334695; Thu, 15 Jan 2026 08:28:15 +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=1768465695; cv=none; b=OhZW/gbzgE4C/OCfY04zqCyNgqvFwjU7q1l6ahh7feGmoiUF1jxUfTSzupwVlPsHyKQhRsc6JMHNjgOLsI8NzyocpenSpfnenRyg4FOLdS44gXjD23a+LsvTEDEBy+tWMe54xh/AXVuoCLaRP9YpruLOhx3nfLCTiEIPX+9B0QE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768465695; c=relaxed/simple; bh=EJQpB8ztvuFwk/JTI9GV2rI0aztC9FlGjnEGKJjdkYM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lNIU1IBJHtTyFoB0R9N9IS7BfGGMx/wEM/RkDWbaYk76WxDgE/UXqt+xQY3OFFrDvEc5E5bXzocBViZLxuYyw1w+Ocl0zWr7TRbmhi84SqIOG0COkyje+P+CSgpnh44jYON9AqX6BW7du17N2FhEWulpgtQ67TtCrjraNJ7kHGI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RfS0Rbfh; 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="RfS0Rbfh" Received: by smtp.kernel.org (Postfix) with ESMTPS id D114AC2BC87; Thu, 15 Jan 2026 08:28:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768465694; bh=EJQpB8ztvuFwk/JTI9GV2rI0aztC9FlGjnEGKJjdkYM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=RfS0RbfhOJalUPD3ROXMAns62t59uoh4bBBg/xCxbHBZ/6/aB3FbwQ1tcofvEqVno xvwcZSIqaVeqOZ8OnKUXG7Exbv86gul4ob48KeoQM6P2F+AAygJIPUIgaIEWq0C5Y2 +FmtTjYQusXJrt4tZp+X+AULaFYQDx2ow7CWwhzg7iOWiv47eoXbnuU1pHPUZBqGfW T/pgy9bvhRMbt8gGgMi6Wj+r3FCoxlvQuh7vyW4sfbiwwvNqxnQSf/SKtHmpQN9HS8 FcrHBxiIrfMvsIiY3WY8mzQhJ43IWpTMxmPcNHLjv+qncGREVYq4KyvTOYsK8KcEBo LDto+rLz23OMQ== 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 CA624D33A01; Thu, 15 Jan 2026 08:28:14 +0000 (UTC) From: Shrikant Raskar via B4 Relay Date: Thu, 15 Jan 2026 13:57:41 +0530 Subject: [PATCH v5 5/5] 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: <20260115-rfd77402_v5-v5-5-594eb57683e4@gmail.com> References: <20260115-rfd77402_v5-v5-0-594eb57683e4@gmail.com> In-Reply-To: <20260115-rfd77402_v5-v5-0-594eb57683e4@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=1768465693; l=1014; i=raskar.shree97@gmail.com; s=20260101; h=from:subject:message-id; bh=syP1cm34ZXh86vqwrGpgNSQse/6+lSSS0BKSNLhKPRA=; b=oibpHuX+teA2H+P/KXELrdZmcO+PBGhxDxww3biLMzBD1aIdbHw6U1NEY9MZsqEadHLne+3vj zhVxhqOzWIBBVRjZsfNJTgub0wKzcXYkEvHRlVJ3NapC+NfFd/5wjSJ 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. Signed-off-by: Shrikant Raskar --- drivers/iio/proximity/rfd77402.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/iio/proximity/rfd77402.c b/drivers/iio/proximity/rfd77= 402.c index 43ace2beef7e..e6a499cfb232 100644 --- a/drivers/iio/proximity/rfd77402.c +++ b/drivers/iio/proximity/rfd77402.c @@ -86,9 +86,15 @@ 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 + * @completion: completion used for interrupt-driven measurements + * @irq_en: indicates whether interrupt mode is enabled + */ struct rfd77402_data { struct i2c_client *client; - /* Serialize reads from the sensor */ struct mutex lock; struct completion completion; bool irq_en; --=20 2.43.0