Skip to content

Commit 8e2fc39

Browse files
author
Dominik Brodowski
committed
pcmcia: pcmcia_config_loop() default CIS entry handling
Many drivers use the default CIS entry within their pcmcia_config_loop() callback function. Therefore, factor the default CIS entry handling out. Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
1 parent 498ac18 commit 8e2fc39

32 files changed

Lines changed: 158 additions & 165 deletions

‎drivers/ata/pata_pcmcia.c‎

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -151,36 +151,38 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
151151

152152
struct pcmcia_config_check {
153153
config_info_t conf;
154-
cistpl_cftable_entry_t dflt;
155154
unsigned long ctl_base;
156155
int skip_vcc;
157156
int is_kme;
158157
};
159158

160159
static int pcmcia_check_one_config(struct pcmcia_device *pdev,
161160
cistpl_cftable_entry_t *cfg,
161+
cistpl_cftable_entry_t *dflt,
162162
void *priv_data)
163163
{
164164
struct pcmcia_config_check *stk = priv_data;
165165

166166
/* Check for matching Vcc, unless we're desperate */
167167
if (!stk->skip_vcc) {
168168
if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
169-
if (stk->conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000)
170-
goto next_entry;
171-
} else if (stk->dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) {
172-
if (stk->conf.Vcc != stk->dflt.vcc.param[CISTPL_POWER_VNOM] / 10000)
173-
goto next_entry;
169+
if (stk->conf.Vcc !=
170+
cfg->vcc.param[CISTPL_POWER_VNOM] / 10000)
171+
return -ENODEV;
172+
} else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
173+
if (stk->conf.Vcc !=
174+
dflt->vcc.param[CISTPL_POWER_VNOM] / 10000)
175+
return -ENODEV;
174176
}
175177
}
176178

177179
if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
178180
pdev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
179-
else if (stk->dflt.vpp1.present & (1 << CISTPL_POWER_VNOM))
180-
pdev->conf.Vpp = stk->dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000;
181+
else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM))
182+
pdev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
181183

182-
if ((cfg->io.nwin > 0) || (stk->dflt.io.nwin > 0)) {
183-
cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &stk->dflt.io;
184+
if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
185+
cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
184186
pdev->io.BasePort1 = io->win[0].base;
185187
pdev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK;
186188
if (!(io->flags & CISTPL_IO_16BIT))
@@ -190,23 +192,19 @@ static int pcmcia_check_one_config(struct pcmcia_device *pdev,
190192
pdev->io.BasePort2 = io->win[1].base;
191193
pdev->io.NumPorts2 = (stk->is_kme) ? 2 : 1;
192194
if (pcmcia_request_io(pdev, &pdev->io) != 0)
193-
goto next_entry;
195+
return -ENODEV;
194196
stk->ctl_base = pdev->io.BasePort2;
195197
} else if ((io->nwin == 1) && (io->win[0].len >= 16)) {
196198
pdev->io.NumPorts1 = io->win[0].len;
197199
pdev->io.NumPorts2 = 0;
198200
if (pcmcia_request_io(pdev, &pdev->io) != 0)
199-
goto next_entry;
201+
return -ENODEV;
200202
stk->ctl_base = pdev->io.BasePort1 + 0x0e;
201203
} else
202-
goto next_entry;
204+
return -ENODEV;
203205
/* If we've got this far, we're done */
204206
return 0;
205207
}
206-
next_entry:
207-
if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
208-
memcpy(&stk->dflt, cfg, sizeof(stk->dflt));
209-
210208
return -ENODEV;
211209
}
212210

@@ -264,7 +262,6 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
264262
CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(pdev, &stk->conf));
265263
stk->skip_vcc = io_base = ctl_base = 0;
266264
if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) {
267-
memset(&stk->dflt, 0, sizeof(stk->dflt));
268265
stk->skip_vcc = 1;
269266
if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk))
270267
goto failed; /* No suitable config found */

