1 The MMC core subsystem provides in drivers/mmc/core/slot-gpio.c a nice
2 set of helper functions to simplify the management of the write
3 protect GPIO in MMC host drivers. This patch migrates the mvsdio
4 driver to using those helpers, which will make the ->probe() code
5 simpler, and therefore ease the process of adding a Device Tree
6 binding for this driver.
8 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
10 drivers/mmc/host/mvsdio.c | 34 +++++-----------------------------
11 1 file changed, 5 insertions(+), 29 deletions(-)
13 --- a/drivers/mmc/host/mvsdio.c
14 +++ b/drivers/mmc/host/mvsdio.c
16 #include <linux/clk.h>
17 #include <linux/gpio.h>
18 #include <linux/mmc/host.h>
19 +#include <linux/mmc/slot-gpio.h>
21 #include <asm/sizes.h>
22 #include <asm/unaligned.h>
23 @@ -54,7 +55,6 @@ struct mvsd_host {
27 - int gpio_write_protect;
30 #define mvsd_write(offs, val) writel(val, iobase + (offs))
31 @@ -566,20 +566,6 @@ static void mvsd_enable_sdio_irq(struct
32 spin_unlock_irqrestore(&host->lock, flags);
35 -static int mvsd_get_ro(struct mmc_host *mmc)
37 - struct mvsd_host *host = mmc_priv(mmc);
39 - if (host->gpio_write_protect)
40 - return gpio_get_value(host->gpio_write_protect);
43 - * Board doesn't support read only detection; let the mmc core
44 - * decide what to do.
49 static void mvsd_power_up(struct mvsd_host *host)
51 void __iomem *iobase = host->base;
52 @@ -676,7 +662,7 @@ static void mvsd_set_ios(struct mmc_host
54 static const struct mmc_host_ops mvsd_ops = {
55 .request = mvsd_request,
56 - .get_ro = mvsd_get_ro,
57 + .get_ro = mmc_gpio_get_ro,
58 .set_ios = mvsd_set_ios,
59 .enable_sdio_irq = mvsd_enable_sdio_irq,
61 @@ -798,15 +784,7 @@ static int __init mvsd_probe(struct plat
62 if (!host->gpio_card_detect)
63 mmc->caps |= MMC_CAP_NEEDS_POLL;
65 - if (mvsd_data->gpio_write_protect) {
66 - ret = gpio_request(mvsd_data->gpio_write_protect,
69 - gpio_direction_input(mvsd_data->gpio_write_protect);
70 - host->gpio_write_protect =
71 - mvsd_data->gpio_write_protect;
74 + mmc_gpio_request_ro(mmc, mvsd_data->gpio_write_protect);
76 setup_timer(&host->timer, mvsd_timeout_timer, (unsigned long)host);
77 platform_set_drvdata(pdev, mmc);
78 @@ -831,8 +809,7 @@ out:
79 free_irq(gpio_to_irq(host->gpio_card_detect), host);
80 gpio_free(host->gpio_card_detect);
82 - if (host->gpio_write_protect)
83 - gpio_free(host->gpio_write_protect);
84 + mmc_gpio_free_ro(mmc);
88 @@ -861,8 +838,7 @@ static int __exit mvsd_remove(struct pla
91 free_irq(host->irq, host);
92 - if (host->gpio_write_protect)
93 - gpio_free(host->gpio_write_protect);
94 + mmc_gpio_free_ro(mmc);
95 del_timer_sync(&host->timer);
96 mvsd_power_down(host);