diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2008-07-29 08:38:55 +0200 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2008-08-23 01:21:29 +0200 |
commit | 84e2d34004dcd0c90d1af43a143511b334f11a4d (patch) | |
tree | 1872000f78edc7368d34ebf1211fd8c56d395143 /drivers/char/pcmcia | |
parent | b54bf94bf91e4ca2a489eb02bca0424ddb55242a (diff) |
pcmcia: use pcmcia_loop_config in misc pcmcia drivers
Use the config loop helper in misc pcmcia drivers.
CC: Harald Welte <laforge@gnumonks.org>
CC: <linux-parport@lists.infradead.org>
CC: Russell King <rmk+kernel@arm.linux.org.uk>
CC: Ed Okerson <eokerson@quicknet.net>
CC: linux-serial@vger.kernel.org
CC: boti@rocketmail.com
CC: linux-usb@vger.kernel.org
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/char/pcmcia')
-rw-r--r-- | drivers/char/pcmcia/cm4000_cs.c | 73 | ||||
-rw-r--r-- | drivers/char/pcmcia/cm4040_cs.c | 76 |
2 files changed, 54 insertions, 95 deletions
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c index f070ae7bd91..47adec480bd 100644 --- a/drivers/char/pcmcia/cm4000_cs.c +++ b/drivers/char/pcmcia/cm4000_cs.c @@ -1759,65 +1759,40 @@ static void cmm_cm4000_release(struct pcmcia_device * link) /*==== Interface to PCMCIA Layer =======================================*/ +static int cm4000_config_check(struct pcmcia_device *p_dev, + cistpl_cftable_entry_t *cfg, + void *priv_data) +{ + p_dev->conf.ConfigIndex = cfg->index; + + if (!cfg->io.nwin) + return -ENODEV; + + /* Get the IOaddr */ + p_dev->io.BasePort1 = cfg->io.win[0].base; + p_dev->io.NumPorts1 = cfg->io.win[0].len; + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; + if (!(cfg->io.flags & CISTPL_IO_8BIT)) + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; + if (!(cfg->io.flags & CISTPL_IO_16BIT)) + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; + p_dev->io.IOAddrLines = cfg->io.flags & CISTPL_IO_LINES_MASK; + + return pcmcia_request_io(p_dev, &p_dev->io); +} + static int cm4000_config(struct pcmcia_device * link, int devno) { struct cm4000_dev *dev; - tuple_t tuple; - cisparse_t parse; - u_char buf[64]; - int fail_fn, fail_rc; - int rc; /* read the config-tuples */ - tuple.Attributes = 0; - tuple.TupleData = buf; - tuple.TupleDataMax = sizeof(buf); - tuple.TupleOffset = 0; - - link->io.BasePort2 = 0; - link->io.NumPorts2 = 0; - link->io.Attributes2 = 0; - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; - for (rc = pcmcia_get_first_tuple(link, &tuple); - rc == CS_SUCCESS; rc = pcmcia_get_next_tuple(link, &tuple)) { - - rc = pcmcia_get_tuple_data(link, &tuple); - if (rc != CS_SUCCESS) - continue; - rc = pcmcia_parse_tuple(link, &tuple, &parse); - if (rc != CS_SUCCESS) - continue; - - link->conf.ConfigIndex = parse.cftable_entry.index; - - if (!parse.cftable_entry.io.nwin) - continue; - - /* Get the IOaddr */ - link->io.BasePort1 = parse.cftable_entry.io.win[0].base; - link->io.NumPorts1 = parse.cftable_entry.io.win[0].len; - link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; - if (!(parse.cftable_entry.io.flags & CISTPL_IO_8BIT)) - link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; - if (!(parse.cftable_entry.io.flags & CISTPL_IO_16BIT)) - link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; - link->io.IOAddrLines = parse.cftable_entry.io.flags - & CISTPL_IO_LINES_MASK; - - rc = pcmcia_request_io(link, &link->io); - if (rc == CS_SUCCESS) - break; /* we are done */ - } - if (rc != CS_SUCCESS) + if (pcmcia_loop_config(link, cm4000_config_check, NULL)) goto cs_release; link->conf.IntType = 00000002; - if ((fail_rc = - pcmcia_request_configuration(link, &link->conf)) != CS_SUCCESS) { - fail_fn = RequestConfiguration; + if (pcmcia_request_configuration(link, &link->conf)) goto cs_release; - } dev = link->priv; sprintf(dev->node.dev_name, DEVICE_NAME "%d", devno); diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c index 0b5934bef7a..e0f5d8c9b26 100644 --- a/drivers/char/pcmcia/cm4040_cs.c +++ b/drivers/char/pcmcia/cm4040_cs.c @@ -526,65 +526,49 @@ static void cm4040_reader_release(struct pcmcia_device *link) return; } -static int reader_config(struct pcmcia_device *link, int devno) +static int cm4040_config_check(struct pcmcia_device *p_dev, + cistpl_cftable_entry_t *cfg, + void *priv_data) { - struct reader_dev *dev; - tuple_t tuple; - cisparse_t parse; - u_char buf[64]; - int fail_fn, fail_rc; int rc; + p_dev->conf.ConfigIndex = cfg->index; + + if (!cfg->io.nwin) + return -ENODEV; - tuple.Attributes = 0; - tuple.TupleData = buf; - tuple.TupleDataMax = sizeof(buf); - tuple.TupleOffset = 0; + /* Get the IOaddr */ + p_dev->io.BasePort1 = cfg->io.win[0].base; + p_dev->io.NumPorts1 = cfg->io.win[0].len; + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; + if (!(cfg->io.flags & CISTPL_IO_8BIT)) + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; + if (!(cfg->io.flags & CISTPL_IO_16BIT)) + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; + p_dev->io.IOAddrLines = cfg->io.flags & CISTPL_IO_LINES_MASK; + + rc = pcmcia_request_io(p_dev, &p_dev->io); + dev_printk(KERN_INFO, &handle_to_dev(p_dev), + "pcmcia_request_io returned 0x%x\n", rc); + return rc; +} + + +static int reader_config(struct pcmcia_device *link, int devno) +{ + struct reader_dev *dev; + int fail_rc; link->io.BasePort2 = 0; link->io.NumPorts2 = 0; link->io.Attributes2 = 0; - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; - for (rc = pcmcia_get_first_tuple(link, &tuple); - rc == CS_SUCCESS; - rc = pcmcia_get_next_tuple(link, &tuple)) { - rc = pcmcia_get_tuple_data(link, &tuple); - if (rc != CS_SUCCESS) - continue; - rc = pcmcia_parse_tuple(link, &tuple, &parse); - if (rc != CS_SUCCESS) - continue; - - link->conf.ConfigIndex = parse.cftable_entry.index; - - if (!parse.cftable_entry.io.nwin) - continue; - - link->io.BasePort1 = parse.cftable_entry.io.win[0].base; - link->io.NumPorts1 = parse.cftable_entry.io.win[0].len; - link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; - if (!(parse.cftable_entry.io.flags & CISTPL_IO_8BIT)) - link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; - if (!(parse.cftable_entry.io.flags & CISTPL_IO_16BIT)) - link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; - link->io.IOAddrLines = parse.cftable_entry.io.flags - & CISTPL_IO_LINES_MASK; - rc = pcmcia_request_io(link, &link->io); - - dev_printk(KERN_INFO, &handle_to_dev(link), "foo"); - if (rc == CS_SUCCESS) - break; - else - dev_printk(KERN_INFO, &handle_to_dev(link), - "pcmcia_request_io failed 0x%x\n", rc); - } - if (rc != CS_SUCCESS) + + if (pcmcia_loop_config(link, cm4040_config_check, NULL)) goto cs_release; link->conf.IntType = 00000002; if ((fail_rc = pcmcia_request_configuration(link,&link->conf)) !=CS_SUCCESS) { - fail_fn = RequestConfiguration; dev_printk(KERN_INFO, &handle_to_dev(link), "pcmcia_request_configuration failed 0x%x\n", fail_rc); |