linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: sdhci-tegra: convert to use GPIO descriptors
@ 2015-03-30 21:39 Mylene JOSSERAND
  2015-04-01 10:43 ` Alexandre Courbot
  2015-04-01 10:59 ` Ulf Hansson
  0 siblings, 2 replies; 3+ messages in thread
From: Mylene JOSSERAND @ 2015-03-30 21:39 UTC (permalink / raw)
  To: ulf.hansson, swarren, thierry.reding, gnurou, linux-mmc,
	linux-tegra, linux-kernel
  Cc: Mylene JOSSERAND

Modify the driver to handle GPIOs using the descriptor API.

Signed-off-by: Mylene JOSSERAND <josserand.mylene@gmail.com>
---
 drivers/mmc/host/sdhci-tegra.c |   32 ++++++++------------------------
 1 file changed, 8 insertions(+), 24 deletions(-)

diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
index 93834ab..ad28b49 100644
--- a/drivers/mmc/host/sdhci-tegra.c
+++ b/drivers/mmc/host/sdhci-tegra.c
@@ -20,11 +20,10 @@
 #include <linux/io.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
-#include <linux/of_gpio.h>
-#include <linux/gpio.h>
 #include <linux/mmc/card.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/slot-gpio.h>
+#include <linux/gpio/consumer.h>
 
 #include "sdhci-pltfm.h"
 
