Skip to content

Commit

Permalink
pcmcia: pcmcia_config_loop() improvement by passing vcc
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dominik Brodowski committed Aug 22, 2008
1 parent 8e2fc39 commit ad913c1
Show file tree
Hide file tree
Showing 32 changed files with 93 additions and 142 deletions.
12 changes: 4 additions & 8 deletions drivers/ata/pata_pcmcia.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)


struct pcmcia_config_check {
config_info_t conf;
unsigned long ctl_base;
int skip_vcc;
int is_kme;
Expand All @@ -159,19 +158,18 @@ struct pcmcia_config_check {
static int pcmcia_check_one_config(struct pcmcia_device *pdev,
cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
struct pcmcia_config_check *stk = priv_data;

/* Check for matching Vcc, unless we're desperate */
if (!stk->skip_vcc) {
if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
if (stk->conf.Vcc !=
cfg->vcc.param[CISTPL_POWER_VNOM] / 10000)
if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000)
return -ENODEV;
} else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
if (stk->conf.Vcc !=
dflt->vcc.param[CISTPL_POWER_VNOM] / 10000)
if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000)
return -ENODEV;
}
}
Expand Down Expand Up @@ -257,10 +255,8 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
if (!stk)
goto out1;
stk->is_kme = is_kme;

/* Not sure if this is right... look up the current Vcc */
CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(pdev, &stk->conf));
stk->skip_vcc = io_base = ctl_base = 0;

if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) {
stk->skip_vcc = 1;
if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk))
Expand Down
2 changes: 2 additions & 0 deletions drivers/bluetooth/bt3c_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ static void bt3c_detach(struct pcmcia_device *link)
static int bt3c_check_config(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
unsigned long try = (unsigned long) priv_data;
Expand All @@ -701,6 +702,7 @@ static int bt3c_check_config(struct pcmcia_device *p_dev,
static int bt3c_check_config_notpicky(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
Expand Down
11 changes: 6 additions & 5 deletions drivers/bluetooth/btuart_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,16 +610,17 @@ static void btuart_detach(struct pcmcia_device *link)
static int btuart_check_config(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
unsigned long try = (unsigned long) priv_data;
int *try = priv_data;

if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM))
p_dev->conf.Vpp = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000;
if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) &&
(cf->io.win[0].base != 0)) {
p_dev->io.BasePort1 = cf->io.win[0].base;
p_dev->io.IOAddrLines = (try == 0) ? 16 :
p_dev->io.IOAddrLines = (*try == 0) ? 16 :
cf->io.flags & CISTPL_IO_LINES_MASK;
if (!pcmcia_request_io(p_dev, &p_dev->io))
return 0;
Expand All @@ -630,6 +631,7 @@ static int btuart_check_config(struct pcmcia_device *p_dev,
static int btuart_check_config_notpicky(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
Expand All @@ -650,13 +652,12 @@ static int btuart_config(struct pcmcia_device *link)
{
btuart_info_t *info = link->priv;
int i;
unsigned long try;
int try;

/* First pass: look for a config entry that looks normal.
Two tries: without IO aliases, then with aliases */
for (try = 0; try < 2; try++)
if (!pcmcia_loop_config(link, btuart_check_config,
(void *) try))
if (!pcmcia_loop_config(link, btuart_check_config, &try))
goto found_port;

/* Second pass: try to find an entry that isn't picky about
Expand Down
1 change: 1 addition & 0 deletions drivers/bluetooth/dtl1_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ static void dtl1_detach(struct pcmcia_device *link)
static int dtl1_confcheck(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
if ((cf->io.nwin == 1) && (cf->io.win[0].len > 8)) {
Expand Down
1 change: 1 addition & 0 deletions drivers/char/pcmcia/cm4000_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1762,6 +1762,7 @@ static void cmm_cm4000_release(struct pcmcia_device * link)
static int cm4000_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
if (!cfg->io.nwin)
Expand Down
1 change: 1 addition & 0 deletions drivers/char/pcmcia/cm4040_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ static void cm4040_reader_release(struct pcmcia_device *link)
static int cm4040_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
int rc;
Expand Down
12 changes: 4 additions & 8 deletions drivers/ide/legacy/ide-cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ static struct ide_host *idecs_register(unsigned long io, unsigned long ctl,
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)

struct pcmcia_config_check {
config_info_t conf;
unsigned long ctl_base;
int skip_vcc;
int is_kme;
Expand All @@ -230,19 +229,18 @@ struct pcmcia_config_check {
static int pcmcia_check_one_config(struct pcmcia_device *pdev,
cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
struct pcmcia_config_check *stk = priv_data;

/* Check for matching Vcc, unless we're desperate */
if (!stk->skip_vcc) {
if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
if (stk->conf.Vcc !=
cfg->vcc.param[CISTPL_POWER_VNOM] / 10000)
if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000)
return -ENODEV;
} else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
if (stk->conf.Vcc !=
dflt->vcc.param[CISTPL_POWER_VNOM] / 10000)
if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000)
return -ENODEV;
}
}
Expand Down Expand Up @@ -298,10 +296,8 @@ static int ide_config(struct pcmcia_device *link)
if (!stk)
goto err_mem;
stk->is_kme = is_kme;

/* Not sure if this is right... look up the current Vcc */
CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &stk->conf));
stk->skip_vcc = io_base = ctl_base = 0;

