bcm63xx: refresh 3.6 patches
[librecmc/librecmc.git] / target / linux / mvebu / patches-3.8 / 006-mmc_mvsdio_use_slot_gpio.patch
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.
7
8 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
9 ---
10  drivers/mmc/host/mvsdio.c |   34 +++++-----------------------------
11  1 file changed, 5 insertions(+), 29 deletions(-)
12
13 --- a/drivers/mmc/host/mvsdio.c
14 +++ b/drivers/mmc/host/mvsdio.c
15 @@ -22,6 +22,7 @@
16  #include <linux/clk.h>
17  #include <linux/gpio.h>
18  #include <linux/mmc/host.h>
19 +#include <linux/mmc/slot-gpio.h>
20  
21  #include <asm/sizes.h>
22  #include <asm/unaligned.h>
23 @@ -54,7 +55,6 @@ struct mvsd_host {
24         int irq;
25         struct clk *clk;
26         int gpio_card_detect;
27 -       int gpio_write_protect;
28  };
29  
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);
33  }
34  
35 -static int mvsd_get_ro(struct mmc_host *mmc)
36 -{
37 -       struct mvsd_host *host = mmc_priv(mmc);
38 -
39 -       if (host->gpio_write_protect)
40 -               return gpio_get_value(host->gpio_write_protect);
41 -
42 -       /*
43 -        * Board doesn't support read only detection; let the mmc core
44 -        * decide what to do.
45 -        */
46 -       return -ENOSYS;
47 -}
48 -
49  static void mvsd_power_up(struct mvsd_host *host)
50  {
51         void __iomem *iobase = host->base;
52 @@ -676,7 +662,7 @@ static void mvsd_set_ios(struct mmc_host
53  
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,
60  };
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;
64  
65 -       if (mvsd_data->gpio_write_protect) {
66 -               ret = gpio_request(mvsd_data->gpio_write_protect,
67 -                                  DRIVER_NAME " wp");
68 -               if (ret == 0) {
69 -                       gpio_direction_input(mvsd_data->gpio_write_protect);
70 -                       host->gpio_write_protect =
71 -                               mvsd_data->gpio_write_protect;
72 -               }
73 -       }
74 +       mmc_gpio_request_ro(mmc, mvsd_data->gpio_write_protect);
75  
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);
81                 }
82 -               if (host->gpio_write_protect)
83 -                       gpio_free(host->gpio_write_protect);
84 +               mmc_gpio_free_ro(mmc);
85                 if (host->base)
86                         iounmap(host->base);
87         }
88 @@ -861,8 +838,7 @@ static int __exit mvsd_remove(struct pla
89                 }
90                 mmc_remove_host(mmc);
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);
97                 iounmap(host->base);