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>
This commit is contained in:
@@ -165,18 +165,16 @@ static void orinoco_cs_detach(struct pcmcia_device *link)
|
||||
} while (0)
|
||||
|
||||
struct orinoco_cs_config_data {
|
||||
cistpl_cftable_entry_t dflt;
|
||||
config_info_t conf;
|
||||
};
|
||||
|
||||
static int orinoco_cs_config_check(struct pcmcia_device *p_dev,
|
||||
cistpl_cftable_entry_t *cfg,
|
||||
cistpl_cftable_entry_t *dflt,
|
||||
void *priv_data)
|
||||
{
|
||||
struct orinoco_cs_config_data *cfg_mem = priv_data;
|
||||
|
||||
if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
|
||||
cfg_mem->dflt = *cfg;
|
||||
if (cfg->index == 0)
|
||||
goto next_entry;
|
||||
|
||||
@@ -188,9 +186,9 @@ static int orinoco_cs_config_check(struct pcmcia_device *p_dev,
|
||||
if (!ignore_cis_vcc)
|
||||
goto next_entry;
|
||||
}
|
||||
} else if (cfg_mem->dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) {
|
||||
if (cfg_mem->conf.Vcc != cfg_mem->dflt.vcc.param[CISTPL_POWER_VNOM] / 10000) {
|
||||
DEBUG(2, "spectrum_cs_config: Vcc mismatch (cfg_mem->conf.Vcc = %d, CIS = %d)\n", cfg_mem->conf.Vcc, cfg_mem->dflt.vcc.param[CISTPL_POWER_VNOM] / 10000);
|
||||
} else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
|
||||
if (cfg_mem->conf.Vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) {
|
||||
DEBUG(2, "spectrum_cs_config: Vcc mismatch (cfg_mem->conf.Vcc = %d, CIS = %d)\n", cfg_mem->conf.Vcc, dflt->vcc.param[CISTPL_POWER_VNOM] / 10000);
|
||||
if (!ignore_cis_vcc)
|
||||
goto next_entry;
|
||||
}
|
||||
@@ -199,17 +197,17 @@ static int orinoco_cs_config_check(struct pcmcia_device *p_dev,
|
||||
if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
|
||||
p_dev->conf.Vpp =
|
||||
cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
|
||||
else if (cfg_mem->dflt.vpp1.present & (1 << CISTPL_POWER_VNOM))
|
||||
else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM))
|
||||
p_dev->conf.Vpp =
|
||||
cfg_mem->dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000;
|
||||
dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
|
||||
|
||||
/* Do we need to allocate an interrupt? */
|
||||
p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
|
||||
|
||||
/* IO window settings */
|
||||
p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
|
||||
if ((cfg->io.nwin > 0) || (cfg_mem->dflt.io.nwin > 0)) {
|
||||
cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &cfg_mem->dflt.io;
|
||||
if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
|
||||
cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
|
||||
p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
|
||||
if (!(io->flags & CISTPL_IO_8BIT))
|
||||
p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
|
||||
|
Reference in New Issue
Block a user