mmc: sdhci: sirf: Use the slot GPIO descriptor

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>
This commit is contained in:
Linus Walleij 2018-09-24 10:02:33 +02:00 committed by Ulf Hansson
parent 43b7358df6
commit bbf57df817
1 changed files with 5 additions and 23 deletions

View File

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