aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-10-13 17:12:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-13 17:12:40 -0400
commit2be4ff2f084842839b041b793ed6237e8d1d315a (patch)
tree1d776ac1717edeff4ee7d59ab0aea2782cb86dba /drivers/scsi
parentcf2fa66055d718ae13e62451bb546505f63906a2 (diff)
parenta45b3fb19ba1e4dfc3fc53563a072612092930a9 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6: (49 commits) pcmcia: ioctl-internal definitions pcmcia: cistpl header cleanup pcmcia: remove unused argument to pcmcia_parse_tuple() pcmcia: card services header cleanup pcmcia: device_id header cleanup pcmcia: encapsulate ioaddr_t pcmcia: cleanup device driver header file pcmcia: cleanup socket services header file pcmcia: merge ds_internal.h into cs_internal.h pcmcia: cleanup cs_internal.h pcmcia: cs_internal.h is internal pcmcia: use dev_printk for cs_error() pcmcia: remove CS_ error codes alltogether pcmcia: deprecate CS_BAD_TUPLE pcmcia: deprecate CS_BAD_ARGS pcmcia: deprecate CS_BAD_BASE, CS_BAD_IRQ, CS_BAD_OFFSET and CS_BAD_SIZE pcmcia: deprecate CS_BAD_ATTRIBUTE, CS_BAD_TYPE and CS_BAD_PAGE pcmcia: deprecate CS_NO_MORE_ITEMS pcmcia: deprecate CS_IN_USE pcmcia: deprecate CS_CONFIGURATION_LOCKED ... Fix trivial conflict in drivers/pcmcia/ds.c manually
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/pcmcia/aha152x_stub.c58
-rw-r--r--drivers/scsi/pcmcia/fdomain_stub.c37
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c194
-rw-r--r--drivers/scsi/pcmcia/qlogic_stub.c47
-rw-r--r--drivers/scsi/pcmcia/sym53c500_cs.c46
5 files changed, 182 insertions, 200 deletions
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c
index 2dd0dc9a9aed..165ff884f48e 100644
--- a/drivers/scsi/pcmcia/aha152x_stub.c
+++ b/drivers/scsi/pcmcia/aha152x_stub.c
@@ -140,44 +140,41 @@ static void aha152x_detach(struct pcmcia_device *link)
140#define CS_CHECK(fn, ret) \ 140#define CS_CHECK(fn, ret) \
141do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 141do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
142 142
143static int aha152x_config_check(struct pcmcia_device *p_dev,
144 cistpl_cftable_entry_t *cfg,
145 cistpl_cftable_entry_t *dflt,
146 unsigned int vcc,
147 void *priv_data)
148{
149 /* For New Media T&J, look for a SCSI window */
150 if (cfg->io.win[0].len >= 0x20)
151 p_dev->io.BasePort1 = cfg->io.win[0].base;
152 else if ((cfg->io.nwin > 1) &&
153 (cfg->io.win[1].len >= 0x20))
154 p_dev->io.BasePort1 = cfg->io.win[1].base;
155 if ((cfg->io.nwin > 0) &&
156 (p_dev->io.BasePort1 < 0xffff)) {
157 if (!pcmcia_request_io(p_dev, &p_dev->io))
158 return 0;
159 }
160 return -EINVAL;
161}
162
143static int aha152x_config_cs(struct pcmcia_device *link) 163static int aha152x_config_cs(struct pcmcia_device *link)
144{ 164{
145 scsi_info_t *info = link->priv; 165 scsi_info_t *info = link->priv;
146 struct aha152x_setup s; 166 struct aha152x_setup s;
147 tuple_t tuple; 167 int last_ret, last_fn;
148 cisparse_t parse;
149 int i, last_ret, last_fn;
150 u_char tuple_data[64];
151 struct Scsi_Host *host; 168 struct Scsi_Host *host;
152 169
153 DEBUG(0, "aha152x_config(0x%p)\n", link); 170 DEBUG(0, "aha152x_config(0x%p)\n", link);
154 171
155 tuple.TupleData = tuple_data; 172 last_ret = pcmcia_loop_config(link, aha152x_config_check, NULL);
156 tuple.TupleDataMax = 64; 173 if (last_ret) {
157 tuple.TupleOffset = 0; 174 cs_error(link, RequestIO, last_ret);
158 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 175 goto failed;
159 tuple.Attributes = 0;
160 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
161 while (1) {
162 if (pcmcia_get_tuple_data(link, &tuple) != 0 ||
163 pcmcia_parse_tuple(link, &tuple, &parse) != 0)
164 goto next_entry;
165 /* For New Media T&J, look for a SCSI window */
166 if (parse.cftable_entry.io.win[0].len >= 0x20)
167 link->io.BasePort1 = parse.cftable_entry.io.win[0].base;
168 else if ((parse.cftable_entry.io.nwin > 1) &&
169 (parse.cftable_entry.io.win[1].len >= 0x20))
170 link->io.BasePort1 = parse.cftable_entry.io.win[1].base;
171 if ((parse.cftable_entry.io.nwin > 0) &&
172 (link->io.BasePort1 < 0xffff)) {
173 link->conf.ConfigIndex = parse.cftable_entry.index;
174 i = pcmcia_request_io(link, &link->io);
175 if (i == CS_SUCCESS) break;
176 }
177 next_entry:
178 CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple));
179 } 176 }
180 177
181 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 178 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
182 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 179 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
183 180
@@ -208,6 +205,7 @@ static int aha152x_config_cs(struct pcmcia_device *link)
208 205
209cs_failed: 206cs_failed:
210 cs_error(link, last_fn, last_ret); 207 cs_error(link, last_fn, last_ret);
208failed:
211 aha152x_release_cs(link); 209 aha152x_release_cs(link);
212 return -ENODEV; 210 return -ENODEV;
213} 211}
diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c
index d8b99351b053..06254f46a0dd 100644
--- a/drivers/scsi/pcmcia/fdomain_stub.c
+++ b/drivers/scsi/pcmcia/fdomain_stub.c
@@ -123,34 +123,30 @@ static void fdomain_detach(struct pcmcia_device *link)
123#define CS_CHECK(fn, ret) \ 123#define CS_CHECK(fn, ret) \
124do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 124do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
125 125
126static int fdomain_config_check(struct pcmcia_device *p_dev,
127 cistpl_cftable_entry_t *cfg,
128 cistpl_cftable_entry_t *dflt,
129 unsigned int vcc,
130 void *priv_data)
131{
132 p_dev->io.BasePort1 = cfg->io.win[0].base;
133 return pcmcia_request_io(p_dev, &p_dev->io);
134}
135
136
126static int fdomain_config(struct pcmcia_device *link) 137static int fdomain_config(struct pcmcia_device *link)
127{ 138{
128 scsi_info_t *info = link->priv; 139 scsi_info_t *info = link->priv;
129 tuple_t tuple; 140 int last_ret, last_fn;
130 cisparse_t parse;
131 int i, last_ret, last_fn;
132 u_char tuple_data[64];
133 char str[22]; 141 char str[22];
134 struct Scsi_Host *host; 142 struct Scsi_Host *host;
135 143
136 DEBUG(0, "fdomain_config(0x%p)\n", link); 144 DEBUG(0, "fdomain_config(0x%p)\n", link);
137 145
138 tuple.TupleData = tuple_data; 146 last_ret = pcmcia_loop_config(link, fdomain_config_check, NULL);
139 tuple.TupleDataMax = 64; 147 if (last_ret) {
140 tuple.TupleOffset = 0; 148 cs_error(link, RequestIO, last_ret);
141 149 goto failed;
142 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
143 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
144 while (1) {
145 if (pcmcia_get_tuple_data(link, &tuple) != 0 ||
146 pcmcia_parse_tuple(link, &tuple, &parse) != 0)
147 goto next_entry;
148 link->conf.ConfigIndex = parse.cftable_entry.index;
149 link->io.BasePort1 = parse.cftable_entry.io.win[0].base;
150 i = pcmcia_request_io(link, &link->io);
151 if (i == CS_SUCCESS) break;
152 next_entry:
153 CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple));
154 } 150 }
155 151
156 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 152 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
@@ -181,6 +177,7 @@ static int fdomain_config(struct pcmcia_device *link)
181 177
182cs_failed: 178cs_failed:
183 cs_error(link, last_fn, last_ret); 179 cs_error(link, last_fn, last_ret);
180failed:
184 fdomain_release(link); 181 fdomain_release(link);
185 return -ENODEV; 182 return -ENODEV;
186} /* fdomain_config */ 183} /* fdomain_config */
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index 24e6cb8396e3..11a61ea8d5d9 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -1606,133 +1606,129 @@ static void nsp_cs_detach(struct pcmcia_device *link)
1606 is received, to configure the PCMCIA socket, and to make the 1606 is received, to configure the PCMCIA socket, and to make the
1607 ethernet device available to the system. 1607 ethernet device available to the system.
1608======================================================================*/ 1608======================================================================*/
1609#define CS_CHECK(fn, ret) \
1610do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
1611/*====================================================================*/
1612static int nsp_cs_config(struct pcmcia_device *link)
1613{
1614 int ret;
1615 scsi_info_t *info = link->priv;
1616 tuple_t tuple;
1617 cisparse_t parse;
1618 int last_ret, last_fn;
1619 unsigned char tuple_data[64];
1620 config_info_t conf;
1621 win_req_t req;
1622 memreq_t map;
1623 cistpl_cftable_entry_t dflt = { 0 };
1624 struct Scsi_Host *host;
1625 nsp_hw_data *data = &nsp_data_base;
1626
1627 nsp_dbg(NSP_DEBUG_INIT, "in");
1628
1629 tuple.Attributes = 0;
1630 tuple.TupleData = tuple_data;
1631 tuple.TupleDataMax = sizeof(tuple_data);
1632 tuple.TupleOffset = 0;
1633
1634 /* Look up the current Vcc */
1635 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &conf));
1636 1609
1637 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 1610struct nsp_cs_configdata {
1638 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 1611 nsp_hw_data *data;
1639 while (1) { 1612 win_req_t req;
1640 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 1613};
1641 1614
1642 if (pcmcia_get_tuple_data(link, &tuple) != 0 || 1615static int nsp_cs_config_check(struct pcmcia_device *p_dev,
1643 pcmcia_parse_tuple(link, &tuple, &parse) != 0) 1616 cistpl_cftable_entry_t *cfg,
1644 goto next_entry; 1617 cistpl_cftable_entry_t *dflt,
1618 unsigned int vcc,
1619 void *priv_data)
1620{
1621 struct nsp_cs_configdata *cfg_mem = priv_data;
1645 1622
1646 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) { dflt = *cfg; } 1623 if (cfg->index == 0)
1647 if (cfg->index == 0) { goto next_entry; } 1624 return -ENODEV;
1648 link->conf.ConfigIndex = cfg->index;
1649 1625
1650 /* Does this card need audio output? */ 1626 /* Does this card need audio output? */
1651 if (cfg->flags & CISTPL_CFTABLE_AUDIO) { 1627 if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
1652 link->conf.Attributes |= CONF_ENABLE_SPKR; 1628 p_dev->conf.Attributes |= CONF_ENABLE_SPKR;
1653 link->conf.Status = CCSR_AUDIO_ENA; 1629 p_dev->conf.Status = CCSR_AUDIO_ENA;
1654 } 1630 }
1655 1631
1656 /* Use power settings for Vcc and Vpp if present */ 1632 /* Use power settings for Vcc and Vpp if present */
1657 /* Note that the CIS values need to be rescaled */ 1633 /* Note that the CIS values need to be rescaled */
1658 if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) { 1634 if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) {
1659 if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000) { 1635 if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000)
1660 goto next_entry; 1636 return -ENODEV;
1661 } 1637 else if (dflt->vcc.present & (1<<CISTPL_POWER_VNOM)) {
1662 } else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) { 1638 if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM]/10000)
1663 if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM]/10000) { 1639 return -ENODEV;
1664 goto next_entry;
1665 }
1666 } 1640 }
1667 1641
1668 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) { 1642 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) {
1669 link->conf.Vpp = 1643 p_dev->conf.Vpp =
1670 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 1644 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
1671 } else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) { 1645 } else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) {
1672 link->conf.Vpp = 1646 p_dev->conf.Vpp =
1673 dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; 1647 dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
1674 } 1648 }
1675 1649
1676 /* Do we need to allocate an interrupt? */ 1650 /* Do we need to allocate an interrupt? */
1677 if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) { 1651 if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
1678 link->conf.Attributes |= CONF_ENABLE_IRQ; 1652 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
1679 }
1680 1653
1681 /* IO window settings */ 1654 /* IO window settings */
1682 link->io.NumPorts1 = link->io.NumPorts2 = 0; 1655 p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
1683 if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { 1656 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
1684 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; 1657 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
1685 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 1658 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
1686 if (!(io->flags & CISTPL_IO_8BIT)) 1659 if (!(io->flags & CISTPL_IO_8BIT))
1687 link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 1660 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
1688 if (!(io->flags & CISTPL_IO_16BIT)) 1661 if (!(io->flags & CISTPL_IO_16BIT))
1689 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 1662 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
1690 link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 1663 p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK;
1691 link->io.BasePort1 = io->win[0].base; 1664 p_dev->io.BasePort1 = io->win[0].base;
1692 link->io.NumPorts1 = io->win[0].len; 1665 p_dev->io.NumPorts1 = io->win[0].len;
1693 if (io->nwin > 1) { 1666 if (io->nwin > 1) {
1694 link->io.Attributes2 = link->io.Attributes1; 1667 p_dev->io.Attributes2 = p_dev->io.Attributes1;
1695 link->io.BasePort2 = io->win[1].base; 1668 p_dev->io.BasePort2 = io->win[1].base;
1696 link->io.NumPorts2 = io->win[1].len; 1669 p_dev->io.NumPorts2 = io->win[1].len;
1697 } 1670 }
1698 /* This reserves IO space but doesn't actually enable it */ 1671 /* This reserves IO space but doesn't actually enable it */
1699 if (pcmcia_request_io(link, &link->io) != 0) 1672 if (pcmcia_request_io(p_dev, &p_dev->io) != 0)
1700 goto next_entry; 1673 goto next_entry;
1701 } 1674 }
1702 1675
1703 if ((cfg->mem.nwin > 0) || (dflt.mem.nwin > 0)) { 1676 if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) {
1704 cistpl_mem_t *mem = 1677 memreq_t map;
1705 (cfg->mem.nwin) ? &cfg->mem : &dflt.mem; 1678 cistpl_mem_t *mem =
1706 req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; 1679 (cfg->mem.nwin) ? &cfg->mem : &dflt->mem;
1707 req.Attributes |= WIN_ENABLE; 1680 cfg_mem->req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM;
1708 req.Base = mem->win[0].host_addr; 1681 cfg_mem->req.Attributes |= WIN_ENABLE;
1709 req.Size = mem->win[0].len; 1682 cfg_mem->req.Base = mem->win[0].host_addr;
1710 if (req.Size < 0x1000) { 1683 cfg_mem->req.Size = mem->win[0].len;
1711 req.Size = 0x1000; 1684 if (cfg_mem->req.Size < 0x1000)
1712 } 1685 cfg_mem->req.Size = 0x1000;
1713 req.AccessSpeed = 0; 1686 cfg_mem->req.AccessSpeed = 0;
1714 if (pcmcia_request_window(&link, &req, &link->win) != 0) 1687 if (pcmcia_request_window(&p_dev, &cfg_mem->req, &p_dev->win) != 0)
1715 goto next_entry; 1688 goto next_entry;
1716 map.Page = 0; map.CardOffset = mem->win[0].card_addr; 1689 map.Page = 0; map.CardOffset = mem->win[0].card_addr;
1717 if (pcmcia_map_mem_page(link->win, &map) != 0) 1690 if (pcmcia_map_mem_page(p_dev->win, &map) != 0)
1718 goto next_entry; 1691 goto next_entry;
1719 1692
1720 data->MmioAddress = (unsigned long)ioremap_nocache(req.Base, req.Size); 1693 cfg_mem->data->MmioAddress = (unsigned long) ioremap_nocache(cfg_mem->req.Base, cfg_mem->req.Size);
1721 data->MmioLength = req.Size; 1694 cfg_mem->data->MmioLength = cfg_mem->req.Size;
1722 } 1695 }
1723 /* If we got this far, we're cool! */ 1696 /* If we got this far, we're cool! */
1724 break; 1697 return 0;
1725
1726 next_entry:
1727 nsp_dbg(NSP_DEBUG_INIT, "next");
1728 pcmcia_disable_device(link);
1729 CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple));
1730 } 1698 }
1731 1699
1700next_entry:
1701 nsp_dbg(NSP_DEBUG_INIT, "next");
1702 pcmcia_disable_device(p_dev);
1703 return -ENODEV;
1704}
1705
1706static int nsp_cs_config(struct pcmcia_device *link)
1707{
1708 int ret;
1709 scsi_info_t *info = link->priv;
1710 struct nsp_cs_configdata *cfg_mem;
1711 struct Scsi_Host *host;
1712 nsp_hw_data *data = &nsp_data_base;
1713
1714 nsp_dbg(NSP_DEBUG_INIT, "in");
1715
1716 cfg_mem = kzalloc(sizeof(cfg_mem), GFP_KERNEL);
1717 if (!cfg_mem)
1718 return -ENOMEM;
1719 cfg_mem->data = data;
1720
1721 ret = pcmcia_loop_config(link, nsp_cs_config_check, cfg_mem);
1722 goto cs_failed;
1723
1732 if (link->conf.Attributes & CONF_ENABLE_IRQ) { 1724 if (link->conf.Attributes & CONF_ENABLE_IRQ) {
1733 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 1725 if (pcmcia_request_irq(link, &link->irq))
1726 goto cs_failed;
1734 } 1727 }
1735 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 1728
1729 ret = pcmcia_request_configuration(link, &link->conf);
1730 if (ret)
1731 goto cs_failed;
1736 1732
1737 if (free_ports) { 1733 if (free_ports) {
1738 if (link->io.BasePort1) { 1734 if (link->io.BasePort1) {
@@ -1790,20 +1786,20 @@ static int nsp_cs_config(struct pcmcia_device *link)
1790 printk(" & 0x%04x-0x%04x", link->io.BasePort2, 1786 printk(" & 0x%04x-0x%04x", link->io.BasePort2,
1791 link->io.BasePort2+link->io.NumPorts2-1); 1787 link->io.BasePort2+link->io.NumPorts2-1);
1792 if (link->win) 1788 if (link->win)
1793 printk(", mem 0x%06lx-0x%06lx", req.Base, 1789 printk(", mem 0x%06lx-0x%06lx", cfg_mem->req.Base,
1794 req.Base+req.Size-1); 1790 cfg_mem->req.Base+cfg_mem->req.Size-1);
1795 printk("\n"); 1791 printk("\n");
1796 1792
1793 kfree(cfg_mem);
1797 return 0; 1794 return 0;
1798 1795
1799 cs_failed: 1796 cs_failed:
1800 nsp_dbg(NSP_DEBUG_INIT, "config fail"); 1797 nsp_dbg(NSP_DEBUG_INIT, "config fail");
1801 cs_error(link, last_fn, last_ret);
1802 nsp_cs_release(link); 1798 nsp_cs_release(link);
1799 kfree(cfg_mem);
1803 1800
1804 return -ENODEV; 1801 return -ENODEV;
1805} /* nsp_cs_config */ 1802} /* nsp_cs_config */
1806#undef CS_CHECK
1807 1803
1808 1804
1809/*====================================================================== 1805/*======================================================================
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
index 67c5a58d17df..20c3e5e6d88a 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -195,39 +195,33 @@ static void qlogic_detach(struct pcmcia_device *link)
195#define CS_CHECK(fn, ret) \ 195#define CS_CHECK(fn, ret) \
196do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 196do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
197 197
198static int qlogic_config_check(struct pcmcia_device *p_dev,
199 cistpl_cftable_entry_t *cfg,
200 cistpl_cftable_entry_t *dflt,
201 unsigned int vcc,
202 void *priv_data)
203{
204 p_dev->io.BasePort1 = cfg->io.win[0].base;
205 p_dev->io.NumPorts1 = cfg->io.win[0].len;
206
207 if (p_dev->io.BasePort1 == 0)
208 return -ENODEV;
209
210 return pcmcia_request_io(p_dev, &p_dev->io);
211}
212
198static int qlogic_config(struct pcmcia_device * link) 213static int qlogic_config(struct pcmcia_device * link)
199{ 214{
200 scsi_info_t *info = link->priv; 215 scsi_info_t *info = link->priv;
201 tuple_t tuple; 216 int last_ret, last_fn;
202 cisparse_t parse;
203 int i, last_ret, last_fn;
204 unsigned short tuple_data[32];
205 struct Scsi_Host *host; 217 struct Scsi_Host *host;
206 218
207 DEBUG(0, "qlogic_config(0x%p)\n", link); 219 DEBUG(0, "qlogic_config(0x%p)\n", link);
208 220
209 info->manf_id = link->manf_id; 221 last_ret = pcmcia_loop_config(link, qlogic_config_check, NULL);
210 222 if (last_ret) {
211 tuple.TupleData = (cisdata_t *) tuple_data; 223 cs_error(link, RequestIO, last_ret);
212 tuple.TupleDataMax = 64; 224 goto failed;
213 tuple.TupleOffset = 0;
214
215 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
216 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
217 while (1) {
218 if (pcmcia_get_tuple_data(link, &tuple) != 0 ||
219 pcmcia_parse_tuple(link, &tuple, &parse) != 0)
220 goto next_entry;
221 link->conf.ConfigIndex = parse.cftable_entry.index;
222 link->io.BasePort1 = parse.cftable_entry.io.win[0].base;
223 link->io.NumPorts1 = parse.cftable_entry.io.win[0].len;
224 if (link->io.BasePort1 != 0) {
225 i = pcmcia_request_io(link, &link->io);
226 if (i == CS_SUCCESS)
227 break;
228 }
229 next_entry:
230 CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple));
231 } 225 }
232 226
233 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 227 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
@@ -262,6 +256,7 @@ static int qlogic_config(struct pcmcia_device * link)
262cs_failed: 256cs_failed:
263 cs_error(link, last_fn, last_ret); 257 cs_error(link, last_fn, last_ret);
264 pcmcia_disable_device(link); 258 pcmcia_disable_device(link);
259failed:
265 return -ENODEV; 260 return -ENODEV;
266 261
267} /* qlogic_config */ 262} /* qlogic_config */
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index 0be232b58ffb..b330c11a1752 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -700,15 +700,27 @@ static struct scsi_host_template sym53c500_driver_template = {
700#define CS_CHECK(fn, ret) \ 700#define CS_CHECK(fn, ret) \
701do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 701do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
702 702
703static int SYM53C500_config_check(struct pcmcia_device *p_dev,
704 cistpl_cftable_entry_t *cfg,
705 cistpl_cftable_entry_t *dflt,
706 unsigned int vcc,
707 void *priv_data)
708{
709 p_dev->io.BasePort1 = cfg->io.win[0].base;
710 p_dev->io.NumPorts1 = cfg->io.win[0].len;
711
712 if (p_dev->io.BasePort1 == 0)
713 return -ENODEV;
714
715 return pcmcia_request_io(p_dev, &p_dev->io);
716}
717
703static int 718static int
704SYM53C500_config(struct pcmcia_device *link) 719SYM53C500_config(struct pcmcia_device *link)
705{ 720{
706 struct scsi_info_t *info = link->priv; 721 struct scsi_info_t *info = link->priv;
707 tuple_t tuple; 722 int last_ret, last_fn;
708 cisparse_t parse;
709 int i, last_ret, last_fn;
710 int irq_level, port_base; 723 int irq_level, port_base;
711 unsigned short tuple_data[32];
712 struct Scsi_Host *host; 724 struct Scsi_Host *host;
713 struct scsi_host_template *tpnt = &sym53c500_driver_template; 725 struct scsi_host_template *tpnt = &sym53c500_driver_template;
714 struct sym53c500_data *data; 726 struct sym53c500_data *data;
@@ -717,27 +729,10 @@ SYM53C500_config(struct pcmcia_device *link)
717 729
718 info->manf_id = link->manf_id; 730 info->manf_id = link->manf_id;
719 731
720 tuple.TupleData = (cisdata_t *)tuple_data; 732 last_ret = pcmcia_loop_config(link, SYM53C500_config_check, NULL);
721 tuple.TupleDataMax = 64; 733 if (last_ret) {
722 tuple.TupleOffset = 0; 734 cs_error(link, RequestIO, last_ret);
723 735 goto failed;
724 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
725 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
726 while (1) {
727 if (pcmcia_get_tuple_data(link, &tuple) != 0 ||
728 pcmcia_parse_tuple(link, &tuple, &parse) != 0)
729 goto next_entry;
730 link->conf.ConfigIndex = parse.cftable_entry.index;
731 link->io.BasePort1 = parse.cftable_entry.io.win[0].base;
732 link->io.NumPorts1 = parse.cftable_entry.io.win[0].len;
733
734 if (link->io.BasePort1 != 0) {
735 i = pcmcia_request_io(link, &link->io);
736 if (i == CS_SUCCESS)
737 break;
738 }
739next_entry:
740 CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple));
741 } 736 }
742 737
743 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 738 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
@@ -831,6 +826,7 @@ err_release:
831 826
832cs_failed: 827cs_failed:
833 cs_error(link, last_fn, last_ret); 828 cs_error(link, last_fn, last_ret);
829failed:
834 SYM53C500_release(link); 830 SYM53C500_release(link);
835 return -ENODEV; 831 return -ENODEV;
836} /* SYM53C500_config */ 832} /* SYM53C500_config */