Skip to content

Commit

Permalink
[PATCH] pcmcia: conf.ConfigBase and conf.Present consolidation
Browse files Browse the repository at this point in the history
struct pcmcia_device *p_dev->conf.ConfigBase and .Present are set in almost
all PCMICA driver right at the beginning, using the same calls but slightly
different implementations. Unfiy this in the PCMCIA core.

Includes a small bugfix ("drivers/net/pcmcia/xirc2ps_cs.c: remove unused
label") from and Signed-off-by Adrian Bunk <[email protected]>

Signed-off-by: Dominik Brodowski <[email protected]>
  • Loading branch information
Dominik Brodowski committed Dec 5, 2006
1 parent a9606fd commit af2b3b5
Show file tree
Hide file tree
Showing 45 changed files with 47 additions and 614 deletions.
7 changes: 0 additions & 7 deletions drivers/ata/pata_pcmcia.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,6 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
tuple.TupleOffset = 0;
tuple.TupleDataMax = 255;
tuple.Attributes = 0;
tuple.DesiredTuple = CISTPL_CONFIG;

CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(pdev, &tuple));
CS_CHECK(GetTupleData, pcmcia_get_tuple_data(pdev, &tuple));
CS_CHECK(ParseTuple, pcmcia_parse_tuple(pdev, &tuple, &stk->parse));
pdev->conf.ConfigBase = stk->parse.config.base;
pdev->conf.Present = stk->parse.config.rmask[0];

/* See if we have a manufacturer identifier. Use it to set is_kme for
vendor quirks */
Expand Down
38 changes: 1 addition & 37 deletions drivers/bluetooth/bluecard_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -892,43 +892,10 @@ static void bluecard_detach(struct pcmcia_device *link)
}


static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse)
{
int i;

i = pcmcia_get_first_tuple(handle, tuple);
if (i != CS_SUCCESS)
return CS_NO_MORE_ITEMS;

i = pcmcia_get_tuple_data(handle, tuple);
if (i != CS_SUCCESS)
return i;

return pcmcia_parse_tuple(handle, tuple, parse);
}

static int bluecard_config(struct pcmcia_device *link)
{
bluecard_info_t *info = link->priv;
tuple_t tuple;
u_short buf[256];
cisparse_t parse;
int i, n, last_ret, last_fn;

tuple.TupleData = (cisdata_t *)buf;
tuple.TupleOffset = 0;
tuple.TupleDataMax = 255;
tuple.Attributes = 0;

/* Get configuration register information */
tuple.DesiredTuple = CISTPL_CONFIG;
last_ret = first_tuple(link, &tuple, &parse);
if (last_ret != CS_SUCCESS) {
last_fn = ParseTuple;
goto cs_failed;
}
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];
int i, n;

link->conf.ConfigIndex = 0x20;
link->io.NumPorts1 = 64;
Expand Down Expand Up @@ -966,9 +933,6 @@ static int bluecard_config(struct pcmcia_device *link)

return 0;

cs_failed:
cs_error(link, last_fn, last_ret);

failed:
bluecard_release(link);
return -ENODEV;
Expand Down
20 changes: 1 addition & 19 deletions drivers/bluetooth/bt3c_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,22 +713,7 @@ static int bt3c_config(struct pcmcia_device *link)
u_short buf[256];
cisparse_t parse;
cistpl_cftable_entry_t *cf = &parse.cftable_entry;
int i, j, try, last_ret, last_fn;

tuple.TupleData = (cisdata_t *)buf;
tuple.TupleOffset = 0;
tuple.TupleDataMax = 255;
tuple.Attributes = 0;

/* Get configuration register information */
tuple.DesiredTuple = CISTPL_CONFIG;
last_ret = first_tuple(link, &tuple, &parse);
if (last_ret != CS_SUCCESS) {
last_fn = ParseTuple;
goto cs_failed;
}
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];
int i, j, try;

/* First pass: look for a config entry that looks normal. */
tuple.TupleData = (cisdata_t *)buf;
Expand Down Expand Up @@ -802,9 +787,6 @@ static int bt3c_config(struct pcmcia_device *link)

return 0;

cs_failed:
cs_error(link, last_fn, last_ret);

failed:
bt3c_release(link);
return -ENODEV;
Expand Down
20 changes: 1 addition & 19 deletions drivers/bluetooth/btuart_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,22 +644,7 @@ static int btuart_config(struct pcmcia_device *link)
u_short buf[256];
cisparse_t parse;
cistpl_cftable_entry_t *cf = &parse.cftable_entry;
int i, j, try, last_ret, last_fn;

tuple.TupleData = (cisdata_t *)buf;
tuple.TupleOffset = 0;
tuple.TupleDataMax = 255;
tuple.Attributes = 0;

