Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753062AbcDUOp6 (ORCPT ); Thu, 21 Apr 2016 10:45:58 -0400 Received: from gw.hale.at ([83.64.51.210]:52612 "EHLO gw.hale.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752796AbcDUOow (ORCPT ); Thu, 21 Apr 2016 10:44:52 -0400 X-HALE-Mailborder-Watermark: 1461854686.3971@16/LQVxJe6CrleSkfO/yFQ X-HALE-Mailborder-From: michael.thalmeier@hale.at X-HALE-Mailborder-SpamCheck: not spam, SpamAssassin (zwischen gespeichert, Wertung=-2.899, benoetigt 3, autolearn=not spam, ALL_TRUSTED -1.00, BAYES_00 -1.90, URIBL_BLOCKED 0.00) X-HALE-Mailborder-IP-Protocol: IPv4 X-HALE-Mailborder: Found to be clean X-HALE-Mailborder-ID: 71A4E2C14CE.A9AE6 X-HALE-Mailborder-Information: Please contact your admin for more information From: Michael Thalmeier To: Samuel Ortiz Cc: Lauro Ramos Venancio , Aloisio Almeida Jr , linux-kernel@vger.kernel.org, linux-nfc@ml01.01.org, michael@thalmeier.at Subject: [PATCH 03/11] NFC: pn533: i2c: do not call pn533_recv_frame with aborted commands Date: Thu, 21 Apr 2016 16:43:51 +0200 Message-Id: <1461249839-16962-4-git-send-email-michael.thalmeier@hale.at> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1461249839-16962-1-git-send-email-michael.thalmeier@hale.at> References: <1461249839-16962-1-git-send-email-michael.thalmeier@hale.at> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1758 Lines: 61 When a command gets aborted the pn533 core does not need any RX frames that may be received until a new frame is sent. Signed-off-by: Michael Thalmeier --- drivers/nfc/pn533/i2c.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/nfc/pn533/i2c.c b/drivers/nfc/pn533/i2c.c index 0141f19..1dc89248 100644 --- a/drivers/nfc/pn533/i2c.c +++ b/drivers/nfc/pn533/i2c.c @@ -39,6 +39,8 @@ struct pn533_i2c_phy { struct i2c_client *i2c_dev; struct pn533 *priv; + bool aborted; + int hard_fault; /* * < 0 if hardware error occurred (e.g. i2c err) * and prevents normal operation. @@ -71,6 +73,8 @@ static int pn533_i2c_send_frame(struct pn533 *dev, if (phy->priv == NULL) phy->priv = dev; + phy->aborted = false; + print_hex_dump_debug("PN533_i2c TX: ", DUMP_PREFIX_NONE, 16, 1, out->data, out->len, false); @@ -93,13 +97,15 @@ static int pn533_i2c_send_frame(struct pn533 *dev, static void pn533_i2c_abort_cmd(struct pn533 *dev, gfp_t flags) { + struct pn533_i2c_phy *phy = dev->phy; + + phy->aborted = true; + /* An ack will cancel the last issued command */ pn533_i2c_send_ack(dev, flags); /* schedule cmd_complete_work to finish current command execution */ - if (dev->cmd != NULL) - dev->cmd->status = -ENOENT; - queue_work(dev->wq, &dev->cmd_complete_work); + pn533_recv_frame(phy->priv, NULL, -ENOENT); } static int pn533_i2c_read(struct pn533_i2c_phy *phy, struct sk_buff **skb) @@ -164,7 +170,8 @@ static irqreturn_t pn533_i2c_irq_thread_fn(int irq, void *data) return IRQ_HANDLED; } - pn533_recv_frame(phy->priv, skb, 0); + if (!phy->aborted) + pn533_recv_frame(phy->priv, skb, 0); return IRQ_HANDLED; } -- 2.5.5