‎drivers/bluetooth/bt3c_cs.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ static void bt3c_detach(struct pcmcia_device *link)
680680

681681
static int bt3c_check_config(struct pcmcia_device *p_dev,
682682
cistpl_cftable_entry_t *cf,
683+
cistpl_cftable_entry_t *dflt,
683684
void *priv_data)
684685
{
685686
unsigned long try = (unsigned long) priv_data;
@@ -699,6 +700,7 @@ static int bt3c_check_config(struct pcmcia_device *p_dev,
699700

700701
static int bt3c_check_config_notpicky(struct pcmcia_device *p_dev,
701702
cistpl_cftable_entry_t *cf,
703+
cistpl_cftable_entry_t *dflt,
702704
void *priv_data)
703705
{
704706
static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };

‎drivers/bluetooth/btuart_cs.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@ static void btuart_detach(struct pcmcia_device *link)
609609

610610
static int btuart_check_config(struct pcmcia_device *p_dev,
611611
cistpl_cftable_entry_t *cf,
612+
cistpl_cftable_entry_t *dflt,
612613
void *priv_data)
613614
{
614615
unsigned long try = (unsigned long) priv_data;
@@ -628,6 +629,7 @@ static int btuart_check_config(struct pcmcia_device *p_dev,
628629

629630
static int btuart_check_config_notpicky(struct pcmcia_device *p_dev,
630631
cistpl_cftable_entry_t *cf,
632+
cistpl_cftable_entry_t *dflt,
631633
void *priv_data)
632634
{
633635
static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };

‎drivers/bluetooth/dtl1_cs.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ static void dtl1_detach(struct pcmcia_device *link)
592592

593593
static int dtl1_confcheck(struct pcmcia_device *p_dev,
594594
cistpl_cftable_entry_t *cf,
595+
cistpl_cftable_entry_t *dflt,
595596
void *priv_data)
596597
{
597598
if ((cf->io.nwin == 1) && (cf->io.win[0].len > 8)) {

‎drivers/char/pcmcia/cm4000_cs.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,6 +1761,7 @@ static void cmm_cm4000_release(struct pcmcia_device * link)
17611761

17621762
static int cm4000_config_check(struct pcmcia_device *p_dev,
17631763
cistpl_cftable_entry_t *cfg,
1764+
cistpl_cftable_entry_t *dflt,
17641765
void *priv_data)
17651766
{
17661767
if (!cfg->io.nwin)

‎drivers/char/pcmcia/cm4040_cs.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ static void cm4040_reader_release(struct pcmcia_device *link)
528528

529529
static int cm4040_config_check(struct pcmcia_device *p_dev,
530530
cistpl_cftable_entry_t *cfg,
531+
cistpl_cftable_entry_t *dflt,
531532
void *priv_data)
532533
{
533534
int rc;

‎drivers/ide/legacy/ide-cs.c‎

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -222,36 +222,38 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
222222

223223
struct pcmcia_config_check {
224224
config_info_t conf;
225-
cistpl_cftable_entry_t dflt;
226225
unsigned long ctl_base;
227226
int skip_vcc;
228227
int is_kme;
229228
};
230229

231230
static int pcmcia_check_one_config(struct pcmcia_device *pdev,
232231
cistpl_cftable_entry_t *cfg,
232+
cistpl_cftable_entry_t *dflt,
233233
void *priv_data)
234234
{
235235
struct pcmcia_config_check *stk = priv_data;
236236

237237
/* Check for matching Vcc, unless we're desperate */
238238
if (!stk->skip_vcc) {
239239
if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
240-
if (stk->conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000)
241-
goto next_entry;
242-
} else if (stk->dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) {
243-
if (stk->conf.Vcc != stk->dflt.vcc.param[CISTPL_POWER_VNOM] / 10000)
244-
goto next_entry;
240+
if (stk->conf.Vcc !=
241+
cfg->vcc.param[CISTPL_POWER_VNOM] / 10000)
242+
return -ENODEV;
243+
} else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
244+
if (stk->conf.Vcc !=
245+
dflt->vcc.param[CISTPL_POWER_VNOM] / 10000)
246+
return -ENODEV;
245247
}
246248
}
247249

248250
if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
249251
pdev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
250-
else if (stk->dflt.vpp1.present & (1 << CISTPL_POWER_VNOM))
251-
pdev->conf.Vpp = stk->dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000;
252+
else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM))
253+
pdev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
252254

253-
if ((cfg->io.nwin > 0) || (stk->dflt.io.nwin > 0)) {
254-
cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &stk->dflt.io;
255+
if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
256+
cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
255257
pdev->conf.ConfigIndex = cfg->index;
256258
pdev->io.BasePort1 = io->win[0].base;
257259
pdev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK;
@@ -262,23 +264,19 @@ static int pcmcia_check_one_config(struct pcmcia_device *pdev,
262264
pdev->io.BasePort2 = io->win[1].base;
263265
pdev->io.NumPorts2 = (stk->is_kme) ? 2 : 1;
264266
if (pcmcia_request_io(pdev, &pdev->io) != 0)
265-
goto next_entry;
267+
return -ENODEV;
266268
stk->ctl_base = pdev->io.BasePort2;
267269
} else if ((io->nwin == 1) && (io->win[0].len >= 16)) {
268270
pdev->io.NumPorts1 = io->win[0].len;
269271
pdev->io.NumPorts2 = 0;
270272
if (pcmcia_request_io(pdev, &pdev->io) != 0)
271-
goto next_entry;
273+
return -ENODEV;
272274
stk->ctl_base = pdev->io.BasePort1 + 0x0e;
273275
} else
274-
goto next_entry;
276+
return -ENODEV;
275277
/* If we've got this far, we're done */
276278
return 0;
277279
}
278-
next_entry:
279-
if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
280-
memcpy(&stk->dflt, cfg, sizeof(stk->dflt));
281-
282280
return -ENODEV;
283281
}
284282

@@ -305,7 +303,6 @@ static int ide_config(struct pcmcia_device *link)
305303
CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &stk->conf));
306304
stk->skip_vcc = io_base = ctl_base = 0;
307305
if (pcmcia_loop_config(link, pcmcia_check_one_config, stk)) {
308-
memset(&stk->dflt, 0, sizeof(stk->dflt));
309306
stk->skip_vcc = 1;
310307
if (pcmcia_loop_config(link, pcmcia_check_one_config, stk))
311308
goto failed; /* No suitable config found */

‎drivers/isdn/hardware/avm/avm_cs.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ static void avmcs_detach(struct pcmcia_device *link)
156156

157157
static int avmcs_configcheck(struct pcmcia_device *p_dev,
158158
cistpl_cftable_entry_t *cf,
159+
cistpl_cftable_entry_t *dflt,
159160
void *priv_data)
160161
{
161162
if (cf->io.nwin <= 0)

‎drivers/isdn/hisax/avma1_cs.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,9 @@ static void avma1cs_detach(struct pcmcia_device *link)
175175
======================================================================*/
176176

177177
static int avma1cs_configcheck(struct pcmcia_device *p_dev,
178-
cistpl_cftable_entry_t *cf,
179-
void *priv_data)
178+
cistpl_cftable_entry_t *cf,
179+
cistpl_cftable_entry_t *dflt,
180+
void *priv_data)
180181
{
181182
if (cf->io.nwin <= 0)
182183
return -ENODEV;

‎drivers/isdn/hisax/elsa_cs.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ static void elsa_cs_detach(struct pcmcia_device *link)
206206

207207
static int elsa_cs_configcheck(struct pcmcia_device *p_dev,
208208
cistpl_cftable_entry_t *cf,
209+
cistpl_cftable_entry_t *dflt,
209210
void *priv_data)
210211
{
211212
int j;

0 commit comments

Comments
 (0)