diff mbox

[v4,2/4] mmc: sdhci-acpi: convert to use GPIO descriptor API

Message ID 1389177657-29266-3-git-send-email-mika.westerberg@linux.intel.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Mika Westerberg Jan. 8, 2014, 10:40 a.m. UTC
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 <mika.westerberg@linux.intel.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
---
 drivers/mmc/host/sdhci-acpi.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

Comments

Linus Walleij Jan. 8, 2014, 11:54 a.m. UTC | #1
On Wed, Jan 8, 2014 at 11:40 AM, Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:

> 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 <mika.westerberg@linux.intel.com>
> Acked-by: Adrian Hunter <adrian.hunter@intel.com>
> Acked-by: Alexandre Courbot <acourbot@nvidia.com>

I've tentatively applied this to the GPIO tree now, as it was acked by
Adrian who is a long time MMC subsystem contributor and we need
it to proceed with the rest of the refactorings.

Chris, beat me up if you're unhappy with this.

(If it explodes in linux-next I'll just back it all out.)

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mika Westerberg Jan. 8, 2014, 12:34 p.m. UTC | #2
On Wed, Jan 08, 2014 at 12:54:13PM +0100, Linus Walleij wrote:
> On Wed, Jan 8, 2014 at 11:40 AM, Mika Westerberg
> <mika.westerberg@linux.intel.com> wrote:
> 
> > 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 <mika.westerberg@linux.intel.com>
> > Acked-by: Adrian Hunter <adrian.hunter@intel.com>
> > Acked-by: Alexandre Courbot <acourbot@nvidia.com>
> 
> I've tentatively applied this to the GPIO tree now, as it was acked by
> Adrian who is a long time MMC subsystem contributor and we need
> it to proceed with the rest of the refactorings.

Thanks!
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chris Ball Jan. 13, 2014, 6:32 p.m. UTC | #3
Hi Linus,

On Wed, Jan 08 2014, Linus Walleij wrote:
> On Wed, Jan 8, 2014 at 11:40 AM, Mika Westerberg
> <mika.westerberg@linux.intel.com> wrote:
>
>> 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 <mika.westerberg@linux.intel.com>
>> Acked-by: Adrian Hunter <adrian.hunter@intel.com>
>> Acked-by: Alexandre Courbot <acourbot@nvidia.com>
>
> I've tentatively applied this to the GPIO tree now, as it was acked by
> Adrian who is a long time MMC subsystem contributor and we need
> it to proceed with the rest of the refactorings.
>
> Chris, beat me up if you're unhappy with this.
>
> (If it explodes in linux-next I'll just back it all out.)

That's fine.  Feel free to add:

Acked-by: Chris Ball <chris@printf.net>

Thanks,

- Chris.
diff mbox

Patch

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 <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/err.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/interrupt.h>
 #include <linux/acpi.h>
-#include <linux/acpi_gpio.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
 #include <linux/delay.h>
@@ -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;
 	}