/* Get configuration register information */
tuple.DesiredTuple = CISTPL_CONFIG;
last_ret = first_tuple(link, &tuple, &parse);
if (last_ret != CS_SUCCESS) {
last_fn = ParseTuple;
goto cs_failed;
}
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];
int i, j, try;

/* First pass: look for a config entry that looks normal. */
tuple.TupleData = (cisdata_t *) buf;
Expand Down Expand Up @@ -734,9 +719,6 @@ static int btuart_config(struct pcmcia_device *link)

return 0;

cs_failed:
cs_error(link, last_fn, last_ret);

failed:
btuart_release(link);
return -ENODEV;
Expand Down
20 changes: 1 addition & 19 deletions drivers/bluetooth/dtl1_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,22 +626,7 @@ static int dtl1_config(struct pcmcia_device *link)
u_short buf[256];
cisparse_t parse;
cistpl_cftable_entry_t *cf = &parse.cftable_entry;
int i, last_ret, last_fn;

tuple.TupleData = (cisdata_t *)buf;
tuple.TupleOffset = 0;
tuple.TupleDataMax = 255;
tuple.Attributes = 0;

/* Get configuration register information */
tuple.DesiredTuple = CISTPL_CONFIG;
last_ret = first_tuple(link, &tuple, &parse);
if (last_ret != CS_SUCCESS) {
last_fn = ParseTuple;
goto cs_failed;
}
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];
int i;

tuple.TupleData = (cisdata_t *)buf;
tuple.TupleOffset = 0;
Expand Down Expand Up @@ -690,9 +675,6 @@ static int dtl1_config(struct pcmcia_device *link)

return 0;

cs_failed:
cs_error(link, last_fn, last_ret);

failed:
dtl1_release(link);
return -ENODEV;
Expand Down
20 changes: 0 additions & 20 deletions drivers/char/pcmcia/cm4000_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1764,29 +1764,11 @@ static int cm4000_config(struct pcmcia_device * link, int devno)
int rc;

/* read the config-tuples */
tuple.DesiredTuple = CISTPL_CONFIG;
tuple.Attributes = 0;
tuple.TupleData = buf;
tuple.TupleDataMax = sizeof(buf);
tuple.TupleOffset = 0;

if ((fail_rc = pcmcia_get_first_tuple(link, &tuple)) != CS_SUCCESS) {
fail_fn = GetFirstTuple;
goto cs_failed;
}
if ((fail_rc = pcmcia_get_tuple_data(link, &tuple)) != CS_SUCCESS) {
fail_fn = GetTupleData;
goto cs_failed;
}
if ((fail_rc =
pcmcia_parse_tuple(link, &tuple, &parse)) != CS_SUCCESS) {
fail_fn = ParseTuple;
goto cs_failed;
}

link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];

link->io.BasePort2 = 0;
link->io.NumPorts2 = 0;
link->io.Attributes2 = 0;
Expand Down Expand Up @@ -1841,8 +1823,6 @@ static int cm4000_config(struct pcmcia_device * link, int devno)

return 0;

cs_failed:
cs_error(link, fail_fn, fail_rc);
cs_release:
cm4000_release(link);
return -ENODEV;
Expand Down
20 changes: 0 additions & 20 deletions drivers/char/pcmcia/cm4040_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,29 +523,11 @@ static int reader_config(struct pcmcia_device *link, int devno)
int fail_fn, fail_rc;
int rc;

tuple.DesiredTuple = CISTPL_CONFIG;
tuple.Attributes = 0;
tuple.TupleData = buf;
tuple.TupleDataMax = sizeof(buf);
tuple.TupleOffset = 0;

if ((fail_rc = pcmcia_get_first_tuple(link, &tuple)) != CS_SUCCESS) {
fail_fn = GetFirstTuple;
goto cs_failed;
}
if ((fail_rc = pcmcia_get_tuple_data(link, &tuple)) != CS_SUCCESS) {
fail_fn = GetTupleData;
goto cs_failed;
}
if ((fail_rc = pcmcia_parse_tuple(link, &tuple, &parse))
!= CS_SUCCESS) {
fail_fn = ParseTuple;
goto cs_failed;
}

link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];

link->io.BasePort2 = 0;
link->io.NumPorts2 = 0;
link->io.Attributes2 = 0;
Expand Down Expand Up @@ -609,8 +591,6 @@ static int reader_config(struct pcmcia_device *link, int devno)

return 0;

