pcmcia: pcmcia_config_loop() improvement by passing vcc

By passing the current Vcc setting to the pcmcia_config_loop callback
function, we can remove pcmcia_get_configuration_info() calls from many
drivers.

Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
This commit is contained in:
Dominik Brodowski
2008-08-02 16:12:00 +02:00
parent 8e2fc39dde
commit ad913c1192
32 changed files with 93 additions and 142 deletions

View File

@@ -633,31 +633,26 @@ static void spectrum_cs_detach(struct pcmcia_device *link)
* device available to the system.
*/
struct spectrum_cs_config_data {
config_info_t conf;
};
static int spectrum_cs_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
struct spectrum_cs_config_data *cfg_mem = priv_data;
if (cfg->index == 0)
goto next_entry;
/* Use power settings for Vcc and Vpp if present */
/* Note that the CIS values need to be rescaled */
if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
if (cfg_mem->conf.Vcc != cfg->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->vcc.param[CISTPL_POWER_VNOM] / 10000);
if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) {
DEBUG(2, "spectrum_cs_config: Vcc mismatch (vcc = %d, CIS = %d)\n", vcc, cfg->vcc.param[CISTPL_POWER_VNOM] / 10000);
if (!ignore_cis_vcc)
goto next_entry;
}
} 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 (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) {
DEBUG(2, "spectrum_cs_config: Vcc mismatch (vcc = %d, CIS = %d)\n", vcc, dflt->vcc.param[CISTPL_POWER_VNOM] / 10000);
if (!ignore_cis_vcc)
goto next_entry;
}
@@ -705,7 +700,6 @@ next_entry:
static int
spectrum_cs_config(struct pcmcia_device *link)
{
struct spectrum_cs_config_data *cfg_mem;
struct net_device *dev = link->priv;
struct orinoco_private *priv = netdev_priv(dev);
struct orinoco_pccard *card = priv->card;
@@ -713,14 +707,6 @@ spectrum_cs_config(struct pcmcia_device *link)
int last_fn, last_ret;
void __iomem *mem;
cfg_mem = kzalloc(sizeof(struct spectrum_cs_config_data), GFP_KERNEL);
if (!cfg_mem)
return -ENOMEM;
/* Look up the current Vcc */
CS_CHECK(GetConfigurationInfo,
pcmcia_get_configuration_info(link, &cfg_mem->conf));
/*
* In this loop, we scan the CIS for configuration table
* entries, each of which describes a valid card
@@ -735,7 +721,7 @@ spectrum_cs_config(struct pcmcia_device *link)
* and most client drivers will only use the CIS to fill in
* implementation-defined details.
*/
last_ret = pcmcia_loop_config(link, spectrum_cs_config_check, cfg_mem);
last_ret = pcmcia_loop_config(link, spectrum_cs_config_check, NULL);
if (last_ret) {
if (!ignore_cis_vcc)
printk(KERN_ERR PFX "GetNextTuple(): No matching "
@@ -799,7 +785,6 @@ spectrum_cs_config(struct pcmcia_device *link)
link->irq.AssignedIRQ, link->io.BasePort1,
link->io.BasePort1 + link->io.NumPorts1 - 1);
kfree(cfg_mem);
return 0;
cs_failed:
@@ -807,7 +792,6 @@ spectrum_cs_config(struct pcmcia_device *link)
failed:
spectrum_cs_release(link);
kfree(cfg_mem);
return -ENODEV;
} /* spectrum_cs_config */