@@ -49,7 +48,7 @@ struct sdhci_tegra_soc_data {
 
 struct sdhci_tegra {
 	const struct sdhci_tegra_soc_data *soc_data;
-	int power_gpio;
+	struct gpio_desc *power_gpio;
 };
 
 static u16 tegra_sdhci_readw(struct sdhci_host *host, int reg)
@@ -246,17 +245,6 @@ static const struct of_device_id sdhci_tegra_dt_match[] = {
 };
 MODULE_DEVICE_TABLE(of, sdhci_tegra_dt_match);
 
-static int sdhci_tegra_parse_dt(struct device *dev)
-{
-	struct device_node *np = dev->of_node;
-	struct sdhci_host *host = dev_get_drvdata(dev);
-	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
-	struct sdhci_tegra *tegra_host = pltfm_host->priv;
-
-	tegra_host->power_gpio = of_get_named_gpio(np, "power-gpios", 0);
-	return mmc_of_parse(host->mmc);
-}
-
 static int sdhci_tegra_probe(struct platform_device *pdev)
 {
 	const struct of_device_id *match;
@@ -286,19 +274,15 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
 	tegra_host->soc_data = soc_data;
 	pltfm_host->priv = tegra_host;
 
-	rc = sdhci_tegra_parse_dt(&pdev->dev);
+	rc = mmc_of_parse(host->mmc);
 	if (rc)
 		goto err_parse_dt;
 
-	if (gpio_is_valid(tegra_host->power_gpio)) {
-		rc = devm_gpio_request(&pdev->dev, tegra_host->power_gpio,
-				       "sdhci_power");
-		if (rc) {
-			dev_err(mmc_dev(host->mmc),
-				"failed to allocate power gpio\n");
-			goto err_power_req;
-		}
-		gpio_direction_output(tegra_host->power_gpio, 1);
+	tegra_host->power_gpio = devm_gpiod_get_optional(&pdev->dev, "power",
+							 GPIOD_OUT_HIGH);
+	if (IS_ERR(tegra_host->power_gpio)) {
+		rc = PTR_ERR(tegra_host->power_gpio);
+		goto err_power_req;
 	}
 
 	clk = devm_clk_get(mmc_dev(host->mmc), NULL);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mmc: sdhci-tegra: convert to use GPIO descriptors
  2015-03-30 21:39 [PATCH] mmc: sdhci-tegra: convert to use GPIO descriptors Mylene JOSSERAND
@ 2015-04-01 10:43 ` Alexandre Courbot
  2015-04-01 10:59 ` Ulf Hansson
  1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Courbot @ 2015-04-01 10:43 UTC (permalink / raw)
  To: Mylene JOSSERAND
  Cc: Ulf Hansson, Stephen Warren, Thierry Reding, linux-mmc,
	linux-tegra, Linux Kernel Mailing List

On Tue, Mar 31, 2015 at 6:39 AM, Mylene JOSSERAND
<josserand.mylene@gmail.com> wrote:
> Modify the driver to handle GPIOs using the descriptor API.

Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Tested-by: Alexandre Courbot <acourbot@nvidia.com>

Both the eMMC (not using power GPIO) and SD slot (using power GPIO) of
my Jetson are happy with this patch. While reviewing it I also noticed
that it improves error handling: any error returned by
of_get_named_gpio(), including -EPROBE_DEFER, were ignored and and
driver would successfully probe without powering the controller.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mmc: sdhci-tegra: convert to use GPIO descriptors
  2015-03-30 21:39 [PATCH] mmc: sdhci-tegra: convert to use GPIO descriptors Mylene JOSSERAND
  2015-04-01 10:43 ` Alexandre Courbot
@ 2015-04-01 10:59 ` Ulf Hansson
  1 sibling, 0 replies; 3+ messages in thread
From: Ulf Hansson @ 2015-04-01 10:59 UTC (permalink / raw)
  To: Mylene JOSSERAND
  Cc: Stephen Warren, Thierry Reding, Alexandre Courbot, linux-mmc,
	linux-tegra, linux-kernel

On 30 March 2015 at 23:39, Mylene JOSSERAND <josserand.mylene@gmail.com> wrote:
> Modify the driver to handle GPIOs using the descriptor API.
>
> Signed-off-by: Mylene JOSSERAND <josserand.mylene@gmail.com>

Thanks! Applied.

Kind regards
Uffe

> ---
>  drivers/mmc/host/sdhci-tegra.c |   32 ++++++++------------------------
>  1 file changed, 8 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
> index 93834ab..ad28b49 100644
> --- a/drivers/mmc/host/sdhci-tegra.c
> +++ b/drivers/mmc/host/sdhci-tegra.c
> @@ -20,11 +20,10 @@
>  #include <linux/io.h>
>  #include <linux/of.h>
>  #include <linux/of_device.h>
> -#include <linux/of_gpio.h>
> -#include <linux/gpio.h>
>  #include <linux/mmc/card.h>
>  #include <linux/mmc/host.h>
>  #include <linux/mmc/slot-gpio.h>
> +#include <linux/gpio/consumer.h>
>
>  #include "sdhci-pltfm.h"
>
> @@ -49,7 +48,7 @@ struct sdhci_tegra_soc_data {
>
>  struct sdhci_tegra {
>         const struct sdhci_tegra_soc_data *soc_data;
> -       int power_gpio;
> +       struct gpio_desc *power_gpio;
>  };
>
>  static u16 tegra_sdhci_readw(struct sdhci_host *host, int reg)
> @@ -246,17 +245,6 @@ static const struct of_device_id sdhci_tegra_dt_match[] = {
>  };
>  MODULE_DEVICE_TABLE(of, sdhci_tegra_dt_match);
>
> -static int sdhci_tegra_parse_dt(struct device *dev)
> -{
> -       struct device_node *np = dev->of_node;
> -       struct sdhci_host *host = dev_get_drvdata(dev);
> -       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
> -       struct sdhci_tegra *tegra_host = pltfm_host->priv;
> -
> -       tegra_host->power_gpio = of_get_named_gpio(np, "power-gpios", 0);
> -       return mmc_of_parse(host->mmc);
> -}
> -
>  static int sdhci_tegra_probe(struct platform_device *pdev)
>  {
>         const struct of_device_id *match;
> @@ -286,19 +274,15 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
>         tegra_host->soc_data = soc_data;
>         pltfm_host->priv = tegra_host;
>
> -       rc = sdhci_tegra_parse_dt(&pdev->dev);
> +       rc = mmc_of_parse(host->mmc);
>         if (rc)
>                 goto err_parse_dt;
>
> -       if (gpio_is_valid(tegra_host->power_gpio)) {
> -               rc = devm_gpio_request(&pdev->dev, tegra_host->power_gpio,
> -                                      "sdhci_power");
> -               if (rc) {
> -                       dev_err(mmc_dev(host->mmc),
> -                               "failed to allocate power gpio\n");
> -                       goto err_power_req;
> -               }
> -               gpio_direction_output(tegra_host->power_gpio, 1);
> +       tegra_host->power_gpio = devm_gpiod_get_optional(&pdev->dev, "power",
> +                                                        GPIOD_OUT_HIGH);
> +       if (IS_ERR(tegra_host->power_gpio)) {
> +               rc = PTR_ERR(tegra_host->power_gpio);
> +               goto err_power_req;
>         }
>
>         clk = devm_clk_get(mmc_dev(host->mmc), NULL);
> --
> 1.7.10.4
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-01 10:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-30 21:39 [PATCH] mmc: sdhci-tegra: convert to use GPIO descriptors Mylene JOSSERAND
2015-04-01 10:43 ` Alexandre Courbot
2015-04-01 10:59 ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).