aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/telephony/ixj_pcmcia.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/telephony/ixj_pcmcia.c')
-rw-r--r--drivers/telephony/ixj_pcmcia.c72
1 files changed, 30 insertions, 42 deletions
diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c
index ff9a29b76336..347c3ed1d9f1 100644
--- a/drivers/telephony/ixj_pcmcia.c
+++ b/drivers/telephony/ixj_pcmcia.c
@@ -124,65 +124,53 @@ 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 cistpl_cftable_entry_t *dflt,
130 unsigned int vcc,
131 void *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->io.BasePort1 = io->win[0].base;
136 p_dev->io.NumPorts1 = io->win[0].len;
137 if (io->nwin == 2) {
138 p_dev->io.BasePort2 = io->win[1].base;
139 p_dev->io.NumPorts2 = io->win[1].len;
140 }
141 if (!pcmcia_request_io(p_dev, &p_dev->io))
142 return 0;
143 }
144 return -ENODEV;
145}
146
127static int ixj_config(struct pcmcia_device * link) 147static int ixj_config(struct pcmcia_device * link)
128{ 148{
129 IXJ *j; 149 IXJ *j;
130 ixj_info_t *info; 150 ixj_info_t *info;
131 tuple_t tuple; 151 cistpl_cftable_entry_t dflt = { 0 };
132 u_short buf[128]; 152
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; 153 info = link->priv;
141 DEBUG(0, "ixj_config(0x%p)\n", link); 154 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 155
172 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 156 if (pcmcia_loop_config(link, ixj_config_check, &dflt))
157 goto cs_failed;
158
159 if (pcmcia_request_configuration(link, &link->conf))
160 goto cs_failed;
173 161
174 /* 162 /*
175 * Register the card with the core. 163 * Register the card with the core.
176 */ 164 */
177 j=ixj_pcmcia_probe(link->io.BasePort1,link->io.BasePort1 + 0x10); 165 j = ixj_pcmcia_probe(link->io.BasePort1, link->io.BasePort1 + 0x10);
178 166
179 info->ndev = 1; 167 info->ndev = 1;
180 info->node.major = PHONE_MAJOR; 168 info->node.major = PHONE_MAJOR;
181 link->dev_node = &info->node; 169 link->dev_node = &info->node;
182 ixj_get_serial(link, j); 170 ixj_get_serial(link, j);
183 return 0; 171 return 0;
172
184 cs_failed: 173 cs_failed:
185 cs_error(link, last_fn, last_ret);
186 ixj_cs_release(link); 174 ixj_cs_release(link);
187 return -ENODEV; 175 return -ENODEV;
188} 176}