]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mmc: sdhci: sirf: Use the slot GPIO descriptor
authorLinus Walleij <linus.walleij@linaro.org>
Mon, 24 Sep 2018 08:02:33 +0000 (10:02 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 8 Oct 2018 09:40:43 +0000 (11:40 +0200)
This driver is complicating things for no reason: the "cd"
GPIO can easily be retrieved from the device tree if present
using just mmc_gpiod_request_cd(), which will fetch the
descriptor from the device tree using the standard binding
just fine.

If the retrieveal is successful, we also request the IRQ.

As a result the private subdriver data can be removed
entirely.

Cc: Weijun Yang <york.yang@csr.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/sdhci-sirf.c

index 391d52b467ca6685902dd1f5ff228c4ed2700c0b..5eada6f87e608d97d7d156876d376f8f83493729 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/mmc/host.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/of_gpio.h>
 #include <linux/mmc/slot-gpio.h>
 #include "sdhci-pltfm.h"
 
 #define SDHCI_SIRF_8BITBUS BIT(3)
 #define SIRF_TUNING_COUNT 16384
 
-struct sdhci_sirf_priv {
-       int gpio_cd;
-};
-
 static void sdhci_sirf_set_bus_width(struct sdhci_host *host, int width)
 {
        u8 ctrl;
@@ -170,9 +165,7 @@ static int sdhci_sirf_probe(struct platform_device *pdev)
 {
        struct sdhci_host *host;
        struct sdhci_pltfm_host *pltfm_host;
-       struct sdhci_sirf_priv *priv;
        struct clk *clk;
-       int gpio_cd;
        int ret;
 
        clk = devm_clk_get(&pdev->dev, NULL);
@@ -181,19 +174,12 @@ static int sdhci_sirf_probe(struct platform_device *pdev)
                return PTR_ERR(clk);
        }
 
-       if (pdev->dev.of_node)
-               gpio_cd = of_get_named_gpio(pdev->dev.of_node, "cd-gpios", 0);
-       else
-               gpio_cd = -EINVAL;
-
-       host = sdhci_pltfm_init(pdev, &sdhci_sirf_pdata, sizeof(struct sdhci_sirf_priv));
+       host = sdhci_pltfm_init(pdev, &sdhci_sirf_pdata, 0);
        if (IS_ERR(host))
                return PTR_ERR(host);
 
        pltfm_host = sdhci_priv(host);
        pltfm_host->clk = clk;
-       priv = sdhci_pltfm_priv(pltfm_host);
-       priv->gpio_cd = gpio_cd;
 
        sdhci_get_of_property(pdev);
 
@@ -209,15 +195,11 @@ static int sdhci_sirf_probe(struct platform_device *pdev)
         * We must request the IRQ after sdhci_add_host(), as the tasklet only
         * gets setup in sdhci_add_host() and we oops.
         */
-       if (gpio_is_valid(priv->gpio_cd)) {
-               ret = mmc_gpio_request_cd(host->mmc, priv->gpio_cd, 0);
-               if (ret) {
-                       dev_err(&pdev->dev, "card detect irq request failed: %d\n",
-                               ret);
-                       goto err_request_cd;
-               }
+       ret = mmc_gpiod_request_cd(host->mmc, "cd", 0, false, 0, NULL);
+       if (ret == -EPROBE_DEFER)
+               goto err_request_cd;
+       if (!ret)
                mmc_gpiod_request_cd_irq(host->mmc);
-       }
 
        return 0;