From patchwork Mon Jul 23 14:00:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 10540353 X-Patchwork-Delegate: sameo@linux.intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BC2761823 for ; Mon, 23 Jul 2018 14:00:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD12928AF3 for ; Mon, 23 Jul 2018 14:00:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A924828AF7; Mon, 23 Jul 2018 14:00:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 533F328AFB for ; Mon, 23 Jul 2018 14:00:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388098AbeGWPBy (ORCPT ); Mon, 23 Jul 2018 11:01:54 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:49872 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388071AbeGWPBy (ORCPT ); Mon, 23 Jul 2018 11:01:54 -0400 Received: from localhost.localdomain (i577BC19A.versanet.de [87.123.193.154]) by mail.bugwerft.de (Postfix) with ESMTPSA id B9A442916AC; Mon, 23 Jul 2018 14:00:06 +0000 (UTC) From: Daniel Mack To: sameo@linux.intel.com Cc: linux-wireless@vger.kernel.org, colin.king@canonical.com, shikha.singh@st.com, Daniel Mack Subject: [PATCH 01/10] Revert "NFC: st95hf: drop illegal kfree_skb()" Date: Mon, 23 Jul 2018 16:00:06 +0200 Message-Id: <20180723140015.11663-2-daniel@zonque.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723140015.11663-1-daniel@zonque.org> References: <20180723140015.11663-1-daniel@zonque.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This reverts commit c99f996b2ba49 ("NFC: st95hf: drop illegal kfree_skb()"). It turns out that the st95hf_in_send_cmd() is in fact the sole owner of this skb, and by not freeing it here, we not only causing a memory leak but also mess up the refcount of the socket that holds it. This will in turn lead to activated targets not being cleaned up, even after stopping userspace processes. The memory corruption that I was hunting was caused by another kfree_skb(). This will be fixed in a later commit. Signed-off-by: Daniel Mack Fixes: c99f996b2ba49 ("NFC: st95hf: drop illegal kfree_skb()") --- drivers/nfc/st95hf/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/nfc/st95hf/core.c b/drivers/nfc/st95hf/core.c index 36ef0e905ba3..bc1a2070f9bb 100644 --- a/drivers/nfc/st95hf/core.c +++ b/drivers/nfc/st95hf/core.c @@ -991,6 +991,8 @@ static int st95hf_in_send_cmd(struct nfc_digital_dev *ddev, goto free_skb_resp; } + kfree_skb(skb); + return rc; free_skb_resp: From patchwork Mon Jul 23 14:00:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 10540355 X-Patchwork-Delegate: sameo@linux.intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1C897157A for ; Mon, 23 Jul 2018 14:00:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E3E428AAE for ; Mon, 23 Jul 2018 14:00:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02E8E28AB1; Mon, 23 Jul 2018 14:00:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38AE128AEB for ; Mon, 23 Jul 2018 14:00:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388116AbeGWPBz (ORCPT ); Mon, 23 Jul 2018 11:01:55 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:49888 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388071AbeGWPBz (ORCPT ); Mon, 23 Jul 2018 11:01:55 -0400 Received: from localhost.localdomain (i577BC19A.versanet.de [87.123.193.154]) by mail.bugwerft.de (Postfix) with ESMTPSA id E40462916AD; Mon, 23 Jul 2018 14:00:08 +0000 (UTC) From: Daniel Mack To: sameo@linux.intel.com Cc: linux-wireless@vger.kernel.org, colin.king@canonical.com, shikha.singh@st.com, Daniel Mack Subject: [PATCH 02/10] NFC: st95hf: drop nfcdev_free Date: Mon, 23 Jul 2018 16:00:07 +0200 Message-Id: <20180723140015.11663-3-daniel@zonque.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723140015.11663-1-daniel@zonque.org> References: <20180723140015.11663-1-daniel@zonque.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This flag is unneccesary. We can just nullify `ddev' instead after we freed it. Signed-off-by: Daniel Mack --- drivers/nfc/st95hf/core.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/nfc/st95hf/core.c b/drivers/nfc/st95hf/core.c index bc1a2070f9bb..d58424ab5c48 100644 --- a/drivers/nfc/st95hf/core.c +++ b/drivers/nfc/st95hf/core.c @@ -220,8 +220,6 @@ struct st95_digital_cmd_complete_arg { * from threaded ISR. Usage of this mutex avoids any race between * deletion of the object from st95hf_remove() and its access from * the threaded ISR. - * @nfcdev_free: flag to have the state of nfc device object. - * [alive | died] * @current_protocol: current nfc protocol. * @current_rf_tech: current rf technology. * @fwi: frame waiting index, received in reply of RATS according to @@ -237,7 +235,6 @@ struct st95hf_context { unsigned char sendrcv_trflag; struct semaphore exchange_lock; struct mutex rm_lock; - bool nfcdev_free; u8 current_protocol; u8 current_rf_tech; int fwi; @@ -820,8 +817,8 @@ static irqreturn_t st95hf_irq_thread_handler(int irq, void *st95hfcontext) goto end; } - /* if stcontext->nfcdev_free is true, it means remove already ran */ - if (stcontext->nfcdev_free) { + /* if stcontext->ddev is %NULL, it means remove already ran */ + if (!stcontext->ddev) { result = -ENODEV; goto end; } @@ -1220,7 +1217,7 @@ static int st95hf_remove(struct spi_device *nfc_spi_dev) nfc_digital_unregister_device(stcontext->ddev); nfc_digital_free_device(stcontext->ddev); - stcontext->nfcdev_free = true; + stcontext->ddev = NULL; mutex_unlock(&stcontext->rm_lock); From patchwork Mon Jul 23 14:00:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 10540357 X-Patchwork-Delegate: sameo@linux.intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 40BDB1823 for ; Mon, 23 Jul 2018 14:00:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3158428A8E for ; Mon, 23 Jul 2018 14:00:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FD9B28AF3; Mon, 23 Jul 2018 14:00:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D23A228A8E for ; Mon, 23 Jul 2018 14:00:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388119AbeGWPB5 (ORCPT ); Mon, 23 Jul 2018 11:01:57 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:49898 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388071AbeGWPB5 (ORCPT ); Mon, 23 Jul 2018 11:01:57 -0400 Received: from localhost.localdomain (i577BC19A.versanet.de [87.123.193.154]) by mail.bugwerft.de (Postfix) with ESMTPSA id 18E8C2916AE; Mon, 23 Jul 2018 14:00:10 +0000 (UTC) From: Daniel Mack To: sameo@linux.intel.com Cc: linux-wireless@vger.kernel.org, colin.king@canonical.com, shikha.singh@st.com, Daniel Mack Subject: [PATCH 03/10] NFC: st95hf: drop illegal kfree_skb() in IRQ handler Date: Mon, 23 Jul 2018 16:00:08 +0200 Message-Id: <20180723140015.11663-4-daniel@zonque.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723140015.11663-1-daniel@zonque.org> References: <20180723140015.11663-1-daniel@zonque.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the error path of the IRQ handler, don't free the skb in flight. The callback in the digital core will do that for us. Doing it from both places causes memory corruptions. Signed-off-by: Daniel Mack --- drivers/nfc/st95hf/core.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/nfc/st95hf/core.c b/drivers/nfc/st95hf/core.c index d58424ab5c48..d857197ec7b2 100644 --- a/drivers/nfc/st95hf/core.c +++ b/drivers/nfc/st95hf/core.c @@ -863,7 +863,6 @@ static irqreturn_t st95hf_irq_thread_handler(int irq, void *st95hfcontext) return IRQ_HANDLED; end: - kfree_skb(skb_resp); wtx = false; cb_arg->rats = false; skb_resp = ERR_PTR(result); From patchwork Mon Jul 23 14:00:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 10540359 X-Patchwork-Delegate: sameo@linux.intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 567891822 for ; Mon, 23 Jul 2018 14:00:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47D3C28A78 for ; Mon, 23 Jul 2018 14:00:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 461F128ADE; Mon, 23 Jul 2018 14:00:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC5B428A7A for ; Mon, 23 Jul 2018 14:00:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388134AbeGWPB7 (ORCPT ); Mon, 23 Jul 2018 11:01:59 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:49910 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388071AbeGWPB7 (ORCPT ); Mon, 23 Jul 2018 11:01:59 -0400 Received: from localhost.localdomain (i577BC19A.versanet.de [87.123.193.154]) by mail.bugwerft.de (Postfix) with ESMTPSA id 688CB2916AF; Mon, 23 Jul 2018 14:00:11 +0000 (UTC) From: Daniel Mack To: sameo@linux.intel.com Cc: linux-wireless@vger.kernel.org, colin.king@canonical.com, shikha.singh@st.com, Daniel Mack Subject: [PATCH 04/10] NFC: st95hf: remove logging from spi functions Date: Mon, 23 Jul 2018 16:00:09 +0200 Message-Id: <20180723140015.11663-5-daniel@zonque.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723140015.11663-1-daniel@zonque.org> References: <20180723140015.11663-1-daniel@zonque.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The callers of these functions already log errors, so there's no need to do it from two places. Signed-off-by: Daniel Mack --- drivers/nfc/st95hf/spi.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/nfc/st95hf/spi.c b/drivers/nfc/st95hf/spi.c index e2d3bbcc8c34..d5894d4546b1 100644 --- a/drivers/nfc/st95hf/spi.c +++ b/drivers/nfc/st95hf/spi.c @@ -47,8 +47,6 @@ int st95hf_spi_send(struct st95hf_spi_context *spicontext, result = spi_sync(spidev, &m); if (result) { - dev_err(&spidev->dev, "error: sending cmd to st95hf using SPI = %d\n", - result); mutex_unlock(&spicontext->spi_lock); return result; } @@ -62,12 +60,10 @@ int st95hf_spi_send(struct st95hf_spi_context *spicontext, result = wait_for_completion_timeout(&spicontext->done, msecs_to_jiffies(1000)); /* check for timeout or success */ - if (!result) { - dev_err(&spidev->dev, "error: response not ready timeout\n"); + if (!result) result = -ETIMEDOUT; - } else { + else result = 0; - } mutex_unlock(&spicontext->spi_lock); @@ -79,7 +75,7 @@ EXPORT_SYMBOL_GPL(st95hf_spi_send); int st95hf_spi_recv_response(struct st95hf_spi_context *spicontext, unsigned char *receivebuff) { - int len = 0; + int ret, len; struct spi_transfer tx_takedata; struct spi_message m; struct spi_device *spidev = spicontext->spidev; @@ -89,8 +85,6 @@ int st95hf_spi_recv_response(struct st95hf_spi_context *spicontext, {.rx_buf = receivebuff, .len = 2, .cs_change = 1,}, }; - int ret = 0; - memset(&tx_takedata, 0x0, sizeof(struct spi_transfer)); mutex_lock(&spicontext->spi_lock); @@ -102,8 +96,6 @@ int st95hf_spi_recv_response(struct st95hf_spi_context *spicontext, ret = spi_sync(spidev, &m); if (ret) { - dev_err(&spidev->dev, "spi_recv_resp, data length error = %d\n", - ret); mutex_unlock(&spicontext->spi_lock); return ret; } @@ -127,11 +119,8 @@ int st95hf_spi_recv_response(struct st95hf_spi_context *spicontext, ret = spi_sync(spidev, &m); mutex_unlock(&spicontext->spi_lock); - if (ret) { - dev_err(&spidev->dev, "spi_recv_resp, data read error = %d\n", - ret); + if (ret) return ret; - } return len; } From patchwork Mon Jul 23 14:00:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 10540361 X-Patchwork-Delegate: sameo@linux.intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9B933157A for ; Mon, 23 Jul 2018 14:00:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88B0F28AC4 for ; Mon, 23 Jul 2018 14:00:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86D5C28AF3; Mon, 23 Jul 2018 14:00:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F378428ADD for ; Mon, 23 Jul 2018 14:00:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388146AbeGWPCA (ORCPT ); Mon, 23 Jul 2018 11:02:00 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:49922 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388123AbeGWPCA (ORCPT ); Mon, 23 Jul 2018 11:02:00 -0400 Received: from localhost.localdomain (i577BC19A.versanet.de [87.123.193.154]) by mail.bugwerft.de (Postfix) with ESMTPSA id AF82C2916A6; Mon, 23 Jul 2018 14:00:12 +0000 (UTC) From: Daniel Mack To: sameo@linux.intel.com Cc: linux-wireless@vger.kernel.org, colin.king@canonical.com, shikha.singh@st.com, Daniel Mack Subject: [PATCH 05/10] NFC: st95hf: remove exchange_lock Date: Mon, 23 Jul 2018 16:00:10 +0200 Message-Id: <20180723140015.11663-6-daniel@zonque.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723140015.11663-1-daniel@zonque.org> References: <20180723140015.11663-1-daniel@zonque.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch removes the exchange_lock sempahore. Its intended function was two-fold: a) Lock the remove() callback of the driver against the ISR, so that the resources only go away after the ISR has finished. This is unnecessary though, because `rm_lock' does that already, in combination with the nullification of `scontext->ddev'. b) Indicate whether a command was sent previously. If the semaphore is found unused in the threaded ISR, an error is reported. This case can be handled much nicer by checking whether `skb_resp' is present in the context. For this, nullify the `skb_resp' pointer in the callback context. Signed-off-by: Daniel Mack --- drivers/nfc/st95hf/core.c | 52 +++++++-------------------------------- 1 file changed, 9 insertions(+), 43 deletions(-) diff --git a/drivers/nfc/st95hf/core.c b/drivers/nfc/st95hf/core.c index d857197ec7b2..6761ab90f68d 100644 --- a/drivers/nfc/st95hf/core.c +++ b/drivers/nfc/st95hf/core.c @@ -214,8 +214,6 @@ struct st95_digital_cmd_complete_arg { * @st95hf_supply: regulator "consumer" for NFC device. * @sendrcv_trflag: last byte of frame send by sendrecv command * of st95hf. This byte contains transmission flag info. - * @exchange_lock: semaphore used for signaling the st95hf_remove - * function that the last outstanding async nfc request is finished. * @rm_lock: mutex for ensuring safe access of nfc digital object * from threaded ISR. Usage of this mutex avoids any race between * deletion of the object from st95hf_remove() and its access from @@ -233,7 +231,6 @@ struct st95hf_context { struct st95_digital_cmd_complete_arg complete_cb_arg; struct regulator *st95hf_supply; unsigned char sendrcv_trflag; - struct semaphore exchange_lock; struct mutex rm_lock; u8 current_protocol; u8 current_rf_tech; @@ -785,29 +782,14 @@ static irqreturn_t st95hf_irq_thread_handler(int irq, void *st95hfcontext) struct st95_digital_cmd_complete_arg *cb_arg; spidevice = &stcontext->spicontext.spidev->dev; + cb_arg = &stcontext->complete_cb_arg; + skb_resp = cb_arg->skb_resp; - /* - * check semaphore, if not down() already, then we don't - * know in which context the ISR is called and surely it - * will be a bug. Note that down() of the semaphore is done - * in the corresponding st95hf_in_send_cmd() and then - * only this ISR should be called. ISR will up() the - * semaphore before leaving. Hence when the ISR is called - * the correct behaviour is down_trylock() should always - * return 1 (indicating semaphore cant be taken and hence no - * change in semaphore count). - * If not, then we up() the semaphore and crash on - * a BUG() ! - */ - if (!down_trylock(&stcontext->exchange_lock)) { - up(&stcontext->exchange_lock); + if (unlikely(!skb_resp)) { WARN(1, "unknown context in ST95HF ISR"); return IRQ_NONE; } - cb_arg = &stcontext->complete_cb_arg; - skb_resp = cb_arg->skb_resp; - mutex_lock(&stcontext->rm_lock); res_len = st95hf_spi_recv_response(&stcontext->spicontext, skb_resp->data); @@ -856,8 +838,13 @@ static irqreturn_t st95hf_irq_thread_handler(int irq, void *st95hfcontext) /* call digital layer callback */ cb_arg->complete_cb(stcontext->ddev, cb_arg->cb_usrarg, skb_resp); + /* + * This skb is now owned by the core layer. + * Make sure not to use it again. + */ + cb_arg->skb_resp = NULL; + /* up the semaphore before returning */ - up(&stcontext->exchange_lock); mutex_unlock(&stcontext->rm_lock); return IRQ_HANDLED; @@ -868,8 +855,6 @@ static irqreturn_t st95hf_irq_thread_handler(int irq, void *st95hfcontext) skb_resp = ERR_PTR(result); /* call of callback with error */ cb_arg->complete_cb(stcontext->ddev, cb_arg->cb_usrarg, skb_resp); - /* up the semaphore before returning */ - up(&stcontext->exchange_lock); mutex_unlock(&stcontext->rm_lock); return IRQ_HANDLED; } @@ -965,25 +950,12 @@ static int st95hf_in_send_cmd(struct nfc_digital_dev *ddev, ddev->curr_protocol == NFC_PROTO_ISO14443) stcontext->complete_cb_arg.rats = true; - /* - * down the semaphore to indicate to remove func that an - * ISR is pending, note that it will not block here in any case. - * If found blocked, it is a BUG! - */ - rc = down_killable(&stcontext->exchange_lock); - if (rc) { - WARN(1, "Semaphore is not found up in st95hf_in_send_cmd\n"); - return rc; - } - rc = st95hf_spi_send(&stcontext->spicontext, skb->data, skb->len, ASYNC); if (rc) { dev_err(&stcontext->nfcdev->dev, "Error %d trying to perform data_exchange", rc); - /* up the semaphore since ISR will never come in this case */ - up(&stcontext->exchange_lock); goto free_skb_resp; } @@ -1104,7 +1076,6 @@ static int st95hf_probe(struct spi_device *nfc_spi_dev) } } - sema_init(&st95context->exchange_lock, 1); init_completion(&spicontext->done); mutex_init(&spicontext->spi_lock); mutex_init(&st95context->rm_lock); @@ -1220,11 +1191,6 @@ static int st95hf_remove(struct spi_device *nfc_spi_dev) mutex_unlock(&stcontext->rm_lock); - /* if last in_send_cmd's ISR is pending, wait for it to finish */ - result = down_killable(&stcontext->exchange_lock); - if (result == -EINTR) - dev_err(&spictx->spidev->dev, "sleep for semaphore interrupted by signal\n"); - /* next reset the ST95HF controller */ result = st95hf_spi_send(&stcontext->spicontext, &reset_cmd, From patchwork Mon Jul 23 14:00:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 10540365 X-Patchwork-Delegate: sameo@linux.intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7390E1822 for ; Mon, 23 Jul 2018 14:00:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63B5928A78 for ; Mon, 23 Jul 2018 14:00:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 624FF28A97; Mon, 23 Jul 2018 14:00:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE50928AE0 for ; Mon, 23 Jul 2018 14:00:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388163AbeGWPCB (ORCPT ); Mon, 23 Jul 2018 11:02:01 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:49930 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388125AbeGWPCA (ORCPT ); Mon, 23 Jul 2018 11:02:00 -0400 Received: from localhost.localdomain (i577BC19A.versanet.de [87.123.193.154]) by mail.bugwerft.de (Postfix) with ESMTPSA id 2A3352916AD; Mon, 23 Jul 2018 14:00:13 +0000 (UTC) From: Daniel Mack To: sameo@linux.intel.com Cc: linux-wireless@vger.kernel.org, colin.king@canonical.com, shikha.singh@st.com, Daniel Mack Subject: [PATCH 06/10] NFC: st95hf: move skb allocation to ISR Date: Mon, 23 Jul 2018 16:00:11 +0200 Message-Id: <20180723140015.11663-7-daniel@zonque.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723140015.11663-1-daniel@zonque.org> References: <20180723140015.11663-1-daniel@zonque.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The driver currently assumes that interrupts can only occur between the time when when a command has been sent to the device and the response to it. This assumption, however, is wrong. The antenna of the chip is likely to catch a lot of environmental noise, and once in a while, the device will latch the interrupt to signal a protocol error, and keep it latched until the response bytes are read from the chip. As the code currently stands, skbs for responses are only prepared when a command is sent, and the ISR bails out early if that wasn't the case. Hence, the interrupt remains latched, and no further communication with device is possible. To fix this, move the call to nfc_alloc_recv_skb() from st95hf_in_send_cmd() to st95hf_irq_thread_handler() so we can always read back the interrupt reason. Signed-off-by: Daniel Mack --- drivers/nfc/st95hf/core.c | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/drivers/nfc/st95hf/core.c b/drivers/nfc/st95hf/core.c index 6761ab90f68d..99f84ddfdfef 100644 --- a/drivers/nfc/st95hf/core.c +++ b/drivers/nfc/st95hf/core.c @@ -196,7 +196,6 @@ static const struct cmd cmd_array[] = { /* st95_digital_cmd_complete_arg stores client context */ struct st95_digital_cmd_complete_arg { - struct sk_buff *skb_resp; nfc_digital_cmd_complete_t complete_cb; void *cb_usrarg; bool rats; @@ -783,12 +782,10 @@ static irqreturn_t st95hf_irq_thread_handler(int irq, void *st95hfcontext) spidevice = &stcontext->spicontext.spidev->dev; cb_arg = &stcontext->complete_cb_arg; - skb_resp = cb_arg->skb_resp; - if (unlikely(!skb_resp)) { - WARN(1, "unknown context in ST95HF ISR"); + skb_resp = nfc_alloc_recv_skb(MAX_RESPONSE_BUFFER_SIZE, GFP_KERNEL); + if (WARN_ON(!skb_resp)) return IRQ_NONE; - } mutex_lock(&stcontext->rm_lock); res_len = st95hf_spi_recv_response(&stcontext->spicontext, @@ -838,12 +835,6 @@ static irqreturn_t st95hf_irq_thread_handler(int irq, void *st95hfcontext) /* call digital layer callback */ cb_arg->complete_cb(stcontext->ddev, cb_arg->cb_usrarg, skb_resp); - /* - * This skb is now owned by the core layer. - * Make sure not to use it again. - */ - cb_arg->skb_resp = NULL; - /* up the semaphore before returning */ mutex_unlock(&stcontext->rm_lock); @@ -913,15 +904,7 @@ static int st95hf_in_send_cmd(struct nfc_digital_dev *ddev, void *arg) { struct st95hf_context *stcontext = nfc_digital_get_drvdata(ddev); - int rc; - struct sk_buff *skb_resp; - int len_data_to_tag = 0; - - skb_resp = nfc_alloc_recv_skb(MAX_RESPONSE_BUFFER_SIZE, GFP_KERNEL); - if (!skb_resp) { - rc = -ENOMEM; - goto error; - } + int rc, len_data_to_tag = 0; switch (stcontext->current_rf_tech) { case NFC_DIGITAL_RF_TECH_106A: @@ -933,8 +916,7 @@ static int st95hf_in_send_cmd(struct nfc_digital_dev *ddev, len_data_to_tag = skb->len; break; default: - rc = -EINVAL; - goto free_skb_resp; + return -EINVAL; } skb_push(skb, 3); @@ -942,7 +924,6 @@ static int st95hf_in_send_cmd(struct nfc_digital_dev *ddev, skb->data[1] = SEND_RECEIVE_CMD; skb->data[2] = len_data_to_tag; - stcontext->complete_cb_arg.skb_resp = skb_resp; stcontext->complete_cb_arg.cb_usrarg = arg; stcontext->complete_cb_arg.complete_cb = cb; @@ -956,17 +937,12 @@ static int st95hf_in_send_cmd(struct nfc_digital_dev *ddev, if (rc) { dev_err(&stcontext->nfcdev->dev, "Error %d trying to perform data_exchange", rc); - goto free_skb_resp; + return rc; } kfree_skb(skb); - return rc; - -free_skb_resp: - kfree_skb(skb_resp); -error: - return rc; + return 0; } /* p2p will be supported in a later release ! */ From patchwork Mon Jul 23 14:00:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 10540363 X-Patchwork-Delegate: sameo@linux.intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 269511823 for ; Mon, 23 Jul 2018 14:00:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13C4C28AA4 for ; Mon, 23 Jul 2018 14:00:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1237C28AF3; Mon, 23 Jul 2018 14:00:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C595228AA4 for ; Mon, 23 Jul 2018 14:00:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388143AbeGWPCA (ORCPT ); Mon, 23 Jul 2018 11:02:00 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:49938 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388127AbeGWPCA (ORCPT ); Mon, 23 Jul 2018 11:02:00 -0400 Received: from localhost.localdomain (i577BC19A.versanet.de [87.123.193.154]) by mail.bugwerft.de (Postfix) with ESMTPSA id 80D9A2916B0; Mon, 23 Jul 2018 14:00:13 +0000 (UTC) From: Daniel Mack To: sameo@linux.intel.com Cc: linux-wireless@vger.kernel.org, colin.king@canonical.com, shikha.singh@st.com, Daniel Mack Subject: [PATCH 07/10] NFC: st95hf: re-order command defines Date: Mon, 23 Jul 2018 16:00:12 +0200 Message-Id: <20180723140015.11663-8-daniel@zonque.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723140015.11663-1-daniel@zonque.org> References: <20180723140015.11663-1-daniel@zonque.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Just a small cleanup to bring the command defines in a numerical order. Signed-off-by: Daniel Mack --- drivers/nfc/st95hf/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/nfc/st95hf/core.c b/drivers/nfc/st95hf/core.c index 99f84ddfdfef..e7ecc57dde8f 100644 --- a/drivers/nfc/st95hf/core.c +++ b/drivers/nfc/st95hf/core.c @@ -45,10 +45,10 @@ /* Command Send Interface */ /* ST95HF_COMMAND_SEND CMD Ids */ -#define ECHO_CMD 0x55 -#define WRITE_REGISTER_CMD 0x9 #define PROTOCOL_SELECT_CMD 0x2 #define SEND_RECEIVE_CMD 0x4 +#define WRITE_REGISTER_CMD 0x9 +#define ECHO_CMD 0x55 /* Select protocol codes */ #define ISO15693_PROTOCOL_CODE 0x1 From patchwork Mon Jul 23 14:00:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 10540369 X-Patchwork-Delegate: sameo@linux.intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3BC74157A for ; Mon, 23 Jul 2018 14:00:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CE5E28B04 for ; Mon, 23 Jul 2018 14:00:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2146328A7E; Mon, 23 Jul 2018 14:00:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9329828A7E for ; Mon, 23 Jul 2018 14:00:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388183AbeGWPCC (ORCPT ); Mon, 23 Jul 2018 11:02:02 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:49942 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388123AbeGWPCC (ORCPT ); Mon, 23 Jul 2018 11:02:02 -0400 Received: from localhost.localdomain (i577BC19A.versanet.de [87.123.193.154]) by mail.bugwerft.de (Postfix) with ESMTPSA id DE2BE2916B1; Mon, 23 Jul 2018 14:00:13 +0000 (UTC) From: Daniel Mack To: sameo@linux.intel.com Cc: linux-wireless@vger.kernel.org, colin.king@canonical.com, shikha.singh@st.com, Daniel Mack Subject: [PATCH 08/10] NFC: st95hf: unify sync/async flags Date: Mon, 23 Jul 2018 16:00:13 +0200 Message-Id: <20180723140015.11663-9-daniel@zonque.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723140015.11663-1-daniel@zonque.org> References: <20180723140015.11663-1-daniel@zonque.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Keep the information whether a command is asynchronous in a boolean flag everywhere in the code. This way, the enum can go away. Signed-off-by: Daniel Mack --- drivers/nfc/st95hf/core.c | 38 ++++++++++++++++---------------------- drivers/nfc/st95hf/spi.c | 12 +++++------- drivers/nfc/st95hf/spi.h | 8 +------- 3 files changed, 22 insertions(+), 36 deletions(-) diff --git a/drivers/nfc/st95hf/core.c b/drivers/nfc/st95hf/core.c index e7ecc57dde8f..835a1e61c817 100644 --- a/drivers/nfc/st95hf/core.c +++ b/drivers/nfc/st95hf/core.c @@ -101,7 +101,7 @@ struct cmd { unsigned char cmd_id; unsigned char no_cmd_params; unsigned char cmd_params[MAX_CMD_PARAMS]; - enum req_type req; + bool is_sync; }; struct param_list { @@ -134,63 +134,62 @@ static const struct cmd cmd_array[] = { .cmd_len = 0x2, .cmd_id = ECHO_CMD, .no_cmd_params = 0, - .req = SYNC, + .is_sync = true, }, [CMD_ISO14443A_CONFIG] = { .cmd_len = 0x7, .cmd_id = WRITE_REGISTER_CMD, .no_cmd_params = 0x4, .cmd_params = {0x3A, 0x00, 0x5A, 0x04}, - .req = SYNC, + .is_sync = true, }, [CMD_ISO14443A_DEMOGAIN] = { .cmd_len = 0x7, .cmd_id = WRITE_REGISTER_CMD, .no_cmd_params = 0x4, .cmd_params = {0x68, 0x01, 0x01, 0xDF}, - .req = SYNC, + .is_sync = true, }, [CMD_ISO14443B_DEMOGAIN] = { .cmd_len = 0x7, .cmd_id = WRITE_REGISTER_CMD, .no_cmd_params = 0x4, .cmd_params = {0x68, 0x01, 0x01, 0x51}, - .req = SYNC, + .is_sync = true, }, [CMD_ISO14443A_PROTOCOL_SELECT] = { .cmd_len = 0x7, .cmd_id = PROTOCOL_SELECT_CMD, .no_cmd_params = 0x4, .cmd_params = {ISO14443A_PROTOCOL_CODE, 0x00, 0x01, 0xA0}, - .req = SYNC, + .is_sync = true, }, [CMD_ISO14443B_PROTOCOL_SELECT] = { .cmd_len = 0x7, .cmd_id = PROTOCOL_SELECT_CMD, .no_cmd_params = 0x4, .cmd_params = {ISO14443B_PROTOCOL_CODE, 0x01, 0x03, 0xFF}, - .req = SYNC, + .is_sync = true, }, [CMD_WTX_RESPONSE] = { .cmd_len = 0x6, .cmd_id = SEND_RECEIVE_CMD, .no_cmd_params = 0x3, .cmd_params = {0xF2, 0x00, TRFLAG_NFCA_STD_FRAME_CRC}, - .req = ASYNC, }, [CMD_FIELD_OFF] = { .cmd_len = 0x5, .cmd_id = PROTOCOL_SELECT_CMD, .no_cmd_params = 0x2, .cmd_params = {0x0, 0x0}, - .req = SYNC, + .is_sync = true, }, [CMD_ISO15693_PROTOCOL_SELECT] = { .cmd_len = 0x5, .cmd_id = PROTOCOL_SELECT_CMD, .no_cmd_params = 0x2, .cmd_params = {ISO15693_PROTOCOL_CODE, 0x0D}, - .req = SYNC, + .is_sync = true, }, }; @@ -279,13 +278,13 @@ static int st95hf_send_recv_cmd(struct st95hf_context *st95context, ret = st95hf_spi_send(&st95context->spicontext, spi_cmd_buffer, cmd_array[cmd].cmd_len, - cmd_array[cmd].req); + cmd_array[cmd].is_sync); if (ret) { dev_err(dev, "st95hf_spi_send failed with error %d\n", ret); return ret; } - if (cmd_array[cmd].req == SYNC && recv_res) { + if (cmd_array[cmd].is_sync && recv_res) { unsigned char st95hf_response_arr[2]; ret = st95hf_spi_recv_response(&st95context->spicontext, @@ -480,10 +479,8 @@ static int st95hf_send_spi_reset_sequence(struct st95hf_context *st95context) int result = 0; unsigned char reset_cmd = ST95HF_COMMAND_RESET; - result = st95hf_spi_send(&st95context->spicontext, - &reset_cmd, - ST95HF_RESET_CMD_LEN, - ASYNC); + result = st95hf_spi_send(&st95context->spicontext, &reset_cmd, + ST95HF_RESET_CMD_LEN, false); if (result) { dev_err(&st95context->spicontext.spidev->dev, "spi reset sequence cmd error = %d", result); @@ -932,8 +929,7 @@ static int st95hf_in_send_cmd(struct nfc_digital_dev *ddev, stcontext->complete_cb_arg.rats = true; rc = st95hf_spi_send(&stcontext->spicontext, skb->data, - skb->len, - ASYNC); + skb->len, false); if (rc) { dev_err(&stcontext->nfcdev->dev, "Error %d trying to perform data_exchange", rc); @@ -1168,10 +1164,8 @@ static int st95hf_remove(struct spi_device *nfc_spi_dev) mutex_unlock(&stcontext->rm_lock); /* next reset the ST95HF controller */ - result = st95hf_spi_send(&stcontext->spicontext, - &reset_cmd, - ST95HF_RESET_CMD_LEN, - ASYNC); + result = st95hf_spi_send(&stcontext->spicontext, &reset_cmd, + ST95HF_RESET_CMD_LEN, false); if (result) { dev_err(&spictx->spidev->dev, "ST95HF reset failed in remove() err = %d\n", result); diff --git a/drivers/nfc/st95hf/spi.c b/drivers/nfc/st95hf/spi.c index d5894d4546b1..ef12ed67343f 100644 --- a/drivers/nfc/st95hf/spi.c +++ b/drivers/nfc/st95hf/spi.c @@ -23,7 +23,7 @@ int st95hf_spi_send(struct st95hf_spi_context *spicontext, unsigned char *buffertx, int datalen, - enum req_type reqtype) + bool is_sync) { struct spi_message m; int result = 0; @@ -35,12 +35,10 @@ int st95hf_spi_send(struct st95hf_spi_context *spicontext, mutex_lock(&spicontext->spi_lock); - if (reqtype == SYNC) { - spicontext->req_issync = true; + spicontext->req_issync = is_sync; + + if (is_sync) reinit_completion(&spicontext->done); - } else { - spicontext->req_issync = false; - } spi_message_init(&m); spi_message_add_tail(&tx_transfer, &m); @@ -52,7 +50,7 @@ int st95hf_spi_send(struct st95hf_spi_context *spicontext, } /* return for asynchronous or no-wait case */ - if (reqtype == ASYNC) { + if (!is_sync) { mutex_unlock(&spicontext->spi_lock); return 0; } diff --git a/drivers/nfc/st95hf/spi.h b/drivers/nfc/st95hf/spi.h index 552d220747cd..ede17eef6ab1 100644 --- a/drivers/nfc/st95hf/spi.h +++ b/drivers/nfc/st95hf/spi.h @@ -44,16 +44,10 @@ struct st95hf_spi_context { struct mutex spi_lock; }; -/* flag to differentiate synchronous & asynchronous spi request */ -enum req_type { - SYNC, - ASYNC, -}; - int st95hf_spi_send(struct st95hf_spi_context *spicontext, unsigned char *buffertx, int datalen, - enum req_type reqtype); + bool is_sync); int st95hf_spi_recv_response(struct st95hf_spi_context *spicontext, unsigned char *receivebuff); From patchwork Mon Jul 23 14:00:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 10540367 X-Patchwork-Delegate: sameo@linux.intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 36989157A for ; Mon, 23 Jul 2018 14:00:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2920F28B04 for ; Mon, 23 Jul 2018 14:00:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D97028AC6; Mon, 23 Jul 2018 14:00:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA04228ACD for ; Mon, 23 Jul 2018 14:00:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388191AbeGWPCD (ORCPT ); Mon, 23 Jul 2018 11:02:03 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:49950 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388125AbeGWPCC (ORCPT ); Mon, 23 Jul 2018 11:02:02 -0400 Received: from localhost.localdomain (i577BC19A.versanet.de [87.123.193.154]) by mail.bugwerft.de (Postfix) with ESMTPSA id 088902916B3; Mon, 23 Jul 2018 14:00:15 +0000 (UTC) From: Daniel Mack To: sameo@linux.intel.com Cc: linux-wireless@vger.kernel.org, colin.king@canonical.com, shikha.singh@st.com, Daniel Mack Subject: [PATCH 09/10] NFC: st95hf: two small style nits Date: Mon, 23 Jul 2018 16:00:14 +0200 Message-Id: <20180723140015.11663-10-daniel@zonque.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723140015.11663-1-daniel@zonque.org> References: <20180723140015.11663-1-daniel@zonque.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Address two minor style issues that I came across while working on the driver. Signed-off-by: Daniel Mack --- drivers/nfc/st95hf/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/nfc/st95hf/core.c b/drivers/nfc/st95hf/core.c index 835a1e61c817..4db3c020921c 100644 --- a/drivers/nfc/st95hf/core.c +++ b/drivers/nfc/st95hf/core.c @@ -662,7 +662,8 @@ static int st95hf_error_handling(struct st95hf_context *stcontext, result = -ETIMEDOUT; else result = -EIO; - return result; + + return result; } /* Check for CRC err only if CRC is present in the tag response */ @@ -844,6 +845,7 @@ static irqreturn_t st95hf_irq_thread_handler(int irq, void *st95hfcontext) /* call of callback with error */ cb_arg->complete_cb(stcontext->ddev, cb_arg->cb_usrarg, skb_resp); mutex_unlock(&stcontext->rm_lock); + return IRQ_HANDLED; } From patchwork Mon Jul 23 14:00:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 10540371 X-Patchwork-Delegate: sameo@linux.intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DD48D157A for ; Mon, 23 Jul 2018 14:00:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCF4E28AC3 for ; Mon, 23 Jul 2018 14:00:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C108328B1E; Mon, 23 Jul 2018 14:00:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F9AA28AC3 for ; Mon, 23 Jul 2018 14:00:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388205AbeGWPCE (ORCPT ); Mon, 23 Jul 2018 11:02:04 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:49964 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388125AbeGWPCE (ORCPT ); Mon, 23 Jul 2018 11:02:04 -0400 Received: from localhost.localdomain (i577BC19A.versanet.de [87.123.193.154]) by mail.bugwerft.de (Postfix) with ESMTPSA id B41DC2916B2; Mon, 23 Jul 2018 14:00:16 +0000 (UTC) From: Daniel Mack To: sameo@linux.intel.com Cc: linux-wireless@vger.kernel.org, colin.king@canonical.com, shikha.singh@st.com, Daniel Mack , devicetree@vger.kernel.org Subject: [PATCH 10/10] NFC: st95hf: add of match table Date: Mon, 23 Jul 2018 16:00:15 +0200 Message-Id: <20180723140015.11663-11-daniel@zonque.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723140015.11663-1-daniel@zonque.org> References: <20180723140015.11663-1-daniel@zonque.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a match table for device tree compatible strings. Interestingly, a document describing the bindings already exists since a while, but users currently reply on the implicit matching in the drivers core. Signed-off-by: Daniel Mack Cc: devicetree@vger.kernel.org --- drivers/nfc/st95hf/core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/nfc/st95hf/core.c b/drivers/nfc/st95hf/core.c index 4db3c020921c..5a01b454fbc4 100644 --- a/drivers/nfc/st95hf/core.c +++ b/drivers/nfc/st95hf/core.c @@ -1012,6 +1012,12 @@ static const struct spi_device_id st95hf_id[] = { }; MODULE_DEVICE_TABLE(spi, st95hf_id); +static const struct of_device_id st95hf_of_match[] = { + { .compatible = "st,st95hf", }, + {} +}; +MODULE_DEVICE_TABLE(of, st95hf_of_match); + static int st95hf_probe(struct spi_device *nfc_spi_dev) { int ret; @@ -1189,6 +1195,7 @@ static struct spi_driver st95hf_driver = { .driver = { .name = "st95hf", .owner = THIS_MODULE, + .of_match_table = st95hf_of_match, }, .id_table = st95hf_id, .probe = st95hf_probe,