if (pcmcia_loop_config(link, pcmcia_check_one_config, stk)) {
stk->skip_vcc = 1;
if (pcmcia_loop_config(link, pcmcia_check_one_config, stk))
Expand Down
1 change: 1 addition & 0 deletions drivers/isdn/hardware/avm/avm_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ static void avmcs_detach(struct pcmcia_device *link)
static int avmcs_configcheck(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
if (cf->io.nwin <= 0)
Expand Down
1 change: 1 addition & 0 deletions drivers/isdn/hisax/avma1_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ static void avma1cs_detach(struct pcmcia_device *link)
static int avma1cs_configcheck(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
if (cf->io.nwin <= 0)
Expand Down
1 change: 1 addition & 0 deletions drivers/isdn/hisax/elsa_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ static void elsa_cs_detach(struct pcmcia_device *link)
static int elsa_cs_configcheck(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
int j;
Expand Down
42 changes: 16 additions & 26 deletions drivers/isdn/hisax/sedlbauer_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,13 @@ static void sedlbauer_detach(struct pcmcia_device *link)
#define CS_CHECK(fn, ret) \
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)

struct sedlbauer_config_data {
config_info_t conf;
win_req_t req;
};

static int sedlbauer_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
struct sedlbauer_config_data *cfg_mem = priv_data;
win_req_t *req = priv_data;

if (cfg->index == 0)
return -ENODEV;
Expand All @@ -241,12 +237,10 @@ static int sedlbauer_config_check(struct pcmcia_device *p_dev,
/* 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)
if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000)
return -ENODEV;
} else if (dflt->vcc.present & (1<<CISTPL_POWER_VNOM)) {
if (cfg_mem->conf.Vcc !=
dflt->vcc.param[CISTPL_POWER_VNOM]/10000)
if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM]/10000)
return -ENODEV;
}

Expand Down Expand Up @@ -294,12 +288,12 @@ static int sedlbauer_config_check(struct pcmcia_device *p_dev,
if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) {
cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &dflt->mem;
memreq_t map;
cfg_mem->req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM;
cfg_mem->req.Attributes |= WIN_ENABLE;
cfg_mem->req.Base = mem->win[0].host_addr;
cfg_mem->req.Size = mem->win[0].len;
cfg_mem->req.AccessSpeed = 0;
if (pcmcia_request_window(&p_dev, &cfg_mem->req, &p_dev->win) != 0)
req->Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM;
req->Attributes |= WIN_ENABLE;
req->Base = mem->win[0].host_addr;
req->Size = mem->win[0].len;
req->AccessSpeed = 0;
if (pcmcia_request_window(&p_dev, req, &p_dev->win) != 0)
return -ENODEV;
map.Page = 0;
map.CardOffset = mem->win[0].card_addr;
Expand All @@ -314,20 +308,16 @@ static int sedlbauer_config_check(struct pcmcia_device *p_dev,
static int sedlbauer_config(struct pcmcia_device *link)
{
local_info_t *dev = link->priv;
struct sedlbauer_config_data *cfg_mem;
win_req_t *req;
int last_fn, last_ret;
IsdnCard_t icard;

DEBUG(0, "sedlbauer_config(0x%p)\n", link);

cfg_mem = kzalloc(sizeof(struct sedlbauer_config_data), GFP_KERNEL);
if (!cfg_mem)
req = kzalloc(sizeof(win_req_t), GFP_KERNEL);
if (!req)
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 configuration, including
Expand All @@ -340,7 +330,7 @@ static int sedlbauer_config(struct pcmcia_device *link)
these things without consulting the CIS, and most client drivers
will only use the CIS to fill in implementation-defined details.
*/
last_ret = pcmcia_loop_config(link, sedlbauer_config_check, cfg_mem);
last_ret = pcmcia_loop_config(link, sedlbauer_config_check, req);
if (last_ret)
goto failed;

Expand Down Expand Up @@ -381,8 +371,8 @@ static int sedlbauer_config(struct pcmcia_device *link)
printk(" & 0x%04x-0x%04x", link->io.BasePort2,
link->io.BasePort2+link->io.NumPorts2-1);
if (link->win)
printk(", mem 0x%06lx-0x%06lx", cfg_mem->req.Base,
cfg_mem->req.Base+cfg_mem->req.Size-1);
printk(", mem 0x%06lx-0x%06lx", req->Base,
req->Base+req->Size-1);
printk("\n");

icard.para[0] = link->irq.AssignedIRQ;
Expand Down
1 change: 1 addition & 0 deletions drivers/isdn/hisax/teles_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ static void teles_detach(struct pcmcia_device *link)
static int teles_cs_configcheck(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
int j;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/pcmcia/axnet_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ static int try_io_port(struct pcmcia_device *link)
static int axnet_configcheck(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
int i;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/pcmcia/pcnet_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ static int try_io_port(struct pcmcia_device *link)
static int pcnet_confcheck(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
int *has_shmem = priv_data;
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/pcmcia/smc91c92_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ static int mhz_3288_power(struct pcmcia_device *link)
static int mhz_mfc_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
int k;
Expand Down Expand Up @@ -653,6 +654,7 @@ static int mot_setup(struct pcmcia_device *link)
static int smc_configcheck(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
p_dev->io.BasePort1 = cf->io.win[0].base;
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/pcmcia/xirc2ps_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@ static int
xirc2ps_config_modem(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
unsigned int ioaddr;
Expand All @@ -738,6 +739,7 @@ static int
xirc2ps_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
int *pass = priv_data;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/wireless/airo_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
static int airo_cs_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
win_req_t *req = priv_data;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/wireless/atmel_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ static int card_present(void *arg)
static int atmel_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
unsigned int vcc,
void *priv_data)
{
if (cfg->index == 0)
Expand Down
Loading

0 comments on commit ad913c1

Please sign in to comment.