Skip to content

Commit bbf57df

Browse files
linuswstorulf
authored andcommitted
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>
1 parent 43b7358 commit bbf57df

File tree

1 file changed

+5
-23
lines changed

1 file changed

+5
-23
lines changed

drivers/mmc/host/sdhci-sirf.c

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,13 @@
1111
#include <linux/mmc/host.h>
1212
#include <linux/module.h>
1313
#include <linux/of.h>
14-
#include <linux/of_gpio.h>
1514
#include <linux/mmc/slot-gpio.h>
1615
#include "sdhci-pltfm.h"
1716

1817
#define SDHCI_CLK_DELAY_SETTING 0x4C
1918
#define SDHCI_SIRF_8BITBUS BIT(3)
2019
#define SIRF_TUNING_COUNT 16384
2120

22-
struct sdhci_sirf_priv {
23-
int gpio_cd;
24-
};
25-
2621
static void sdhci_sirf_set_bus_width(struct sdhci_host *host, int width)
2722
{
2823
u8 ctrl;
@@ -170,9 +165,7 @@ static int sdhci_sirf_probe(struct platform_device *pdev)
170165
{
171166
struct sdhci_host *host;
172167
struct sdhci_pltfm_host *pltfm_host;
173-
struct sdhci_sirf_priv *priv;
174168
struct clk *clk;
175-
int gpio_cd;
176169
int ret;
177170

178171
clk = devm_clk_get(&pdev->dev, NULL);
@@ -181,19 +174,12 @@ static int sdhci_sirf_probe(struct platform_device *pdev)
181174
return PTR_ERR(clk);
182175
}
183176

184-
if (pdev->dev.of_node)
185-
gpio_cd = of_get_named_gpio(pdev->dev.of_node, "cd-gpios", 0);
186-
else
187-
gpio_cd = -EINVAL;
188-
189-
host = sdhci_pltfm_init(pdev, &sdhci_sirf_pdata, sizeof(struct sdhci_sirf_priv));
177+
host = sdhci_pltfm_init(pdev, &sdhci_sirf_pdata, 0);
190178
if (IS_ERR(host))
191179
return PTR_ERR(host);
192180

193181
pltfm_host = sdhci_priv(host);
194182
pltfm_host->clk = clk;
195-
priv = sdhci_pltfm_priv(pltfm_host);
196-
priv->gpio_cd = gpio_cd;
197183

198184
sdhci_get_of_property(pdev);
199185

@@ -209,15 +195,11 @@ static int sdhci_sirf_probe(struct platform_device *pdev)
209195
* We must request the IRQ after sdhci_add_host(), as the tasklet only
210196
* gets setup in sdhci_add_host() and we oops.
211197
*/
212-
if (gpio_is_valid(priv->gpio_cd)) {
213-
ret = mmc_gpio_request_cd(host->mmc, priv->gpio_cd, 0);
214-
if (ret) {
215-
dev_err(&pdev->dev, "card detect irq request failed: %d\n",
216-
ret);
217-
goto err_request_cd;
218-
}
198+
ret = mmc_gpiod_request_cd(host->mmc, "cd", 0, false, 0, NULL);
199+
if (ret == -EPROBE_DEFER)
200+
goto err_request_cd;
201+
if (!ret)
219202
mmc_gpiod_request_cd_irq(host->mmc);
220-
}
221203

222204
return 0;
223205

0 commit comments

Comments
 (0)