[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230607170009.9458-3-giorgi.marco.96@disroot.org>
Date: Wed, 7 Jun 2023 19:00:09 +0200
From: Marco Giorgi <giorgi.marco.96@...root.org>
To: netdev@...r.kernel.org
Cc: krzysztof.kozlowski@...aro.org,
u.kleine-koenig@...gutronix.de,
davem@...emloft.net,
michael@...le.cc,
kuba@...nel.org,
linux-kernel@...r.kernel.org,
Marco Giorgi <giorgi.marco.96@...root.org>
Subject: [PATCH RFC net 2/2] nfc: nxp-nci: Fix i2c read on ThinkPad hardware
Read IRQ GPIO value and exit from IRQ if the device is not ready.
Signed-off-by: Marco Giorgi <giorgi.marco.96@...root.org>
---
drivers/nfc/nxp-nci/i2c.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c
index 4ba26a958258..d40a640c64d6 100644
--- a/drivers/nfc/nxp-nci/i2c.c
+++ b/drivers/nfc/nxp-nci/i2c.c
@@ -148,6 +148,16 @@ static int nxp_nci_i2c_nci_read(struct nxp_nci_i2c_phy *phy,
struct i2c_client *client = phy->i2c_dev;
int r;
+ r = gpiod_get_value(phy->gpiod_irq);
+ if (r < 0) {
+ nfc_err(&client->dev, "Error reading IRQ GPIO\n");
+ goto nci_read_exit;
+ }
+ if (r != 1) { /* Device is busy, go out */
+ r = -EBUSY;
+ goto nci_read_exit;
+ }
+
r = i2c_master_recv(client, (u8 *) &header, NCI_CTRL_HDR_SIZE);
if (r < 0) {
goto nci_read_exit;
@@ -226,6 +236,9 @@ static irqreturn_t nxp_nci_i2c_irq_thread_fn(int irq, void *phy_id)
break;
}
+ if (r == -EBUSY) {
+ goto exit_irq_handled;
+ }
if (r == -EREMOTEIO) {
phy->hard_fault = r;
if (info->mode == NXP_NCI_MODE_FW)
--
2.41.0
Powered by blists - more mailing lists