From patchwork Sun Jan 22 12:28:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Mc Guire X-Patchwork-Id: 9530949 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.web.codeaurora.org (Postfix) with ESMTP id 288626020B for ; Sun, 22 Jan 2017 12:28:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1883027DC2 for ; Sun, 22 Jan 2017 12:28:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0CDB2283C2; Sun, 22 Jan 2017 12:28:03 +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=-6.9 required=2.0 tests=BAYES_00,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 220BF27DC2 for ; Sun, 22 Jan 2017 12:28:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751665AbdAVM2B (ORCPT ); Sun, 22 Jan 2017 07:28:01 -0500 Received: from www.osadl.org ([62.245.132.105]:32856 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751030AbdAVM17 (ORCPT ); Sun, 22 Jan 2017 07:27:59 -0500 Received: from debian01.hofrr.at (92-243-34-74.adsl.nanet.at [92.243.34.74] (may be forged)) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id v0MCROc2029608; Sun, 22 Jan 2017 13:27:25 +0100 From: Nicholas Mc Guire To: Clement Perrochaud Cc: Charles Gorand , Lauro Ramos Venancio , Aloisio Almeida Jr , Samuel Ortiz , linux-nfc@ml01.01.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire , Nicholas Mc Guire Subject: [PATCH] nfc: nxp-nci: use msleep for long delays Date: Sun, 22 Jan 2017 13:28:39 +0100 Message-Id: <1485088119-17986-1-git-send-email-der.herr@hofr.at> X-Mailer: git-send-email 2.1.4 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 ulseep_range() uses hrtimers and provides no advantage over msleep() for larger delays. For this large delay msleep() is preferable. Fixes: commit 6be88670fc59 ("NFC: nxp-nci_i2c: Add I2C support to NXP NCI driver") Link: http://lkml.org/lkml/2017/1/11/377 Signed-off-by: Nicholas Mc Guire --- Problem was found by cocinelle script. nxp_nci_i2c_write takes the negative return code as indicator that the NFC device was probably in stand-by mode, the first transaction attempt woke it up and that after 110ms latest it would be ready to receive. Overrunning this time by a few milliseconds will not hurt though so msleep() should be fine here. Patch was compile tested with: x86_64_defconfig + CONFIG_NFC=m, CONFIG_NFC_NCI=m, CONFIG_NFC_NXP_NCI=m, CONFIG_NFC_NXP_NCI_I2C=m Patch is against 4.10-rc4 (localversion-next is next-20170120) drivers/nfc/nxp-nci/i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c index 36099e5..ceb815c 100644 --- a/drivers/nfc/nxp-nci/i2c.c +++ b/drivers/nfc/nxp-nci/i2c.c @@ -86,7 +86,7 @@ static int nxp_nci_i2c_write(void *phy_id, struct sk_buff *skb) r = i2c_master_send(client, skb->data, skb->len); if (r < 0) { /* Retry, chip was in standby */ - usleep_range(110000, 120000); + msleep(110); r = i2c_master_send(client, skb->data, skb->len); }