aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/telephony
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2008-07-29 02:38:55 -0400
committerDominik Brodowski <linux@dominikbrodowski.net>2008-08-22 19:21:29 -0400
commit84e2d34004dcd0c90d1af43a143511b334f11a4d (patch)
tree1872000f78edc7368d34ebf1211fd8c56d395143 /drivers/telephony
parentb54bf94bf91e4ca2a489eb02bca0424ddb55242a (diff)
pcmcia: use pcmcia_loop_config in misc pcmcia drivers
Use the config loop helper in misc pcmcia drivers. CC: Harald Welte <laforge@gnumonks.org> CC: <linux-parport@lists.infradead.org> CC: Russell King <rmk+kernel@arm.linux.org.uk> CC: Ed Okerson <eokerson@quicknet.net> CC: linux-serial@vger.kernel.org CC: boti@rocketmail.com CC: linux-usb@vger.kernel.org Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/telephony')
-rw-r--r--drivers/telephony/ixj_pcmcia.c76
1 files changed, 34 insertions, 42 deletions
diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c
index ff9a29b76336..89c5e40ce3a0 100644
--- a/drivers/telephony/ixj_pcmcia.c
+++ b/drivers/telephony/ixj_pcmcia.c
@@ -124,65 +124,57 @@ static void ixj_get_serial(struct pcmcia_device * link, IXJ * j)
124 return; 124 return;
125} 125}
126 126
127static int ixj_config_check(struct pcmcia_device *p_dev,
128 cistpl_cftable_entry_t *cfg,
129 void *priv_data)
130{
131 cistpl_cftable_entry_t *dflt = priv_data;
132
133 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
134 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
135 p_dev->conf.ConfigIndex = cfg->index;
136 p_dev->io.BasePort1 = io->win[0].base;
137 p_dev->io.NumPorts1 = io->win[0].len;
138 if (io->nwin == 2) {
139 p_dev->io.BasePort2 = io->win[1].base;
140 p_dev->io.NumPorts2 = io->win[1].len;
141 }
142 if (pcmcia_request_io(p_dev, &p_dev->io)) {
143 if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
144 *dflt = *cfg;
145 } else
146 return 0;
147 }
148 return -ENODEV;
149}
150
127static int ixj_config(struct pcmcia_device * link) 151static int ixj_config(struct pcmcia_device * link)
128{ 152{
129 IXJ *j; 153 IXJ *j;
130 ixj_info_t *info; 154 ixj_info_t *info;
131 tuple_t tuple; 155 cistpl_cftable_entry_t dflt = { 0 };
132 u_short buf[128]; 156
133 cisparse_t parse;
134 cistpl_cftable_entry_t *cfg = &parse.cftable_entry;
135 cistpl_cftable_entry_t dflt =
136 {
137 0
138 };
139 int last_ret, last_fn;
140 info = link->priv; 157 info = link->priv;
141 DEBUG(0, "ixj_config(0x%p)\n", link); 158 DEBUG(0, "ixj_config(0x%p)\n", link);
142 tuple.TupleData = (cisdata_t *) buf;
143 tuple.TupleOffset = 0;
144 tuple.TupleDataMax = 255;
145 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
146 tuple.Attributes = 0;
147 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
148 while (1) {
149 if (pcmcia_get_tuple_data(link, &tuple) != 0 ||
150 pcmcia_parse_tuple(link, &tuple, &parse) != 0)
151 goto next_entry;
152 if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
153 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io;
154 link->conf.ConfigIndex = cfg->index;
155 link->io.BasePort1 = io->win[0].base;
156 link->io.NumPorts1 = io->win[0].len;
157 if (io->nwin == 2) {
158 link->io.BasePort2 = io->win[1].base;
159 link->io.NumPorts2 = io->win[1].len;
160 }
161 if (pcmcia_request_io(link, &link->io) != 0)
162 goto next_entry;
163 /* If we've got this far, we're done */
164 break;
165 }
166 next_entry:
167 if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
168 dflt = *cfg;
169 CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple));
170 }
171 159
172 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 160 if (pcmcia_loop_config(link, ixj_config_check, &dflt))
161 goto cs_failed;
162
163 if (pcmcia_request_configuration(link, &link->conf))
164 goto cs_failed;
173 165
174 /* 166 /*
175 * Register the card with the core. 167 * Register the card with the core.
176 */ 168 */
177 j=ixj_pcmcia_probe(link->io.BasePort1,link->io.BasePort1 + 0x10); 169 j = ixj_pcmcia_probe(link->io.BasePort1, link->io.BasePort1 + 0x10);
178 170
179 info->ndev = 1; 171 info->ndev = 1;
180 info->node.major = PHONE_MAJOR; 172 info->node.major = PHONE_MAJOR;
181 link->dev_node = &info->node; 173 link->dev_node = &info->node;
182 ixj_get_serial(link, j); 174 ixj_get_serial(link, j);
183 return 0; 175 return 0;
176
184 cs_failed: 177 cs_failed:
185 cs_error(link, last_fn, last_ret);
186 ixj_cs_release(link); 178 ixj_cs_release(link);
187 return -ENODEV; 179 return -ENODEV;
188} 180}