netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] NFC: nxp-nci: check return code of i2c_master_recv()
@ 2022-06-26 19:42 Michael Walle
  2022-06-26 19:42 ` [PATCH 2/2] NFC: nxp-nci: Don't issue a zero length i2c_master_read() Michael Walle
  2022-06-26 19:49 ` [PATCH 1/2] NFC: nxp-nci: check return code of i2c_master_recv() Krzysztof Kozlowski
  0 siblings, 2 replies; 9+ messages in thread
From: Michael Walle @ 2022-06-26 19:42 UTC (permalink / raw)
  To: Charles Gorand, Krzysztof Kozlowski
  Cc: Clément Perrochaud, netdev, linux-kernel, Michael Walle

Check the return code of i2c_master_recv() for actual errors and
propagate it to the caller.

Fixes: 6be88670fc59 ("NFC: nxp-nci_i2c: Add I2C support to NXP NCI driver")
Signed-off-by: Michael Walle <michael@walle.cc>
---
 drivers/nfc/nxp-nci/i2c.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c
index 7e451c10985d..9c80d5a6d56b 100644
--- a/drivers/nfc/nxp-nci/i2c.c
+++ b/drivers/nfc/nxp-nci/i2c.c
@@ -163,7 +163,10 @@ static int nxp_nci_i2c_nci_read(struct nxp_nci_i2c_phy *phy,
 	skb_put_data(*skb, (void *)&header, NCI_CTRL_HDR_SIZE);
 
 	r = i2c_master_recv(client, skb_put(*skb, header.plen), header.plen);
-	if (r != header.plen) {
+	if (r < 0) {
+		nfc_err(&client->dev, "I2C receive error %pe\n", ERR_PTR(r));
+		goto nci_read_exit_free_skb;
+	} else if (r != header.plen) {
 		nfc_err(&client->dev,
 			"Invalid frame payload length: %u (expected %u)\n",
 			r, header.plen);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-06-28  6:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-26 19:42 [PATCH 1/2] NFC: nxp-nci: check return code of i2c_master_recv() Michael Walle
2022-06-26 19:42 ` [PATCH 2/2] NFC: nxp-nci: Don't issue a zero length i2c_master_read() Michael Walle
2022-06-26 19:51   ` Krzysztof Kozlowski
2022-06-26 19:56     ` Michael Walle
2022-06-26 20:02       ` Krzysztof Kozlowski
2022-06-28  5:03   ` Jakub Kicinski
2022-06-28  6:42     ` Michael Walle
2022-06-26 19:49 ` [PATCH 1/2] NFC: nxp-nci: check return code of i2c_master_recv() Krzysztof Kozlowski
2022-06-26 19:55   ` Michael Walle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).