From patchwork Wed Jan 8 10:40:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 3453381 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C5C0E9F2E9 for ; Wed, 8 Jan 2014 10:43:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B238E20122 for ; Wed, 8 Jan 2014 10:43:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 87DCF2010C for ; Wed, 8 Jan 2014 10:42:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756201AbaAHKm1 (ORCPT ); Wed, 8 Jan 2014 05:42:27 -0500 Received: from mga09.intel.com ([134.134.136.24]:8835 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755099AbaAHKlE (ORCPT ); Wed, 8 Jan 2014 05:41:04 -0500 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 08 Jan 2014 02:37:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.95,623,1384329600"; d="scan'208";a="435636588" Received: from blue.fi.intel.com ([10.237.72.156]) by orsmga001.jf.intel.com with ESMTP; 08 Jan 2014 02:40:59 -0800 Received: by blue.fi.intel.com (Postfix, from userid 1004) id 36DFEE0092; Wed, 8 Jan 2014 12:40:57 +0200 (EET) From: Mika Westerberg To: linux-acpi@vger.kernel.org Cc: "Rafael J. Wysocki" , Linus Walleij , Chris Ball , Johannes Berg , Rhyland Klein , Adrian Hunter , Heikki Krogerus , Mathias Nyman , Alexandre Courbot , Rob Landley , Stephen Warren , Thierry Reding , Mika Westerberg , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 2/4] mmc: sdhci-acpi: convert to use GPIO descriptor API Date: Wed, 8 Jan 2014 12:40:55 +0200 Message-Id: <1389177657-29266-3-git-send-email-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1389177657-29266-1-git-send-email-mika.westerberg@linux.intel.com> References: <1389177657-29266-1-git-send-email-mika.westerberg@linux.intel.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The new descriptor based GPIO interface is now the recommended and safer way of using GPIOs from device drivers. Convert the ACPI SDHCI driver to use that interface. Signed-off-by: Mika Westerberg Acked-by: Adrian Hunter Acked-by: Alexandre Courbot Acked-by: Chris Ball --- drivers/mmc/host/sdhci-acpi.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c index ef19874fcd1f..5c86550f83ad 100644 --- a/drivers/mmc/host/sdhci-acpi.c +++ b/drivers/mmc/host/sdhci-acpi.c @@ -31,10 +31,9 @@ #include #include #include -#include +#include #include #include -#include #include #include #include @@ -199,22 +198,23 @@ static irqreturn_t sdhci_acpi_sd_cd(int irq, void *dev_id) return IRQ_HANDLED; } -static int sdhci_acpi_add_own_cd(struct device *dev, int gpio, - struct mmc_host *mmc) +static int sdhci_acpi_add_own_cd(struct device *dev, struct mmc_host *mmc) { + struct gpio_desc *desc; unsigned long flags; int err, irq; - if (gpio < 0) { - err = gpio; + desc = devm_gpiod_get_index(dev, "sd_cd", 0); + if (IS_ERR(desc)) { + err = PTR_ERR(desc); goto out; } - err = devm_gpio_request_one(dev, gpio, GPIOF_DIR_IN, "sd_cd"); + err = gpiod_direction_input(desc); if (err) - goto out; + goto out_free; - irq = gpio_to_irq(gpio); + irq = gpiod_to_irq(desc); if (irq < 0) { err = irq; goto out_free; @@ -228,7 +228,7 @@ static int sdhci_acpi_add_own_cd(struct device *dev, int gpio, return 0; out_free: - devm_gpio_free(dev, gpio); + devm_gpiod_put(dev, desc); out: dev_warn(dev, "failed to setup card detect wake up\n"); return err; @@ -254,7 +254,7 @@ static int sdhci_acpi_probe(struct platform_device *pdev) struct resource *iomem; resource_size_t len; const char *hid; - int err, gpio; + int err; if (acpi_bus_get_device(handle, &device)) return -ENODEV; @@ -279,8 +279,6 @@ static int sdhci_acpi_probe(struct platform_device *pdev) if (IS_ERR(host)) return PTR_ERR(host); - gpio = acpi_get_gpio_by_index(dev, 0, NULL); - c = sdhci_priv(host); c->host = host; c->slot = sdhci_acpi_get_slot(handle, hid); @@ -338,7 +336,7 @@ static int sdhci_acpi_probe(struct platform_device *pdev) goto err_free; if (sdhci_acpi_flag(c, SDHCI_ACPI_SD_CD)) { - if (sdhci_acpi_add_own_cd(dev, gpio, host->mmc)) + if (sdhci_acpi_add_own_cd(dev, host->mmc)) c->use_runtime_pm = false; }