Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3153698iog; Mon, 27 Jun 2022 10:13:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t7Q9s9HTlZ5e6H0v2qr3MXaXJIlgwDqw7jKXogdPAxCj6Akx8oRphlA+8+6KnZzfFDb5Kx X-Received: by 2002:a63:7741:0:b0:40c:c3cb:d9bd with SMTP id s62-20020a637741000000b0040cc3cbd9bdmr13257293pgc.581.1656349998599; Mon, 27 Jun 2022 10:13:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656349998; cv=none; d=google.com; s=arc-20160816; b=IDn+lq9nesex+vRAHYgMvUYuoymFF+yJdiKma9xRvZTvljDgu3BI3rSBkNCEoI70NU i7a4ZD0uhcNN/4ZHAX4yxNEJfDa2B8qPPFlpYre404P31nKdnR6PeZE36+iUn1Db72Vx EYvGfyZ1SJ8bfpavn96OfOdqcWYoxpAdebgm1ITt3YjDwaMntPmePf5Nakjl9Uu+Tt7p OU9m1f5K5OV6Uqjl6LbH7hYt5rqn+90EIUxpV1r7EMYbDnXd69OLNVuPeKS1oMap3vBn 0zuOZA9ZF/bJm5MqIEXUn5hfI4KuJkNCxuyhzL/6196Q6k3j7kkNkSBbkl/NyF0AlKPm EVtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=hdSEEfSPwayxYsX2lkz6wJR/gBxqwicuOttb5J8K25U=; b=QI+t60sU+L9uZRT8ARdagCXg9XnSu8HyxMADZJYc6R96oSZgREjTn/6VSqSEDY+KEA wpBmlELhiX1EelQV7616++vyWsRohUaMxDDlQc309no7CA4NR8s8OutRcRLUV/y5VMez 97P2f5Y4PTsGycckm0DzkXIMdWE7mO/jcv42ssl8hWa1uybbg6Fe5XmmEH+jBBjjpeVP 35NhgbS2jtMV1veAXKSYlarIhmLzi/YczMssgsWgdvASfBlLLlfyocjP5+Uy2a2ql7sF 9biwnshPFL67c7tL8W1mNuE0gVvzaZFC28vXAyRqhfEQ7Z446ys8uh1A/aujA2n+mrTM otXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=Z+N8P1Rs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bf24-20020a656d18000000b003fc573fa56dsi17170534pgb.6.2022.06.27.10.13.06; Mon, 27 Jun 2022 10:13:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=Z+N8P1Rs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239781AbiF0RGy (ORCPT + 99 others); Mon, 27 Jun 2022 13:06:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239773AbiF0RGx (ORCPT ); Mon, 27 Jun 2022 13:06:53 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 091D918E07; Mon, 27 Jun 2022 10:06:50 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id EC7C222247; Mon, 27 Jun 2022 19:06:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1656349609; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=hdSEEfSPwayxYsX2lkz6wJR/gBxqwicuOttb5J8K25U=; b=Z+N8P1RsBooq7XLfGMvP2smcldc93s2snh+nCmRRggHy9acquHGhKNK6oixXH+yM8ZMxqs rJsCWtTz1A/gsD5QjwA09PFCj88dRaIisjNHHI1AxirJHBjmzV3vnfh1aNqMB1CzYrgCNl kMd3mNi/O46V6T4P5kx0vOpJDmZLWmA= From: Michael Walle To: Krzysztof Kozlowski Cc: =?UTF-8?q?Cl=C3=A9ment=20Perrochaud?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Walle Subject: [PATCH v2 1/2] NFC: nxp-nci: Don't issue a zero length i2c_master_read() Date: Mon, 27 Jun 2022 19:06:42 +0200 Message-Id: <20220627170643.98239-1-michael@walle.cc> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are packets which doesn't have a payload. In that case, the second i2c_master_read() will have a zero length. But because the NFC controller doesn't have any data left, it will NACK the I2C read and -ENXIO will be returned. In case there is no payload, just skip the second i2c master read. Fixes: 6be88670fc59 ("NFC: nxp-nci_i2c: Add I2C support to NXP NCI driver") Signed-off-by: Michael Walle Reviewed-by: Krzysztof Kozlowski --- changes since v1: - none drivers/nfc/nxp-nci/i2c.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c index 7e451c10985d..e8f3b35afbee 100644 --- a/drivers/nfc/nxp-nci/i2c.c +++ b/drivers/nfc/nxp-nci/i2c.c @@ -162,6 +162,9 @@ static int nxp_nci_i2c_nci_read(struct nxp_nci_i2c_phy *phy, skb_put_data(*skb, (void *)&header, NCI_CTRL_HDR_SIZE); + if (!header.plen) + return 0; + r = i2c_master_recv(client, skb_put(*skb, header.plen), header.plen); if (r != header.plen) { nfc_err(&client->dev, -- 2.30.2