aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia
diff options
context:
space:
mode:
authorMarek Vasut <marek.vasut@gmail.com>2011-01-15 13:11:16 -0500
committerEric Miao <eric.y.miao@gmail.com>2011-03-16 04:32:46 -0400
commite27af7edda008d225ad542c3b6645483683a7e91 (patch)
tree75564362a6b20a98930c9e01594ffda33153e3d6 /drivers/pcmcia
parent235a175c401ab2d79d63f08257acebe1558a0621 (diff)
ARM: pxa: Use gpio arrays in vpac270_pcmcia driver
Use gpio_request_array() / gpio_free_array(), this makes the code cleaner and less error prone. Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r--drivers/pcmcia/pxa2xx_vpac270.c107
1 files changed, 29 insertions, 78 deletions
diff --git a/drivers/pcmcia/pxa2xx_vpac270.c b/drivers/pcmcia/pxa2xx_vpac270.c
index 55627eccee8e..c13f4111e334 100644
--- a/drivers/pcmcia/pxa2xx_vpac270.c
+++ b/drivers/pcmcia/pxa2xx_vpac270.c
@@ -22,6 +22,19 @@
22 22
23#include "soc_common.h" 23#include "soc_common.h"
24 24
25static struct gpio vpac270_pcmcia_gpios[] = {
26 { GPIO84_VPAC270_PCMCIA_CD, GPIOF_IN, "PCMCIA Card Detect" },
27 { GPIO35_VPAC270_PCMCIA_RDY, GPIOF_IN, "PCMCIA Ready" },
28 { GPIO107_VPAC270_PCMCIA_PPEN, GPIOF_INIT_LOW, "PCMCIA PPEN" },
29 { GPIO11_VPAC270_PCMCIA_RESET, GPIOF_INIT_LOW, "PCMCIA Reset" },
30};
31
32static struct gpio vpac270_cf_gpios[] = {
33 { GPIO17_VPAC270_CF_CD, GPIOF_IN, "CF Card Detect" },
34 { GPIO12_VPAC270_CF_RDY, GPIOF_IN, "CF Ready" },
35 { GPIO16_VPAC270_CF_RESET, GPIOF_INIT_LOW, "CF Reset" },
36};
37
25static struct pcmcia_irqs cd_irqs[] = { 38static struct pcmcia_irqs cd_irqs[] = {
26 { 39 {
27 .sock = 0, 40 .sock = 0,
@@ -40,96 +53,34 @@ static int vpac270_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
40 int ret; 53 int ret;
41 54
42 if (skt->nr == 0) { 55 if (skt->nr == 0) {
43 ret = gpio_request(GPIO84_VPAC270_PCMCIA_CD, "PCMCIA CD"); 56 ret = gpio_request_array(vpac270_pcmcia_gpios,
44 if (ret) 57 ARRAY_SIZE(vpac270_pcmcia_gpios));
45 goto err1;
46 ret = gpio_direction_input(GPIO84_VPAC270_PCMCIA_CD);
47 if (ret)
48 goto err2;
49
50 ret = gpio_request(GPIO35_VPAC270_PCMCIA_RDY, "PCMCIA RDY");
51 if (ret)
52 goto err2;
53 ret = gpio_direction_input(GPIO35_VPAC270_PCMCIA_RDY);
54 if (ret)
55 goto err3;
56
57 ret = gpio_request(GPIO107_VPAC270_PCMCIA_PPEN, "PCMCIA PPEN");
58 if (ret)
59 goto err3;
60 ret = gpio_direction_output(GPIO107_VPAC270_PCMCIA_PPEN, 0);
61 if (ret)
62 goto err4;
63
64 ret = gpio_request(GPIO11_VPAC270_PCMCIA_RESET, "PCMCIA RESET");
65 if (ret)
66 goto err4;
67 ret = gpio_direction_output(GPIO11_VPAC270_PCMCIA_RESET, 0);
68 if (ret)
69 goto err5;
70 58
71 skt->socket.pci_irq = gpio_to_irq(GPIO35_VPAC270_PCMCIA_RDY); 59 skt->socket.pci_irq = gpio_to_irq(GPIO35_VPAC270_PCMCIA_RDY);
72 60
73 return soc_pcmcia_request_irqs(skt, &cd_irqs[0], 1); 61 if (!ret)
74 62 ret = soc_pcmcia_request_irqs(skt, &cd_irqs[0], 1);
75err5:
76 gpio_free(GPIO11_VPAC270_PCMCIA_RESET);
77err4:
78 gpio_free(GPIO107_VPAC270_PCMCIA_PPEN);
79err3:
80 gpio_free(GPIO35_VPAC270_PCMCIA_RDY);
81err2:
82 gpio_free(GPIO84_VPAC270_PCMCIA_CD);
83err1:
84 return ret;
85
86 } else { 63 } else {
87 ret = gpio_request(GPIO17_VPAC270_CF_CD, "CF CD"); 64 ret = gpio_request_array(vpac270_cf_gpios,
88 if (ret) 65 ARRAY_SIZE(vpac270_cf_gpios));
89 goto err6;
90 ret = gpio_direction_input(GPIO17_VPAC270_CF_CD);
91 if (ret)
92 goto err7;
93
94 ret = gpio_request(GPIO12_VPAC270_CF_RDY, "CF RDY");
95 if (ret)
96 goto err7;
97 ret = gpio_direction_input(GPIO12_VPAC270_CF_RDY);
98 if (ret)
99 goto err8;
100
101 ret = gpio_request(GPIO16_VPAC270_CF_RESET, "CF RESET");
102 if (ret)
103 goto err8;
104 ret = gpio_direction_output(GPIO16_VPAC270_CF_RESET, 0);
105 if (ret)
106 goto err9;
107 66
108 skt->socket.pci_irq = gpio_to_irq(GPIO12_VPAC270_CF_RDY); 67 skt->socket.pci_irq = gpio_to_irq(GPIO12_VPAC270_CF_RDY);
109 68
110 return soc_pcmcia_request_irqs(skt, &cd_irqs[1], 1); 69 if (!ret)
111 70 ret = soc_pcmcia_request_irqs(skt, &cd_irqs[1], 1);
112err9:
113 gpio_free(GPIO16_VPAC270_CF_RESET);
114err8:
115 gpio_free(GPIO12_VPAC270_CF_RDY);
116err7:
117 gpio_free(GPIO17_VPAC270_CF_CD);
118err6:
119 return ret;
120
121 } 71 }
72
73 return ret;
122} 74}
123 75
124static void vpac270_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) 76static void vpac270_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
125{ 77{
126 gpio_free(GPIO11_VPAC270_PCMCIA_RESET); 78 if (skt->nr == 0)
127 gpio_free(GPIO107_VPAC270_PCMCIA_PPEN); 79 gpio_request_array(vpac270_pcmcia_gpios,
128 gpio_free(GPIO35_VPAC270_PCMCIA_RDY); 80 ARRAY_SIZE(vpac270_pcmcia_gpios));
129 gpio_free(GPIO84_VPAC270_PCMCIA_CD); 81 else
130 gpio_free(GPIO16_VPAC270_CF_RESET); 82 gpio_request_array(vpac270_cf_gpios,
131 gpio_free(GPIO12_VPAC270_CF_RDY); 83 ARRAY_SIZE(vpac270_cf_gpios));
132 gpio_free(GPIO17_VPAC270_CF_CD);
133} 84}
134 85
135static void vpac270_pcmcia_socket_state(struct soc_pcmcia_socket *skt, 86static void vpac270_pcmcia_socket_state(struct soc_pcmcia_socket *skt,