aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/pcmcia
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2010-07-28 04:59:06 -0400
committerDominik Brodowski <linux@dominikbrodowski.net>2010-09-29 11:20:21 -0400
commitcdb138080b78146d1cdadba9f5dadbeb97445b91 (patch)
treefae26f709ed0f19648db79059234faf9fa028051 /drivers/scsi/pcmcia
parent899611ee7d373e5eeda08e9a8632684e1ebbbf00 (diff)
pcmcia: do not use win_req_t when calling pcmcia_request_window()
Instead of win_req_t, drivers are now requested to fill out struct pcmcia_device *p_dev->resource[2,3,4,5] for up to four iomem ranges. After a call to pcmcia_request_window(), the windows found there are reserved and may be used until pcmcia_release_window() is called. CC: netdev@vger.kernel.org CC: linux-wireless@vger.kernel.org CC: linux-mtd@lists.infradead.org CC: Jiri Kosina <jkosina@suse.cz> CC: linux-scsi@vger.kernel.org Tested-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/scsi/pcmcia')
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c49
1 files changed, 19 insertions, 30 deletions
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index dd9b40306f3d..e872e0684273 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -1596,18 +1596,13 @@ static void nsp_cs_detach(struct pcmcia_device *link)
1596 ethernet device available to the system. 1596 ethernet device available to the system.
1597======================================================================*/ 1597======================================================================*/
1598 1598
1599struct nsp_cs_configdata {
1600 nsp_hw_data *data;
1601 win_req_t req;
1602};
1603
1604static int nsp_cs_config_check(struct pcmcia_device *p_dev, 1599static int nsp_cs_config_check(struct pcmcia_device *p_dev,
1605 cistpl_cftable_entry_t *cfg, 1600 cistpl_cftable_entry_t *cfg,
1606 cistpl_cftable_entry_t *dflt, 1601 cistpl_cftable_entry_t *dflt,
1607 unsigned int vcc, 1602 unsigned int vcc,
1608 void *priv_data) 1603 void *priv_data)
1609{ 1604{
1610 struct nsp_cs_configdata *cfg_mem = priv_data; 1605 nsp_hw_data *data = priv_data;
1611 1606
1612 if (cfg->index == 0) 1607 if (cfg->index == 0)
1613 return -ENODEV; 1608 return -ENODEV;
@@ -1663,21 +1658,24 @@ static int nsp_cs_config_check(struct pcmcia_device *p_dev,
1663 if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) { 1658 if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) {
1664 cistpl_mem_t *mem = 1659 cistpl_mem_t *mem =
1665 (cfg->mem.nwin) ? &cfg->mem : &dflt->mem; 1660 (cfg->mem.nwin) ? &cfg->mem : &dflt->mem;
1666 cfg_mem->req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; 1661 p_dev->resource[2]->flags |= (WIN_DATA_WIDTH_16 |
1667 cfg_mem->req.Attributes |= WIN_ENABLE; 1662 WIN_MEMORY_TYPE_CM |
1668 cfg_mem->req.Base = mem->win[0].host_addr; 1663 WIN_ENABLE);
1669 cfg_mem->req.Size = mem->win[0].len; 1664 p_dev->resource[2]->start = mem->win[0].host_addr;
1670 if (cfg_mem->req.Size < 0x1000) 1665 p_dev->resource[2]->end = mem->win[0].len;
1671 cfg_mem->req.Size = 0x1000; 1666 if (p_dev->resource[2]->end < 0x1000)
1672 cfg_mem->req.AccessSpeed = 0; 1667 p_dev->resource[2]->end = 0x1000;
1673 if (pcmcia_request_window(p_dev, &cfg_mem->req, &p_dev->win) != 0) 1668 if (pcmcia_request_window(p_dev, p_dev->resource[2],
1669 0) != 0)
1674 goto next_entry; 1670 goto next_entry;
1675 if (pcmcia_map_mem_page(p_dev, p_dev->win, 1671 if (pcmcia_map_mem_page(p_dev, p_dev->resource[2],
1676 mem->win[0].card_addr) != 0) 1672 mem->win[0].card_addr) != 0)
1677 goto next_entry; 1673 goto next_entry;
1678 1674
1679 cfg_mem->data->MmioAddress = (unsigned long) ioremap_nocache(cfg_mem->req.Base, cfg_mem->req.Size); 1675 data->MmioAddress = (unsigned long)
1680 cfg_mem->data->MmioLength = cfg_mem->req.Size; 1676 ioremap_nocache(p_dev->resource[2]->start,
1677 resource_size(p_dev->resource[2]));
1678 data->MmioLength = resource_size(p_dev->resource[2]);
1681 } 1679 }
1682 /* If we got this far, we're cool! */ 1680 /* If we got this far, we're cool! */
1683 return 0; 1681 return 0;
@@ -1693,18 +1691,12 @@ static int nsp_cs_config(struct pcmcia_device *link)
1693{ 1691{
1694 int ret; 1692 int ret;
1695 scsi_info_t *info = link->priv; 1693 scsi_info_t *info = link->priv;
1696 struct nsp_cs_configdata *cfg_mem;
1697 struct Scsi_Host *host; 1694 struct Scsi_Host *host;
1698 nsp_hw_data *data = &nsp_data_base; 1695 nsp_hw_data *data = &nsp_data_base;
1699 1696
1700 nsp_dbg(NSP_DEBUG_INIT, "in"); 1697 nsp_dbg(NSP_DEBUG_INIT, "in");
1701 1698
1702 cfg_mem = kzalloc(sizeof(*cfg_mem), GFP_KERNEL); 1699 ret = pcmcia_loop_config(link, nsp_cs_config_check, data);
1703 if (!cfg_mem)
1704 return -ENOMEM;
1705 cfg_mem->data = data;
1706
1707 ret = pcmcia_loop_config(link, nsp_cs_config_check, cfg_mem);
1708 if (ret) 1700 if (ret)
1709 goto cs_failed; 1701 goto cs_failed;
1710 1702
@@ -1767,18 +1759,15 @@ static int nsp_cs_config(struct pcmcia_device *link)
1767 printk(", io %pR", link->resource[0]); 1759 printk(", io %pR", link->resource[0]);
1768 if (link->resource[1]) 1760 if (link->resource[1])
1769 printk(" & %pR", link->resource[1]); 1761 printk(" & %pR", link->resource[1]);
1770 if (link->win) 1762 if (link->resource[2])
1771 printk(", mem 0x%06lx-0x%06lx", cfg_mem->req.Base, 1763 printk(", mem %pR", link->resource[2]);
1772 cfg_mem->req.Base+cfg_mem->req.Size-1);
1773 printk("\n"); 1764 printk("\n");
1774 1765
1775 kfree(cfg_mem);
1776 return 0; 1766 return 0;
1777 1767
1778 cs_failed: 1768 cs_failed:
1779 nsp_dbg(NSP_DEBUG_INIT, "config fail"); 1769 nsp_dbg(NSP_DEBUG_INIT, "config fail");
1780 nsp_cs_release(link); 1770 nsp_cs_release(link);
1781 kfree(cfg_mem);
1782 1771
1783 return -ENODEV; 1772 return -ENODEV;
1784} /* nsp_cs_config */ 1773} /* nsp_cs_config */
@@ -1807,7 +1796,7 @@ static void nsp_cs_release(struct pcmcia_device *link)
1807 scsi_remove_host(info->host); 1796 scsi_remove_host(info->host);
1808 } 1797 }
1809 1798
1810 if (link->win) { 1799 if (resource_size(link->resource[2])) {
1811 if (data != NULL) { 1800 if (data != NULL) {
1812 iounmap((void *)(data->MmioAddress)); 1801 iounmap((void *)(data->MmioAddress));
1813 } 1802 }