From patchwork Tue Apr 25 22:43:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Greer X-Patchwork-Id: 9699999 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 7962760245 for ; Tue, 25 Apr 2017 22:44:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F84521E5A for ; Tue, 25 Apr 2017 22:44:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6465E2846B; Tue, 25 Apr 2017 22:44:22 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 EF99C21E5A for ; Tue, 25 Apr 2017 22:44:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1953220AbdDYWoU (ORCPT ); Tue, 25 Apr 2017 18:44:20 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:41551 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1953170AbdDYWoA (ORCPT ); Tue, 25 Apr 2017 18:44:00 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id C136421BA7; Tue, 25 Apr 2017 18:43:58 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute3.internal (MEProxy); Tue, 25 Apr 2017 18:43:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=animalcreek.com; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=Hie U0npkbGfrSj8AqGDlr5FQ5I8K63DeYF/boUJjWe0=; b=mX+6WDuPsxaSTKEWSXZ MBF0LyFKmRA+MVj0b6KOAJE/qnkKeL3vUzvv1tIeyPnMy6o0sQdJqhK+VWUmoSY4 q6XP8vnqqn+1BBKPk5se4Ly3tH2clgBUawm7zgHbVYPAo8sK5VziytLDkgw459xJ DY7DXk6jSq4VPzPTj2scSd2A= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=HieU0npkbGfrSj8AqGDlr5FQ5I8K63DeYF/boUJjW e0=; b=qBuGf4zG5bqDX2kJfUDfcj9wEv5Mq5F+zi+chJw8JOBuCzZQ7qyh+F3rb CBMCSevgm0MUT8u1psLAK+S24wPbYM4BJmRTiie6SViKOPEnubof21XLH2GI/7m2 xy6qbljn0d/kwcryUkl5ATrdBT2dY3+lJh0rG1Hi2jpNiu/ppgrXqFJXjaClRKuW czBD7OkgXX5HcvJJeAOW5S5+YGMTOulezQTazXyRBoA9PnBa6uz8H+ENVaUOGYAC CevqJUl1oYjZBJpb+hEfTxamXJ3c6Q3bZtjxmO6O2DcLCflSXFaT7rmTXc7IYmJN Yi78kIKMMkkSHeXSFp5jwi77x5KhA== X-ME-Sender: X-Sasl-enc: 6FNht9f0igi+e8lybx7bJj+bZfX1FpDCvexmBEFh4N/w 1493160238 Received: from blue.animalcreek.com (ip68-2-86-89.ph.ph.cox.net [68.2.86.89]) by mail.messagingengine.com (Postfix) with ESMTPA id 6EEA8241E1; Tue, 25 Apr 2017 18:43:58 -0400 (EDT) Received: from blue.animalcreek.com (localhost [127.0.0.1]) by blue.animalcreek.com (Postfix) with ESMTP id 7DF79A22326; Tue, 25 Apr 2017 15:43:57 -0700 (MST) From: Mark Greer To: Samuel Ortiz Cc: linux-wireless@vger.kernel.org, linux-nfc@lists.01.org, devicetree@vger.kernel.org, Mark Greer Subject: [PATCH v5 8/9] NFC: trf7970a: Convert to descriptor based GPIO interface Date: Tue, 25 Apr 2017 15:43:55 -0700 Message-Id: <20170425224356.11498-9-mgreer@animalcreek.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170425224356.11498-1-mgreer@animalcreek.com> References: <20170425224356.11498-1-mgreer@animalcreek.com> Organization: Animal Creek Technologies, Inc. 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 trf7970a driver uses the deprecated integer-based GPIO consumer interface so convert it to use the new descriptor-based GPIO consumer interface. Signed-off-by: Mark Greer --- drivers/nfc/Kconfig | 2 +- drivers/nfc/trf7970a.c | 61 +++++++++++++++++++++----------------------------- 2 files changed, 26 insertions(+), 37 deletions(-) diff --git a/drivers/nfc/Kconfig b/drivers/nfc/Kconfig index c4208487fadc..b065eb605215 100644 --- a/drivers/nfc/Kconfig +++ b/drivers/nfc/Kconfig @@ -7,7 +7,7 @@ menu "Near Field Communication (NFC) devices" config NFC_TRF7970A tristate "Texas Instruments TRF7970a NFC driver" - depends on SPI && NFC_DIGITAL + depends on SPI && NFC_DIGITAL && GPIOLIB help This option enables the NFC driver for Texas Instruments' TRF7970a device. Such device supports 5 different protocols: ISO14443A, diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c index 5827ad111942..bb777f50b4fb 100644 --- a/drivers/nfc/trf7970a.c +++ b/drivers/nfc/trf7970a.c @@ -20,9 +20,8 @@ #include #include #include -#include +#include #include -#include #include #include @@ -452,8 +451,8 @@ struct trf7970a { u8 tx_cmd; bool issue_eof; bool adjust_resp_len; - int en2_gpio; - int en_gpio; + struct gpio_desc *en_gpiod; + struct gpio_desc *en2_gpiod; struct mutex lock; unsigned int timeout; bool ignore_timeout; @@ -1908,14 +1907,13 @@ static int trf7970a_power_up(struct trf7970a *trf) usleep_range(5000, 6000); - if (!(trf->quirks & TRF7970A_QUIRK_EN2_MUST_STAY_LOW)) { - if (gpio_is_valid(trf->en2_gpio)) { - gpio_set_value(trf->en2_gpio, 1); - usleep_range(1000, 2000); - } + if (trf->en2_gpiod && + !(trf->quirks & TRF7970A_QUIRK_EN2_MUST_STAY_LOW)) { + gpiod_set_value_cansleep(trf->en2_gpiod, 1); + usleep_range(1000, 2000); } - gpio_set_value(trf->en_gpio, 1); + gpiod_set_value_cansleep(trf->en_gpiod, 1); usleep_range(20000, 21000); @@ -1939,11 +1937,11 @@ static int trf7970a_power_down(struct trf7970a *trf) return -EBUSY; } - gpio_set_value(trf->en_gpio, 0); + gpiod_set_value_cansleep(trf->en_gpiod, 0); - if (!(trf->quirks & TRF7970A_QUIRK_EN2_MUST_STAY_LOW)) - if (gpio_is_valid(trf->en2_gpio)) - gpio_set_value(trf->en2_gpio, 0); + if (trf->en2_gpiod && + !(trf->quirks & TRF7970A_QUIRK_EN2_MUST_STAY_LOW)) + gpiod_set_value_cansleep(trf->en2_gpiod, 0); ret = regulator_disable(trf->regulator); if (ret) @@ -2041,32 +2039,23 @@ static int trf7970a_probe(struct spi_device *spi) trf->quirks |= TRF7970A_QUIRK_IRQ_STATUS_READ; /* There are two enable pins - only EN must be present in the DT */ - trf->en_gpio = of_get_named_gpio(np, "ti,enable-gpios", 0); - if (!gpio_is_valid(trf->en_gpio)) { + trf->en_gpiod = devm_gpiod_get_index(trf->dev, "ti,enable", 0, + GPIOD_OUT_LOW); + if (IS_ERR(trf->en_gpiod)) { dev_err(trf->dev, "No EN GPIO property\n"); - return trf->en_gpio; - } - - ret = devm_gpio_request_one(trf->dev, trf->en_gpio, - GPIOF_DIR_OUT | GPIOF_INIT_LOW, "trf7970a EN"); - if (ret) { - dev_err(trf->dev, "Can't request EN GPIO: %d\n", ret); - return ret; + return PTR_ERR(trf->en_gpiod); } - trf->en2_gpio = of_get_named_gpio(np, "ti,enable-gpios", 1); - if (!gpio_is_valid(trf->en2_gpio)) { + trf->en2_gpiod = devm_gpiod_get_index_optional(trf->dev, "ti,enable", 1, + GPIOD_OUT_LOW); + if (!trf->en2_gpiod) { dev_info(trf->dev, "No EN2 GPIO property\n"); - } else { - ret = devm_gpio_request_one(trf->dev, trf->en2_gpio, - GPIOF_DIR_OUT | GPIOF_INIT_LOW, "trf7970a EN2"); - if (ret) { - dev_err(trf->dev, "Can't request EN2 GPIO: %d\n", ret); - return ret; - } - - if (of_property_read_bool(np, "en2-rf-quirk")) - trf->quirks |= TRF7970A_QUIRK_EN2_MUST_STAY_LOW; + } else if (IS_ERR(trf->en2_gpiod)) { + dev_err(trf->dev, "Error getting EN2 GPIO property: %ld\n", + PTR_ERR(trf->en2_gpiod)); + return PTR_ERR(trf->en2_gpiod); + } else if (of_property_read_bool(np, "en2-rf-quirk")) { + trf->quirks |= TRF7970A_QUIRK_EN2_MUST_STAY_LOW; } of_property_read_u32(np, "clock-frequency", &clk_freq);