diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2008-08-02 09:30:31 -0400 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2008-08-22 19:22:00 -0400 |
commit | 8e2fc39ddea7fe8c6798837da282db88a09af793 (patch) | |
tree | 7cba37b5b86f4ff25562012a14e29424e3872de0 /drivers/scsi/pcmcia/nsp_cs.c | |
parent | 498ac1899b62626bf6879a251d75c22ec564c559 (diff) |
pcmcia: pcmcia_config_loop() default CIS entry handling
Many drivers use the default CIS entry within their pcmcia_config_loop()
callback function. Therefore, factor the default CIS entry handling out.
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/scsi/pcmcia/nsp_cs.c')
-rw-r--r-- | drivers/scsi/pcmcia/nsp_cs.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index aee24b745dc9..aa4523462578 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c | |||
@@ -1612,17 +1612,15 @@ struct nsp_cs_configdata { | |||
1612 | nsp_hw_data *data; | 1612 | nsp_hw_data *data; |
1613 | win_req_t req; | 1613 | win_req_t req; |
1614 | config_info_t conf; | 1614 | config_info_t conf; |
1615 | cistpl_cftable_entry_t dflt; | ||
1616 | }; | 1615 | }; |
1617 | 1616 | ||
1618 | static int nsp_cs_config_check(struct pcmcia_device *p_dev, | 1617 | static int nsp_cs_config_check(struct pcmcia_device *p_dev, |
1619 | cistpl_cftable_entry_t *cfg, | 1618 | cistpl_cftable_entry_t *cfg, |
1619 | cistpl_cftable_entry_t *dflt, | ||
1620 | void *priv_data) | 1620 | void *priv_data) |
1621 | { | 1621 | { |
1622 | struct nsp_cs_configdata *cfg_mem = priv_data; | 1622 | struct nsp_cs_configdata *cfg_mem = priv_data; |
1623 | 1623 | ||
1624 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) | ||
1625 | memcpy(&cfg_mem->dflt, cfg, sizeof(cistpl_cftable_entry_t)); | ||
1626 | if (cfg->index == 0) | 1624 | if (cfg->index == 0) |
1627 | return -ENODEV; | 1625 | return -ENODEV; |
1628 | 1626 | ||
@@ -1637,28 +1635,27 @@ static int nsp_cs_config_check(struct pcmcia_device *p_dev, | |||
1637 | if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) { | 1635 | if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) { |
1638 | if (cfg_mem->conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000) | 1636 | if (cfg_mem->conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000) |
1639 | return -ENODEV; | 1637 | return -ENODEV; |
1640 | else if (cfg_mem->dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) { | 1638 | else if (dflt->vcc.present & (1<<CISTPL_POWER_VNOM)) { |
1641 | if (cfg_mem->conf.Vcc != cfg_mem->dflt.vcc.param[CISTPL_POWER_VNOM]/10000) | 1639 | if (cfg_mem->conf.Vcc != dflt->vcc.param[CISTPL_POWER_VNOM]/10000) |
1642 | return -ENODEV; | 1640 | return -ENODEV; |
1643 | } | 1641 | } |
1644 | 1642 | ||
1645 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) { | 1643 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) { |
1646 | p_dev->conf.Vpp = | 1644 | p_dev->conf.Vpp = |
1647 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | 1645 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; |
1648 | } else if (cfg_mem->dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) { | 1646 | } else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) { |
1649 | p_dev->conf.Vpp = | 1647 | p_dev->conf.Vpp = |
1650 | cfg_mem->dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; | 1648 | dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; |
1651 | } | 1649 | } |
1652 | 1650 | ||
1653 | /* Do we need to allocate an interrupt? */ | 1651 | /* Do we need to allocate an interrupt? */ |
1654 | if (cfg->irq.IRQInfo1 || cfg_mem->dflt.irq.IRQInfo1) { | 1652 | if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1) |
1655 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; | 1653 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; |
1656 | } | ||
1657 | 1654 | ||
1658 | /* IO window settings */ | 1655 | /* IO window settings */ |
1659 | p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; | 1656 | p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; |
1660 | if ((cfg->io.nwin > 0) || (cfg_mem->dflt.io.nwin > 0)) { | 1657 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { |
1661 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &cfg_mem->dflt.io; | 1658 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; |
1662 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | 1659 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; |
1663 | if (!(io->flags & CISTPL_IO_8BIT)) | 1660 | if (!(io->flags & CISTPL_IO_8BIT)) |
1664 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | 1661 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; |
@@ -1677,10 +1674,10 @@ static int nsp_cs_config_check(struct pcmcia_device *p_dev, | |||
1677 | goto next_entry; | 1674 | goto next_entry; |
1678 | } | 1675 | } |
1679 | 1676 | ||
1680 | if ((cfg->mem.nwin > 0) || (cfg_mem->dflt.mem.nwin > 0)) { | 1677 | if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) { |
1681 | memreq_t map; | 1678 | memreq_t map; |
1682 | cistpl_mem_t *mem = | 1679 | cistpl_mem_t *mem = |
1683 | (cfg->mem.nwin) ? &cfg->mem : &cfg_mem->dflt.mem; | 1680 | (cfg->mem.nwin) ? &cfg->mem : &dflt->mem; |
1684 | cfg_mem->req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; | 1681 | cfg_mem->req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; |
1685 | cfg_mem->req.Attributes |= WIN_ENABLE; | 1682 | cfg_mem->req.Attributes |= WIN_ENABLE; |
1686 | cfg_mem->req.Base = mem->win[0].host_addr; | 1683 | cfg_mem->req.Base = mem->win[0].host_addr; |