aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-10-13 17:12:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-13 17:12:40 -0400
commit2be4ff2f084842839b041b793ed6237e8d1d315a (patch)
tree1d776ac1717edeff4ee7d59ab0aea2782cb86dba /drivers/isdn
parentcf2fa66055d718ae13e62451bb546505f63906a2 (diff)
parenta45b3fb19ba1e4dfc3fc53563a072612092930a9 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6: (49 commits) pcmcia: ioctl-internal definitions pcmcia: cistpl header cleanup pcmcia: remove unused argument to pcmcia_parse_tuple() pcmcia: card services header cleanup pcmcia: device_id header cleanup pcmcia: encapsulate ioaddr_t pcmcia: cleanup device driver header file pcmcia: cleanup socket services header file pcmcia: merge ds_internal.h into cs_internal.h pcmcia: cleanup cs_internal.h pcmcia: cs_internal.h is internal pcmcia: use dev_printk for cs_error() pcmcia: remove CS_ error codes alltogether pcmcia: deprecate CS_BAD_TUPLE pcmcia: deprecate CS_BAD_ARGS pcmcia: deprecate CS_BAD_BASE, CS_BAD_IRQ, CS_BAD_OFFSET and CS_BAD_SIZE pcmcia: deprecate CS_BAD_ATTRIBUTE, CS_BAD_TYPE and CS_BAD_PAGE pcmcia: deprecate CS_NO_MORE_ITEMS pcmcia: deprecate CS_IN_USE pcmcia: deprecate CS_CONFIGURATION_LOCKED ... Fix trivial conflict in drivers/pcmcia/ds.c manually
Diffstat (limited to 'drivers/isdn')
-rw-r--r--drivers/isdn/hardware/avm/avm_cs.c85
-rw-r--r--drivers/isdn/hisax/avma1_cs.c81
-rw-r--r--drivers/isdn/hisax/elsa_cs.c79
-rw-r--r--drivers/isdn/hisax/sedlbauer_cs.c197
-rw-r--r--drivers/isdn/hisax/teles_cs.c79
5 files changed, 192 insertions, 329 deletions
diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c
index a5b941c327f7..c72565520e41 100644
--- a/drivers/isdn/hardware/avm/avm_cs.c
+++ b/drivers/isdn/hardware/avm/avm_cs.c
@@ -154,83 +154,50 @@ static void avmcs_detach(struct pcmcia_device *link)
154 154
155======================================================================*/ 155======================================================================*/
156 156
157static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, 157static int avmcs_configcheck(struct pcmcia_device *p_dev,
158 cisparse_t *parse) 158 cistpl_cftable_entry_t *cf,
159 cistpl_cftable_entry_t *dflt,
160 unsigned int vcc,
161 void *priv_data)
159{ 162{
160 int i = pcmcia_get_tuple_data(handle, tuple); 163 if (cf->io.nwin <= 0)
161 if (i != CS_SUCCESS) return i; 164 return -ENODEV;
162 return pcmcia_parse_tuple(handle, tuple, parse); 165
163} 166 p_dev->io.BasePort1 = cf->io.win[0].base;
164 167 p_dev->io.NumPorts1 = cf->io.win[0].len;
165static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, 168 p_dev->io.NumPorts2 = 0;
166 cisparse_t *parse) 169 printk(KERN_INFO "avm_cs: testing i/o %#x-%#x\n",
167{ 170 p_dev->io.BasePort1,
168 int i = pcmcia_get_first_tuple(handle, tuple); 171 p_dev->io.BasePort1+p_dev->io.NumPorts1-1);
169 if (i != CS_SUCCESS) return i; 172 return pcmcia_request_io(p_dev, &p_dev->io);
170 return get_tuple(handle, tuple, parse);
171}
172
173static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple,
174 cisparse_t *parse)
175{
176 int i = pcmcia_get_next_tuple(handle, tuple);
177 if (i != CS_SUCCESS) return i;
178 return get_tuple(handle, tuple, parse);
179} 173}
180 174
181static int avmcs_config(struct pcmcia_device *link) 175static int avmcs_config(struct pcmcia_device *link)
182{ 176{
183 tuple_t tuple;
184 cisparse_t parse;
185 cistpl_cftable_entry_t *cf = &parse.cftable_entry;
186 local_info_t *dev; 177 local_info_t *dev;
187 int i; 178 int i;
188 u_char buf[64];
189 char devname[128]; 179 char devname[128];
190 int cardtype; 180 int cardtype;
191 int (*addcard)(unsigned int port, unsigned irq); 181 int (*addcard)(unsigned int port, unsigned irq);
192 182
193 dev = link->priv; 183 dev = link->priv;
194 184
195 do { 185 devname[0] = 0;
196 devname[0] = 0; 186 if (link->prod_id[1])
197 if (link->prod_id[1]) 187 strlcpy(devname, link->prod_id[1], sizeof(devname));
198 strlcpy(devname, link->prod_id[1], sizeof(devname));
199 188
200 /* 189 /*
201 * find IO port 190 * find IO port
202 */ 191 */
203 tuple.TupleData = (cisdata_t *)buf; 192 if (pcmcia_loop_config(link, avmcs_configcheck, NULL))
204 tuple.TupleOffset = 0; tuple.TupleDataMax = 255; 193 return -ENODEV;
205 tuple.Attributes = 0;
206 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
207 i = first_tuple(link, &tuple, &parse);
208 while (i == CS_SUCCESS) {
209 if (cf->io.nwin > 0) {
210 link->conf.ConfigIndex = cf->index;
211 link->io.BasePort1 = cf->io.win[0].base;
212 link->io.NumPorts1 = cf->io.win[0].len;
213 link->io.NumPorts2 = 0;
214 printk(KERN_INFO "avm_cs: testing i/o %#x-%#x\n",
215 link->io.BasePort1,
216 link->io.BasePort1+link->io.NumPorts1-1);
217 i = pcmcia_request_io(link, &link->io);
218 if (i == CS_SUCCESS) goto found_port;
219 }
220 i = next_tuple(link, &tuple, &parse);
221 }
222
223found_port:
224 if (i != CS_SUCCESS) {
225 cs_error(link, RequestIO, i);
226 break;
227 }
228 194
195 do {
229 /* 196 /*
230 * allocate an interrupt line 197 * allocate an interrupt line
231 */ 198 */
232 i = pcmcia_request_irq(link, &link->irq); 199 i = pcmcia_request_irq(link, &link->irq);
233 if (i != CS_SUCCESS) { 200 if (i != 0) {
234 cs_error(link, RequestIRQ, i); 201 cs_error(link, RequestIRQ, i);
235 /* undo */ 202 /* undo */
236 pcmcia_disable_device(link); 203 pcmcia_disable_device(link);
@@ -241,7 +208,7 @@ found_port:
241 * configure the PCMCIA socket 208 * configure the PCMCIA socket
242 */ 209 */
243 i = pcmcia_request_configuration(link, &link->conf); 210 i = pcmcia_request_configuration(link, &link->conf);
244 if (i != CS_SUCCESS) { 211 if (i != 0) {
245 cs_error(link, RequestConfiguration, i); 212 cs_error(link, RequestConfiguration, i);
246 pcmcia_disable_device(link); 213 pcmcia_disable_device(link);
247 break; 214 break;
diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c
index fc6cc2c065b8..23560c897ec3 100644
--- a/drivers/isdn/hisax/avma1_cs.c
+++ b/drivers/isdn/hisax/avma1_cs.c
@@ -174,38 +174,29 @@ static void avma1cs_detach(struct pcmcia_device *link)
174 174
175======================================================================*/ 175======================================================================*/
176 176
177static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, 177static int avma1cs_configcheck(struct pcmcia_device *p_dev,
178 cisparse_t *parse) 178 cistpl_cftable_entry_t *cf,
179 cistpl_cftable_entry_t *dflt,
180 unsigned int vcc,
181 void *priv_data)
179{ 182{
180 int i = pcmcia_get_tuple_data(handle, tuple); 183 if (cf->io.nwin <= 0)
181 if (i != CS_SUCCESS) return i; 184 return -ENODEV;
182 return pcmcia_parse_tuple(handle, tuple, parse); 185
186 p_dev->io.BasePort1 = cf->io.win[0].base;
187 p_dev->io.NumPorts1 = cf->io.win[0].len;
188 p_dev->io.NumPorts2 = 0;
189 printk(KERN_INFO "avma1_cs: testing i/o %#x-%#x\n",
190 p_dev->io.BasePort1,
191 p_dev->io.BasePort1+p_dev->io.NumPorts1-1);
192 return pcmcia_request_io(p_dev, &p_dev->io);
183} 193}
184 194
185static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple,
186 cisparse_t *parse)
187{
188 int i = pcmcia_get_first_tuple(handle, tuple);
189 if (i != CS_SUCCESS) return i;
190 return get_tuple(handle, tuple, parse);
191}
192
193static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple,
194 cisparse_t *parse)
195{
196 int i = pcmcia_get_next_tuple(handle, tuple);
197 if (i != CS_SUCCESS) return i;
198 return get_tuple(handle, tuple, parse);
199}
200 195
201static int avma1cs_config(struct pcmcia_device *link) 196static int avma1cs_config(struct pcmcia_device *link)
202{ 197{
203 tuple_t tuple;
204 cisparse_t parse;
205 cistpl_cftable_entry_t *cf = &parse.cftable_entry;
206 local_info_t *dev; 198 local_info_t *dev;
207 int i; 199 int i;
208 u_char buf[64];
209 char devname[128]; 200 char devname[128];
210 IsdnCard_t icard; 201 IsdnCard_t icard;
211 int busy = 0; 202 int busy = 0;
@@ -214,45 +205,19 @@ static int avma1cs_config(struct pcmcia_device *link)
214 205
215 DEBUG(0, "avma1cs_config(0x%p)\n", link); 206 DEBUG(0, "avma1cs_config(0x%p)\n", link);
216 207
217 do { 208 devname[0] = 0;
218 devname[0] = 0; 209 if (link->prod_id[1])
219 if (link->prod_id[1]) 210 strlcpy(devname, link->prod_id[1], sizeof(devname));
220 strlcpy(devname, link->prod_id[1], sizeof(devname));
221 211
222 /* 212 if (pcmcia_loop_config(link, avma1cs_configcheck, NULL))
223 * find IO port 213 return -ENODEV;
224 */
225 tuple.TupleData = (cisdata_t *)buf;
226 tuple.TupleOffset = 0; tuple.TupleDataMax = 255;
227 tuple.Attributes = 0;
228 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
229 i = first_tuple(link, &tuple, &parse);
230 while (i == CS_SUCCESS) {
231 if (cf->io.nwin > 0) {
232 link->conf.ConfigIndex = cf->index;
233 link->io.BasePort1 = cf->io.win[0].base;
234 link->io.NumPorts1 = cf->io.win[0].len;
235 link->io.NumPorts2 = 0;
236 printk(KERN_INFO "avma1_cs: testing i/o %#x-%#x\n",
237 link->io.BasePort1,
238 link->io.BasePort1+link->io.NumPorts1 - 1);
239 i = pcmcia_request_io(link, &link->io);
240 if (i == CS_SUCCESS) goto found_port;
241 }
242 i = next_tuple(link, &tuple, &parse);
243 }
244 214
245found_port: 215 do {
246 if (i != CS_SUCCESS) {
247 cs_error(link, RequestIO, i);
248 break;
249 }
250
251 /* 216 /*
252 * allocate an interrupt line 217 * allocate an interrupt line
253 */ 218 */
254 i = pcmcia_request_irq(link, &link->irq); 219 i = pcmcia_request_irq(link, &link->irq);
255 if (i != CS_SUCCESS) { 220 if (i != 0) {
256 cs_error(link, RequestIRQ, i); 221 cs_error(link, RequestIRQ, i);
257 /* undo */ 222 /* undo */
258 pcmcia_disable_device(link); 223 pcmcia_disable_device(link);
@@ -263,7 +228,7 @@ found_port:
263 * configure the PCMCIA socket 228 * configure the PCMCIA socket
264 */ 229 */
265 i = pcmcia_request_configuration(link, &link->conf); 230 i = pcmcia_request_configuration(link, &link->conf);
266 if (i != CS_SUCCESS) { 231 if (i != 0) {
267 cs_error(link, RequestConfiguration, i); 232 cs_error(link, RequestConfiguration, i);
268 pcmcia_disable_device(link); 233 pcmcia_disable_device(link);
269 break; 234 break;
diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c
index db7e64424afe..f4d0fe29bcf8 100644
--- a/drivers/isdn/hisax/elsa_cs.c
+++ b/drivers/isdn/hisax/elsa_cs.c
@@ -203,82 +203,55 @@ static void elsa_cs_detach(struct pcmcia_device *link)
203 device available to the system. 203 device available to the system.
204 204
205======================================================================*/ 205======================================================================*/
206static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple,
207 cisparse_t *parse)
208{
209 int i = pcmcia_get_tuple_data(handle, tuple);
210 if (i != CS_SUCCESS) return i;
211 return pcmcia_parse_tuple(handle, tuple, parse);
212}
213
214static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple,
215 cisparse_t *parse)
216{
217 int i = pcmcia_get_first_tuple(handle, tuple);
218 if (i != CS_SUCCESS) return i;
219 return get_tuple(handle, tuple, parse);
220}
221 206
222static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, 207static int elsa_cs_configcheck(struct pcmcia_device *p_dev,
223 cisparse_t *parse) 208 cistpl_cftable_entry_t *cf,
209 cistpl_cftable_entry_t *dflt,
210 unsigned int vcc,
211 void *priv_data)
224{ 212{
225 int i = pcmcia_get_next_tuple(handle, tuple); 213 int j;
226 if (i != CS_SUCCESS) return i; 214
227 return get_tuple(handle, tuple, parse); 215 if ((cf->io.nwin > 0) && cf->io.win[0].base) {
216 printk(KERN_INFO "(elsa_cs: looks like the 96 model)\n");
217 p_dev->io.BasePort1 = cf->io.win[0].base;
218 if (!pcmcia_request_io(p_dev, &p_dev->io))
219 return 0;
220 } else {
221 printk(KERN_INFO "(elsa_cs: looks like the 97 model)\n");
222 for (j = 0x2f0; j > 0x100; j -= 0x10) {
223 p_dev->io.BasePort1 = j;
224 if (!pcmcia_request_io(p_dev, &p_dev->io))
225 return 0;
226 }
227 }
228 return -ENODEV;
228} 229}
229 230
230static int elsa_cs_config(struct pcmcia_device *link) 231static int elsa_cs_config(struct pcmcia_device *link)
231{ 232{
232 tuple_t tuple;
233 cisparse_t parse;
234 local_info_t *dev; 233 local_info_t *dev;
235 int i, j, last_fn; 234 int i, last_fn;
236 u_short buf[128];
237 cistpl_cftable_entry_t *cf = &parse.cftable_entry;
238 IsdnCard_t icard; 235 IsdnCard_t icard;
239 236
240 DEBUG(0, "elsa_config(0x%p)\n", link); 237 DEBUG(0, "elsa_config(0x%p)\n", link);
241 dev = link->priv; 238 dev = link->priv;
242 239
243 tuple.TupleData = (cisdata_t *)buf; 240 i = pcmcia_loop_config(link, elsa_cs_configcheck, NULL);
244 tuple.TupleOffset = 0; tuple.TupleDataMax = 255; 241 if (i != 0) {
245 tuple.Attributes = 0;
246 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
247 i = first_tuple(link, &tuple, &parse);
248 while (i == CS_SUCCESS) {
249 if ( (cf->io.nwin > 0) && cf->io.win[0].base) {
250 printk(KERN_INFO "(elsa_cs: looks like the 96 model)\n");
251 link->conf.ConfigIndex = cf->index;
252 link->io.BasePort1 = cf->io.win[0].base;
253 i = pcmcia_request_io(link, &link->io);
254 if (i == CS_SUCCESS) break;
255 } else {
256 printk(KERN_INFO "(elsa_cs: looks like the 97 model)\n");
257 link->conf.ConfigIndex = cf->index;
258 for (i = 0, j = 0x2f0; j > 0x100; j -= 0x10) {
259 link->io.BasePort1 = j;
260 i = pcmcia_request_io(link, &link->io);
261 if (i == CS_SUCCESS) break;
262 }
263 break;
264 }
265 i = next_tuple(link, &tuple, &parse);
266 }
267
268 if (i != CS_SUCCESS) {
269 last_fn = RequestIO; 242 last_fn = RequestIO;
270 goto cs_failed; 243 goto cs_failed;
271 } 244 }
272 245
273 i = pcmcia_request_irq(link, &link->irq); 246 i = pcmcia_request_irq(link, &link->irq);
274 if (i != CS_SUCCESS) { 247 if (i != 0) {
275 link->irq.AssignedIRQ = 0; 248 link->irq.AssignedIRQ = 0;
276 last_fn = RequestIRQ; 249 last_fn = RequestIRQ;
277 goto cs_failed; 250 goto cs_failed;
278 } 251 }
279 252
280 i = pcmcia_request_configuration(link, &link->conf); 253 i = pcmcia_request_configuration(link, &link->conf);
281 if (i != CS_SUCCESS) { 254 if (i != 0) {
282 last_fn = RequestConfiguration; 255 last_fn = RequestConfiguration;
283 goto cs_failed; 256 goto cs_failed;
284 } 257 }
diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c
index 439cb530def8..9a3c9f5e4fe8 100644
--- a/drivers/isdn/hisax/sedlbauer_cs.c
+++ b/drivers/isdn/hisax/sedlbauer_cs.c
@@ -217,101 +217,61 @@ static void sedlbauer_detach(struct pcmcia_device *link)
217#define CS_CHECK(fn, ret) \ 217#define CS_CHECK(fn, ret) \
218do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 218do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
219 219
220static int sedlbauer_config(struct pcmcia_device *link) 220static int sedlbauer_config_check(struct pcmcia_device *p_dev,
221 cistpl_cftable_entry_t *cfg,
222 cistpl_cftable_entry_t *dflt,
223 unsigned int vcc,
224 void *priv_data)
221{ 225{
222 local_info_t *dev = link->priv; 226 win_req_t *req = priv_data;
223 tuple_t tuple;
224 cisparse_t parse;
225 int last_fn, last_ret;
226 u8 buf[64];
227 config_info_t conf;
228 win_req_t req;
229 memreq_t map;
230 IsdnCard_t icard;
231
232 DEBUG(0, "sedlbauer_config(0x%p)\n", link);
233
234 tuple.Attributes = 0;
235 tuple.TupleData = buf;
236 tuple.TupleDataMax = sizeof(buf);
237 tuple.TupleOffset = 0;
238 227
239 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &conf)); 228 if (cfg->index == 0)
229 return -ENODEV;
240 230
241 /*
242 In this loop, we scan the CIS for configuration table entries,
243 each of which describes a valid card configuration, including
244 voltage, IO window, memory window, and interrupt settings.
245
246 We make no assumptions about the card to be configured: we use
247 just the information available in the CIS. In an ideal world,
248 this would work for any PCMCIA card, but it requires a complete
249 and accurate CIS. In practice, a driver usually "knows" most of
250 these things without consulting the CIS, and most client drivers
251 will only use the CIS to fill in implementation-defined details.
252 */
253 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
254 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
255 while (1) {
256 cistpl_cftable_entry_t dflt = { 0 };
257 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
258 if (pcmcia_get_tuple_data(link, &tuple) != 0 ||
259 pcmcia_parse_tuple(link, &tuple, &parse) != 0)
260 goto next_entry;
261
262 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg;
263 if (cfg->index == 0) goto next_entry;
264 link->conf.ConfigIndex = cfg->index;
265
266 /* Does this card need audio output? */ 231 /* Does this card need audio output? */
267 if (cfg->flags & CISTPL_CFTABLE_AUDIO) { 232 if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
268 link->conf.Attributes |= CONF_ENABLE_SPKR; 233 p_dev->conf.Attributes |= CONF_ENABLE_SPKR;
269 link->conf.Status = CCSR_AUDIO_ENA; 234 p_dev->conf.Status = CCSR_AUDIO_ENA;
270 } 235 }
271 236
272 /* Use power settings for Vcc and Vpp if present */ 237 /* Use power settings for Vcc and Vpp if present */
273 /* Note that the CIS values need to be rescaled */ 238 /* Note that the CIS values need to be rescaled */
274 if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) { 239 if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) {
275 if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000) 240 if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000)
276 goto next_entry; 241 return -ENODEV;
277 } else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) { 242 } else if (dflt->vcc.present & (1<<CISTPL_POWER_VNOM)) {
278 if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM]/10000) 243 if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM]/10000)
279 goto next_entry; 244 return -ENODEV;
280 } 245 }
281 246
282 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) 247 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM))
283 link->conf.Vpp = 248 p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000;
284 cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; 249 else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM))
285 else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) 250 p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000;
286 link->conf.Vpp = 251
287 dflt.vpp1.param[CISTPL_POWER_VNOM]/10000;
288
289 /* Do we need to allocate an interrupt? */ 252 /* Do we need to allocate an interrupt? */
290 if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) 253 if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
291 link->conf.Attributes |= CONF_ENABLE_IRQ; 254 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
292 255
293 /* IO window settings */ 256 /* IO window settings */
294 link->io.NumPorts1 = link->io.NumPorts2 = 0; 257 p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
295 if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { 258 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
296 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; 259 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
297 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 260 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
298 if (!(io->flags & CISTPL_IO_8BIT)) 261 if (!(io->flags & CISTPL_IO_8BIT))
299 link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 262 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
300 if (!(io->flags & CISTPL_IO_16BIT)) 263 if (!(io->flags & CISTPL_IO_16BIT))
301 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 264 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
302/* new in dummy.cs 2001/01/28 MN 265 p_dev->io.BasePort1 = io->win[0].base;
303 link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 266 p_dev->io.NumPorts1 = io->win[0].len;
304*/ 267 if (io->nwin > 1) {
305 link->io.BasePort1 = io->win[0].base; 268 p_dev->io.Attributes2 = p_dev->io.Attributes1;
306 link->io.NumPorts1 = io->win[0].len; 269 p_dev->io.BasePort2 = io->win[1].base;
307 if (io->nwin > 1) { 270 p_dev->io.NumPorts2 = io->win[1].len;
308 link->io.Attributes2 = link->io.Attributes1; 271 }
309 link->io.BasePort2 = io->win[1].base; 272 /* This reserves IO space but doesn't actually enable it */
310 link->io.NumPorts2 = io->win[1].len; 273 if (pcmcia_request_io(p_dev, &p_dev->io) != 0)
311 } 274 return -ENODEV;
312 /* This reserves IO space but doesn't actually enable it */
313 if (pcmcia_request_io(link, &link->io) != 0)
314 goto next_entry;
315 } 275 }
316 276
317 /* 277 /*
@@ -325,30 +285,54 @@ static int sedlbauer_config(struct pcmcia_device *link)
325 needs to be mapped to virtual space with ioremap() before it 285 needs to be mapped to virtual space with ioremap() before it
326 is used. 286 is used.
327 */ 287 */
328 if ((cfg->mem.nwin > 0) || (dflt.mem.nwin > 0)) { 288 if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) {
329 cistpl_mem_t *mem = 289 cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &dflt->mem;
330 (cfg->mem.nwin) ? &cfg->mem : &dflt.mem; 290 memreq_t map;
331 req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; 291 req->Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM;
332 req.Attributes |= WIN_ENABLE; 292 req->Attributes |= WIN_ENABLE;
333 req.Base = mem->win[0].host_addr; 293 req->Base = mem->win[0].host_addr;
334 req.Size = mem->win[0].len; 294 req->Size = mem->win[0].len;
335/* new in dummy.cs 2001/01/28 MN 295 req->AccessSpeed = 0;
336 if (req.Size < 0x1000) 296 if (pcmcia_request_window(&p_dev, req, &p_dev->win) != 0)
337 req.Size = 0x1000; 297 return -ENODEV;
338*/ 298 map.Page = 0;
339 req.AccessSpeed = 0; 299 map.CardOffset = mem->win[0].card_addr;
340 if (pcmcia_request_window(&link, &req, &link->win) != 0) 300 if (pcmcia_map_mem_page(p_dev->win, &map) != 0)
341 goto next_entry; 301 return -ENODEV;
342 map.Page = 0; map.CardOffset = mem->win[0].card_addr;
343 if (pcmcia_map_mem_page(link->win, &map) != 0)
344 goto next_entry;
345 } 302 }
346 /* If we got this far, we're cool! */ 303 return 0;
347 break; 304}
348 305
349 next_entry: 306
350 CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 307
351 } 308static int sedlbauer_config(struct pcmcia_device *link)
309{
310 local_info_t *dev = link->priv;
311 win_req_t *req;
312 int last_fn, last_ret;
313 IsdnCard_t icard;
314
315 DEBUG(0, "sedlbauer_config(0x%p)\n", link);
316
317 req = kzalloc(sizeof(win_req_t), GFP_KERNEL);
318 if (!req)
319 return -ENOMEM;
320
321 /*
322 In this loop, we scan the CIS for configuration table entries,
323 each of which describes a valid card configuration, including
324 voltage, IO window, memory window, and interrupt settings.
325
326 We make no assumptions about the card to be configured: we use
327 just the information available in the CIS. In an ideal world,
328 this would work for any PCMCIA card, but it requires a complete
329 and accurate CIS. In practice, a driver usually "knows" most of
330 these things without consulting the CIS, and most client drivers
331 will only use the CIS to fill in implementation-defined details.
332 */
333 last_ret = pcmcia_loop_config(link, sedlbauer_config_check, req);
334 if (last_ret)
335 goto failed;
352 336
353 /* 337 /*
354 Allocate an interrupt line. Note that this does not assign a 338 Allocate an interrupt line. Note that this does not assign a
@@ -387,8 +371,8 @@ static int sedlbauer_config(struct pcmcia_device *link)
387 printk(" & 0x%04x-0x%04x", link->io.BasePort2, 371 printk(" & 0x%04x-0x%04x", link->io.BasePort2,
388 link->io.BasePort2+link->io.NumPorts2-1); 372 link->io.BasePort2+link->io.NumPorts2-1);
389 if (link->win) 373 if (link->win)
390 printk(", mem 0x%06lx-0x%06lx", req.Base, 374 printk(", mem 0x%06lx-0x%06lx", req->Base,
391 req.Base+req.Size-1); 375 req->Base+req->Size-1);
392 printk("\n"); 376 printk("\n");
393 377
394 icard.para[0] = link->irq.AssignedIRQ; 378 icard.para[0] = link->irq.AssignedIRQ;
@@ -409,6 +393,7 @@ static int sedlbauer_config(struct pcmcia_device *link)
409 393
410cs_failed: 394cs_failed:
411 cs_error(link, last_fn, last_ret); 395 cs_error(link, last_fn, last_ret);
396failed:
412 sedlbauer_release(link); 397 sedlbauer_release(link);
413 return -ENODEV; 398 return -ENODEV;
414 399
diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c
index ab4bd455450e..623d111544d4 100644
--- a/drivers/isdn/hisax/teles_cs.c
+++ b/drivers/isdn/hisax/teles_cs.c
@@ -193,82 +193,55 @@ static void teles_detach(struct pcmcia_device *link)
193 device available to the system. 193 device available to the system.
194 194
195======================================================================*/ 195======================================================================*/
196static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple,
197 cisparse_t *parse)
198{
199 int i = pcmcia_get_tuple_data(handle, tuple);
200 if (i != CS_SUCCESS) return i;
201 return pcmcia_parse_tuple(handle, tuple, parse);
202}
203
204static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple,
205 cisparse_t *parse)
206{
207 int i = pcmcia_get_first_tuple(handle, tuple);
208 if (i != CS_SUCCESS) return i;
209 return get_tuple(handle, tuple, parse);
210}
211 196
212static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, 197static int teles_cs_configcheck(struct pcmcia_device *p_dev,
213 cisparse_t *parse) 198 cistpl_cftable_entry_t *cf,
199 cistpl_cftable_entry_t *dflt,
200 unsigned int vcc,
201 void *priv_data)
214{ 202{
215 int i = pcmcia_get_next_tuple(handle, tuple); 203 int j;
216 if (i != CS_SUCCESS) return i; 204
217 return get_tuple(handle, tuple, parse); 205 if ((cf->io.nwin > 0) && cf->io.win[0].base) {
206 printk(KERN_INFO "(teles_cs: looks like the 96 model)\n");
207 p_dev->io.BasePort1 = cf->io.win[0].base;
208 if (!pcmcia_request_io(p_dev, &p_dev->io))
209 return 0;
210 } else {
211 printk(KERN_INFO "(teles_cs: looks like the 97 model)\n");
212 for (j = 0x2f0; j > 0x100; j -= 0x10) {
213 p_dev->io.BasePort1 = j;
214 if (!pcmcia_request_io(p_dev, &p_dev->io))
215 return 0;
216 }
217 }
218 return -ENODEV;
218} 219}
219 220
220static int teles_cs_config(struct pcmcia_device *link) 221static int teles_cs_config(struct pcmcia_device *link)
221{ 222{
222 tuple_t tuple;
223 cisparse_t parse;
224 local_info_t *dev; 223 local_info_t *dev;
225 int i, j, last_fn; 224 int i, last_fn;
226 u_short buf[128];
227 cistpl_cftable_entry_t *cf = &parse.cftable_entry;
228 IsdnCard_t icard; 225 IsdnCard_t icard;
229 226
230 DEBUG(0, "teles_config(0x%p)\n", link); 227 DEBUG(0, "teles_config(0x%p)\n", link);
231 dev = link->priv; 228 dev = link->priv;
232 229
233 tuple.TupleData = (cisdata_t *)buf; 230 i = pcmcia_loop_config(link, teles_cs_configcheck, NULL);
234 tuple.TupleOffset = 0; tuple.TupleDataMax = 255; 231 if (i != 0) {
235 tuple.Attributes = 0;
236 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
237 i = first_tuple(link, &tuple, &parse);
238 while (i == CS_SUCCESS) {
239 if ( (cf->io.nwin > 0) && cf->io.win[0].base) {
240 printk(KERN_INFO "(teles_cs: looks like the 96 model)\n");
241 link->conf.ConfigIndex = cf->index;
242 link->io.BasePort1 = cf->io.win[0].base;
243 i = pcmcia_request_io(link, &link->io);
244 if (i == CS_SUCCESS) break;
245 } else {
246 printk(KERN_INFO "(teles_cs: looks like the 97 model)\n");
247 link->conf.ConfigIndex = cf->index;
248 for (i = 0, j = 0x2f0; j > 0x100; j -= 0x10) {
249 link->io.BasePort1 = j;
250 i = pcmcia_request_io(link, &link->io);
251 if (i == CS_SUCCESS) break;
252 }
253 break;
254 }
255 i = next_tuple(link, &tuple, &parse);
256 }
257
258 if (i != CS_SUCCESS) {
259 last_fn = RequestIO; 232 last_fn = RequestIO;
260 goto cs_failed; 233 goto cs_failed;
261 } 234 }
262 235
263 i = pcmcia_request_irq(link, &link->irq); 236 i = pcmcia_request_irq(link, &link->irq);
264 if (i != CS_SUCCESS) { 237 if (i != 0) {
265 link->irq.AssignedIRQ = 0; 238 link->irq.AssignedIRQ = 0;
266 last_fn = RequestIRQ; 239 last_fn = RequestIRQ;
267 goto cs_failed; 240 goto cs_failed;
268 } 241 }
269 242
270 i = pcmcia_request_configuration(link, &link->conf); 243 i = pcmcia_request_configuration(link, &link->conf);
271 if (i != CS_SUCCESS) { 244 if (i != 0) {
272 last_fn = RequestConfiguration; 245 last_fn = RequestConfiguration;
273 goto cs_failed; 246 goto cs_failed;
274 } 247 }