cs_failed:
cs_error(link, fail_fn, fail_rc);
cs_release:
reader_release(link);
return -ENODEV;
Expand Down
7 changes: 0 additions & 7 deletions drivers/char/pcmcia/synclink_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,17 +604,10 @@ static int mgslpc_config(struct pcmcia_device *link)
if (debug_level >= DEBUG_LEVEL_INFO)
printk("mgslpc_config(0x%p)\n", link);

/* read CONFIG tuple to find its configuration registers */
tuple.DesiredTuple = CISTPL_CONFIG;
tuple.Attributes = 0;
tuple.TupleData = buf;
tuple.TupleDataMax = sizeof(buf);
tuple.TupleOffset = 0;
CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];

/* get CIS configuration entry */

Expand Down
6 changes: 0 additions & 6 deletions drivers/ide/legacy/ide-cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,6 @@ static int ide_config(struct pcmcia_device *link)
tuple.TupleOffset = 0;
tuple.TupleDataMax = 255;
tuple.Attributes = 0;
tuple.DesiredTuple = CISTPL_CONFIG;
CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &stk->parse));
link->conf.ConfigBase = stk->parse.config.base;
link->conf.Present = stk->parse.config.rmask[0];

is_kme = ((link->manf_id == MANFID_KME) &&
((link->card_id == PRODID_KME_KXLC005_A) ||
Expand Down
22 changes: 0 additions & 22 deletions drivers/isdn/hardware/avm/avm_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,28 +194,6 @@ static int avmcs_config(struct pcmcia_device *link)

dev = link->priv;

/*
This reads the card's CONFIG tuple to find its configuration
registers.
*/
do {
tuple.DesiredTuple = CISTPL_CONFIG;
i = pcmcia_get_first_tuple(link, &tuple);
if (i != CS_SUCCESS) break;
tuple.TupleData = buf;
tuple.TupleDataMax = 64;
tuple.TupleOffset = 0;
i = pcmcia_get_tuple_data(link, &tuple);
if (i != CS_SUCCESS) break;
i = pcmcia_parse_tuple(link, &tuple, &parse);
if (i != CS_SUCCESS) break;
link->conf.ConfigBase = parse.config.base;
} while (0);
if (i != CS_SUCCESS) {
cs_error(link, ParseTuple, i);
return -ENODEV;
}

do {
devname[0] = 0;
if (link->prod_id[1])
Expand Down
22 changes: 0 additions & 22 deletions drivers/isdn/hisax/avma1_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,28 +216,6 @@ static int avma1cs_config(struct pcmcia_device *link)

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

/*
This reads the card's CONFIG tuple to find its configuration
registers.
*/
do {
tuple.DesiredTuple = CISTPL_CONFIG;
i = pcmcia_get_first_tuple(link, &tuple);
if (i != CS_SUCCESS) break;
tuple.TupleData = buf;
tuple.TupleDataMax = 64;
tuple.TupleOffset = 0;
i = pcmcia_get_tuple_data(link, &tuple);
if (i != CS_SUCCESS) break;
i = pcmcia_parse_tuple(link, &tuple, &parse);
if (i != CS_SUCCESS) break;
link->conf.ConfigBase = parse.config.base;
} while (0);
if (i != CS_SUCCESS) {
cs_error(link, ParseTuple, i);
return -ENODEV;
}

do {
devname[0] = 0;
if (link->prod_id[1])
Expand Down
17 changes: 0 additions & 17 deletions drivers/isdn/hisax/elsa_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,23 +242,6 @@ static int elsa_cs_config(struct pcmcia_device *link)
DEBUG(0, "elsa_config(0x%p)\n", link);
dev = link->priv;

/*
This reads the card's CONFIG tuple to find its configuration
registers.
*/
tuple.DesiredTuple = CISTPL_CONFIG;
tuple.TupleData = (cisdata_t *)buf;
tuple.TupleDataMax = 255;
tuple.TupleOffset = 0;
tuple.Attributes = 0;
i = first_tuple(link, &tuple, &parse);
if (i != CS_SUCCESS) {
last_fn = ParseTuple;
goto cs_failed;
}
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];

tuple.TupleData = (cisdata_t *)buf;
tuple.TupleOffset = 0; tuple.TupleDataMax = 255;
tuple.Attributes = 0;
Expand Down
10 changes: 0 additions & 10 deletions drivers/isdn/hisax/sedlbauer_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,20 +233,10 @@ static int sedlbauer_config(struct pcmcia_device *link)

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

/*
This reads the card's CONFIG tuple to find its configuration
registers.
*/
tuple.DesiredTuple = CISTPL_CONFIG;
tuple.Attributes = 0;
tuple.TupleData = buf;
tuple.TupleDataMax = sizeof(buf);
tuple.TupleOffset = 0;
CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];

CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &conf));

Expand Down
Loading

0 comments on commit af2b3b5

Please sign in to comment.