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>
This commit is contained in:
Dominik Brodowski
2008-08-02 15:30:31 +02:00
parent 498ac1899b
commit 8e2fc39dde
32 changed files with 158 additions and 165 deletions
+15 -18
View File
@@ -151,7 +151,6 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
struct pcmcia_config_check { struct pcmcia_config_check {
config_info_t conf; config_info_t conf;
cistpl_cftable_entry_t dflt;
unsigned long ctl_base; unsigned long ctl_base;
int skip_vcc; int skip_vcc;
int is_kme; int is_kme;
@@ -159,6 +158,7 @@ struct pcmcia_config_check {
static int pcmcia_check_one_config(struct pcmcia_device *pdev, static int pcmcia_check_one_config(struct pcmcia_device *pdev,
cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
struct pcmcia_config_check *stk = priv_data; struct pcmcia_config_check *stk = priv_data;
@@ -166,21 +166,23 @@ static int pcmcia_check_one_config(struct pcmcia_device *pdev,
/* Check for matching Vcc, unless we're desperate */ /* Check for matching Vcc, unless we're desperate */
if (!stk->skip_vcc) { if (!stk->skip_vcc) {
if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
if (stk->conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) if (stk->conf.Vcc !=
goto next_entry; cfg->vcc.param[CISTPL_POWER_VNOM] / 10000)
} else if (stk->dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { return -ENODEV;
if (stk->conf.Vcc != stk->dflt.vcc.param[CISTPL_POWER_VNOM] / 10000) } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
goto next_entry; if (stk->conf.Vcc !=
dflt->vcc.param[CISTPL_POWER_VNOM] / 10000)
return -ENODEV;
} }
} }
if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
pdev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; pdev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
else if (stk->dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM))
pdev->conf.Vpp = stk->dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; pdev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
if ((cfg->io.nwin > 0) || (stk->dflt.io.nwin > 0)) { if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &stk->dflt.io; cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
pdev->io.BasePort1 = io->win[0].base; pdev->io.BasePort1 = io->win[0].base;
pdev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; pdev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK;
if (!(io->flags & CISTPL_IO_16BIT)) if (!(io->flags & CISTPL_IO_16BIT))
@@ -190,23 +192,19 @@ static int pcmcia_check_one_config(struct pcmcia_device *pdev,
pdev->io.BasePort2 = io->win[1].base; pdev->io.BasePort2 = io->win[1].base;
pdev->io.NumPorts2 = (stk->is_kme) ? 2 : 1; pdev->io.NumPorts2 = (stk->is_kme) ? 2 : 1;
if (pcmcia_request_io(pdev, &pdev->io) != 0) if (pcmcia_request_io(pdev, &pdev->io) != 0)
goto next_entry; return -ENODEV;
stk->ctl_base = pdev->io.BasePort2; stk->ctl_base = pdev->io.BasePort2;
} else if ((io->nwin == 1) && (io->win[0].len >= 16)) { } else if ((io->nwin == 1) && (io->win[0].len >= 16)) {
pdev->io.NumPorts1 = io->win[0].len; pdev->io.NumPorts1 = io->win[0].len;
pdev->io.NumPorts2 = 0; pdev->io.NumPorts2 = 0;
if (pcmcia_request_io(pdev, &pdev->io) != 0) if (pcmcia_request_io(pdev, &pdev->io) != 0)
goto next_entry; return -ENODEV;
stk->ctl_base = pdev->io.BasePort1 + 0x0e; stk->ctl_base = pdev->io.BasePort1 + 0x0e;
} else } else
goto next_entry; return -ENODEV;
/* If we've got this far, we're done */ /* If we've got this far, we're done */
return 0; return 0;
} }
next_entry:
if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
memcpy(&stk->dflt, cfg, sizeof(stk->dflt));
return -ENODEV; return -ENODEV;
} }
@@ -264,7 +262,6 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(pdev, &stk->conf)); CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(pdev, &stk->conf));
stk->skip_vcc = io_base = ctl_base = 0; stk->skip_vcc = io_base = ctl_base = 0;
if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) { if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) {
memset(&stk->dflt, 0, sizeof(stk->dflt));
stk->skip_vcc = 1; stk->skip_vcc = 1;
if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk))
goto failed; /* No suitable config found */ goto failed; /* No suitable config found */
+2
View File
@@ -680,6 +680,7 @@ static void bt3c_detach(struct pcmcia_device *link)
static int bt3c_check_config(struct pcmcia_device *p_dev, static int bt3c_check_config(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
unsigned long try = (unsigned long) priv_data; unsigned long try = (unsigned long) priv_data;
@@ -699,6 +700,7 @@ static int bt3c_check_config(struct pcmcia_device *p_dev,
static int bt3c_check_config_notpicky(struct pcmcia_device *p_dev, static int bt3c_check_config_notpicky(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
+2
View File
@@ -609,6 +609,7 @@ static void btuart_detach(struct pcmcia_device *link)
static int btuart_check_config(struct pcmcia_device *p_dev, static int btuart_check_config(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
unsigned long try = (unsigned long) priv_data; unsigned long try = (unsigned long) priv_data;
@@ -628,6 +629,7 @@ static int btuart_check_config(struct pcmcia_device *p_dev,
static int btuart_check_config_notpicky(struct pcmcia_device *p_dev, static int btuart_check_config_notpicky(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
+1
View File
@@ -592,6 +592,7 @@ static void dtl1_detach(struct pcmcia_device *link)
static int dtl1_confcheck(struct pcmcia_device *p_dev, static int dtl1_confcheck(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
if ((cf->io.nwin == 1) && (cf->io.win[0].len > 8)) { if ((cf->io.nwin == 1) && (cf->io.win[0].len > 8)) {
+1
View File
@@ -1761,6 +1761,7 @@ static void cmm_cm4000_release(struct pcmcia_device * link)
static int cm4000_config_check(struct pcmcia_device *p_dev, static int cm4000_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
if (!cfg->io.nwin) if (!cfg->io.nwin)
+1
View File
@@ -528,6 +528,7 @@ static void cm4040_reader_release(struct pcmcia_device *link)
static int cm4040_config_check(struct pcmcia_device *p_dev, static int cm4040_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
int rc; int rc;
+15 -18
View File
@@ -222,7 +222,6 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
struct pcmcia_config_check { struct pcmcia_config_check {
config_info_t conf; config_info_t conf;
cistpl_cftable_entry_t dflt;
unsigned long ctl_base; unsigned long ctl_base;
int skip_vcc; int skip_vcc;
int is_kme; int is_kme;
@@ -230,6 +229,7 @@ struct pcmcia_config_check {
static int pcmcia_check_one_config(struct pcmcia_device *pdev, static int pcmcia_check_one_config(struct pcmcia_device *pdev,
cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
struct pcmcia_config_check *stk = priv_data; struct pcmcia_config_check *stk = priv_data;
@@ -237,21 +237,23 @@ static int pcmcia_check_one_config(struct pcmcia_device *pdev,
/* Check for matching Vcc, unless we're desperate */ /* Check for matching Vcc, unless we're desperate */
if (!stk->skip_vcc) { if (!stk->skip_vcc) {
if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
if (stk->conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) if (stk->conf.Vcc !=
goto next_entry; cfg->vcc.param[CISTPL_POWER_VNOM] / 10000)
} else if (stk->dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { return -ENODEV;
if (stk->conf.Vcc != stk->dflt.vcc.param[CISTPL_POWER_VNOM] / 10000) } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
goto next_entry; if (stk->conf.Vcc !=
dflt->vcc.param[CISTPL_POWER_VNOM] / 10000)
return -ENODEV;
} }
} }
if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
pdev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; pdev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
else if (stk->dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM))
pdev->conf.Vpp = stk->dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; pdev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
if ((cfg->io.nwin > 0) || (stk->dflt.io.nwin > 0)) { if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &stk->dflt.io; cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
pdev->conf.ConfigIndex = cfg->index; pdev->conf.ConfigIndex = cfg->index;
pdev->io.BasePort1 = io->win[0].base; pdev->io.BasePort1 = io->win[0].base;
pdev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; pdev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK;
@@ -262,23 +264,19 @@ static int pcmcia_check_one_config(struct pcmcia_device *pdev,
pdev->io.BasePort2 = io->win[1].base; pdev->io.BasePort2 = io->win[1].base;
pdev->io.NumPorts2 = (stk->is_kme) ? 2 : 1; pdev->io.NumPorts2 = (stk->is_kme) ? 2 : 1;
if (pcmcia_request_io(pdev, &pdev->io) != 0) if (pcmcia_request_io(pdev, &pdev->io) != 0)
goto next_entry; return -ENODEV;
stk->ctl_base = pdev->io.BasePort2; stk->ctl_base = pdev->io.BasePort2;
} else if ((io->nwin == 1) && (io->win[0].len >= 16)) { } else if ((io->nwin == 1) && (io->win[0].len >= 16)) {
pdev->io.NumPorts1 = io->win[0].len; pdev->io.NumPorts1 = io->win[0].len;
pdev->io.NumPorts2 = 0; pdev->io.NumPorts2 = 0;
if (pcmcia_request_io(pdev, &pdev->io) != 0) if (pcmcia_request_io(pdev, &pdev->io) != 0)
goto next_entry; return -ENODEV;
stk->ctl_base = pdev->io.BasePort1 + 0x0e; stk->ctl_base = pdev->io.BasePort1 + 0x0e;
} else } else
goto next_entry; return -ENODEV;
/* If we've got this far, we're done */ /* If we've got this far, we're done */
return 0; return 0;
} }
next_entry:
if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
memcpy(&stk->dflt, cfg, sizeof(stk->dflt));
return -ENODEV; return -ENODEV;
} }
@@ -305,7 +303,6 @@ static int ide_config(struct pcmcia_device *link)
CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &stk->conf)); CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &stk->conf));
stk->skip_vcc = io_base = ctl_base = 0; stk->skip_vcc = io_base = ctl_base = 0;
if (pcmcia_loop_config(link, pcmcia_check_one_config, stk)) { if (pcmcia_loop_config(link, pcmcia_check_one_config, stk)) {
memset(&stk->dflt, 0, sizeof(stk->dflt));
stk->skip_vcc = 1; stk->skip_vcc = 1;
if (pcmcia_loop_config(link, pcmcia_check_one_config, stk)) if (pcmcia_loop_config(link, pcmcia_check_one_config, stk))
goto failed; /* No suitable config found */ goto failed; /* No suitable config found */
+1
View File
@@ -156,6 +156,7 @@ static void avmcs_detach(struct pcmcia_device *link)
static int avmcs_configcheck(struct pcmcia_device *p_dev, static int avmcs_configcheck(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
if (cf->io.nwin <= 0) if (cf->io.nwin <= 0)
+3 -2
View File
@@ -175,8 +175,9 @@ static void avma1cs_detach(struct pcmcia_device *link)
======================================================================*/ ======================================================================*/
static int avma1cs_configcheck(struct pcmcia_device *p_dev, static int avma1cs_configcheck(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *cf,
void *priv_data) cistpl_cftable_entry_t *dflt,
void *priv_data)
{ {
if (cf->io.nwin <= 0) if (cf->io.nwin <= 0)
return -ENODEV; return -ENODEV;
+1
View File
@@ -206,6 +206,7 @@ static void elsa_cs_detach(struct pcmcia_device *link)
static int elsa_cs_configcheck(struct pcmcia_device *p_dev, static int elsa_cs_configcheck(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
int j; int j;
+13 -13
View File
@@ -218,19 +218,17 @@ static void sedlbauer_detach(struct pcmcia_device *link)
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
struct sedlbauer_config_data { struct sedlbauer_config_data {
cistpl_cftable_entry_t dflt;
config_info_t conf; config_info_t conf;
win_req_t req; win_req_t req;
}; };
static int sedlbauer_config_check(struct pcmcia_device *p_dev, static int sedlbauer_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
struct sedlbauer_config_data *cfg_mem = priv_data; struct sedlbauer_config_data *cfg_mem = priv_data;
if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
cfg_mem->dflt = *cfg;
if (cfg->index == 0) if (cfg->index == 0)
return -ENODEV; return -ENODEV;
@@ -243,26 +241,28 @@ static int sedlbauer_config_check(struct pcmcia_device *p_dev,
/* Use power settings for Vcc and Vpp if present */ /* Use power settings for Vcc and Vpp if present */
/* Note that the CIS values need to be rescaled */ /* Note that the CIS values need to be rescaled */
if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) { if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) {
if (cfg_mem->conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000) if (cfg_mem->conf.Vcc !=
cfg->vcc.param[CISTPL_POWER_VNOM]/10000)
return -ENODEV; return -ENODEV;
} else if (cfg_mem->dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) { } else if (dflt->vcc.present & (1<<CISTPL_POWER_VNOM)) {
if (cfg_mem->conf.Vcc != cfg_mem->dflt.vcc.param[CISTPL_POWER_VNOM]/10000) if (cfg_mem->conf.Vcc !=
dflt->vcc.param[CISTPL_POWER_VNOM]/10000)
return -ENODEV; return -ENODEV;
} }
if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM))
p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000;
else if (cfg_mem->dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM))
p_dev->conf.Vpp = cfg_mem->dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000;
/* Do we need to allocate an interrupt? */ /* Do we need to allocate an interrupt? */
if (cfg->irq.IRQInfo1 || cfg_mem->dflt.irq.IRQInfo1) if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
p_dev->conf.Attributes |= CONF_ENABLE_IRQ; p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
/* IO window settings */ /* IO window settings */
p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
if ((cfg->io.nwin > 0) || (cfg_mem->dflt.io.nwin > 0)) { if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &cfg_mem->dflt.io; cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
if (!(io->flags & CISTPL_IO_8BIT)) if (!(io->flags & CISTPL_IO_8BIT))
p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
@@ -291,8 +291,8 @@ static int sedlbauer_config_check(struct pcmcia_device *p_dev,
needs to be mapped to virtual space with ioremap() before it needs to be mapped to virtual space with ioremap() before it
is used. is used.
*/ */
if ((cfg->mem.nwin > 0) || (cfg_mem->dflt.mem.nwin > 0)) { if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) {
cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &cfg_mem->dflt.mem; cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &dflt->mem;
memreq_t map; memreq_t map;
cfg_mem->req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; cfg_mem->req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM;
cfg_mem->req.Attributes |= WIN_ENABLE; cfg_mem->req.Attributes |= WIN_ENABLE;
+1
View File
@@ -196,6 +196,7 @@ static void teles_detach(struct pcmcia_device *link)
static int teles_cs_configcheck(struct pcmcia_device *p_dev, static int teles_cs_configcheck(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
int j; int j;
+1
View File
@@ -286,6 +286,7 @@ static int try_io_port(struct pcmcia_device *link)
static int axnet_configcheck(struct pcmcia_device *p_dev, static int axnet_configcheck(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
int i; int i;
+1
View File
@@ -514,6 +514,7 @@ static int try_io_port(struct pcmcia_device *link)
static int pcnet_confcheck(struct pcmcia_device *p_dev, static int pcnet_confcheck(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
int *has_shmem = priv_data; int *has_shmem = priv_data;
+2
View File
@@ -461,6 +461,7 @@ static int mhz_3288_power(struct pcmcia_device *link)
static int mhz_mfc_config_check(struct pcmcia_device *p_dev, static int mhz_mfc_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
int k; int k;
@@ -651,6 +652,7 @@ static int mot_setup(struct pcmcia_device *link)
static int smc_configcheck(struct pcmcia_device *p_dev, static int smc_configcheck(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
p_dev->io.BasePort1 = cf->io.win[0].base; p_dev->io.BasePort1 = cf->io.win[0].base;
+2
View File
@@ -718,6 +718,7 @@ has_ce2_string(struct pcmcia_device * p_dev)
static int static int
xirc2ps_config_modem(struct pcmcia_device *p_dev, xirc2ps_config_modem(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
unsigned int ioaddr; unsigned int ioaddr;
@@ -736,6 +737,7 @@ xirc2ps_config_modem(struct pcmcia_device *p_dev,
static int static int
xirc2ps_config_check(struct pcmcia_device *p_dev, xirc2ps_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *cf,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
int *pass = priv_data; int *pass = priv_data;
+22 -29
View File
@@ -206,19 +206,12 @@ static void airo_detach(struct pcmcia_device *link)
#define CS_CHECK(fn, ret) \ #define CS_CHECK(fn, ret) \
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
struct airo_cs_config_data {
cistpl_cftable_entry_t dflt;
win_req_t req;
};
static int airo_cs_config_check(struct pcmcia_device *p_dev, static int airo_cs_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
struct airo_cs_config_data *cfg_mem = priv_data; win_req_t *req = priv_data;
if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
cfg_mem->dflt = *cfg;
if (cfg->index == 0) if (cfg->index == 0)
return -ENODEV; return -ENODEV;
@@ -233,17 +226,17 @@ static int airo_cs_config_check(struct pcmcia_device *p_dev,
/* Note that the CIS values need to be rescaled */ /* Note that the CIS values need to be rescaled */
if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM))
p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000;
else if (cfg_mem->dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM))
p_dev->conf.Vpp = cfg_mem->dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000;
/* Do we need to allocate an interrupt? */ /* Do we need to allocate an interrupt? */
if (cfg->irq.IRQInfo1 || cfg_mem->dflt.irq.IRQInfo1) if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
p_dev->conf.Attributes |= CONF_ENABLE_IRQ; p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
/* IO window settings */ /* IO window settings */
p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
if ((cfg->io.nwin > 0) || (cfg_mem->dflt.io.nwin > 0)) { if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &cfg_mem->dflt.io; cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
if (!(io->flags & CISTPL_IO_8BIT)) if (!(io->flags & CISTPL_IO_8BIT))
p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
@@ -273,14 +266,14 @@ static int airo_cs_config_check(struct pcmcia_device *p_dev,
needs to be mapped to virtual space with ioremap() before it needs to be mapped to virtual space with ioremap() before it
is used. is used.
*/ */
if ((cfg->mem.nwin > 0) || (cfg_mem->dflt.mem.nwin > 0)) { if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) {
cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &cfg_mem->dflt.mem; cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &dflt->mem;
memreq_t map; memreq_t map;
cfg_mem->req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; req->Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM;
cfg_mem->req.Base = mem->win[0].host_addr; req->Base = mem->win[0].host_addr;
cfg_mem->req.Size = mem->win[0].len; req->Size = mem->win[0].len;
cfg_mem->req.AccessSpeed = 0; req->AccessSpeed = 0;
if (pcmcia_request_window(&p_dev, &cfg_mem->req, &p_dev->win) != 0) if (pcmcia_request_window(&p_dev, req, &p_dev->win) != 0)
return -ENODEV; return -ENODEV;
map.Page = 0; map.Page = 0;
map.CardOffset = mem->win[0].card_addr; map.CardOffset = mem->win[0].card_addr;
@@ -295,15 +288,15 @@ static int airo_cs_config_check(struct pcmcia_device *p_dev,
static int airo_config(struct pcmcia_device *link) static int airo_config(struct pcmcia_device *link)
{ {
local_info_t *dev; local_info_t *dev;
struct airo_cs_config_data *cfg_mem; win_req_t *req;
int last_fn, last_ret; int last_fn, last_ret;
dev = link->priv; dev = link->priv;
DEBUG(0, "airo_config(0x%p)\n", link); DEBUG(0, "airo_config(0x%p)\n", link);
cfg_mem = kzalloc(sizeof(struct airo_cs_config_data), GFP_KERNEL); req = kzalloc(sizeof(win_req_t), GFP_KERNEL);
if (!cfg_mem) if (!req)
return -ENOMEM; return -ENOMEM;
/* /*
@@ -320,7 +313,7 @@ static int airo_config(struct pcmcia_device *link)
* and most client drivers will only use the CIS to fill in * and most client drivers will only use the CIS to fill in
* implementation-defined details. * implementation-defined details.
*/ */
last_ret = pcmcia_loop_config(link, airo_cs_config_check, cfg_mem); last_ret = pcmcia_loop_config(link, airo_cs_config_check, req);
if (last_ret) if (last_ret)
goto failed; goto failed;
@@ -365,17 +358,17 @@ static int airo_config(struct pcmcia_device *link)
printk(" & 0x%04x-0x%04x", link->io.BasePort2, printk(" & 0x%04x-0x%04x", link->io.BasePort2,
link->io.BasePort2+link->io.NumPorts2-1); link->io.BasePort2+link->io.NumPorts2-1);
if (link->win) if (link->win)
printk(", mem 0x%06lx-0x%06lx", cfg_mem->req.Base, printk(", mem 0x%06lx-0x%06lx", req->Base,
cfg_mem->req.Base+cfg_mem->req.Size-1); req->Base+req->Size-1);
printk("\n"); printk("\n");
kfree(cfg_mem); kfree(req);
return 0; return 0;
cs_failed: cs_failed:
cs_error(link, last_fn, last_ret); cs_error(link, last_fn, last_ret);
failed: failed:
airo_release(link); airo_release(link);
kfree(cfg_mem); kfree(req);
return -ENODEV; return -ENODEV;
} /* airo_config */ } /* airo_config */
+3 -6
View File
@@ -226,14 +226,12 @@ static int card_present(void *arg)
static int atmel_config_check(struct pcmcia_device *p_dev, static int atmel_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
cistpl_cftable_entry_t *dflt = priv_data;
if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
*dflt = *cfg;
if (cfg->index == 0) if (cfg->index == 0)
return -ENODEV; return -ENODEV;
/* Does this card need audio output? */ /* Does this card need audio output? */
if (cfg->flags & CISTPL_CFTABLE_AUDIO) { if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
p_dev->conf.Attributes |= CONF_ENABLE_SPKR; p_dev->conf.Attributes |= CONF_ENABLE_SPKR;
@@ -278,7 +276,6 @@ static int atmel_config(struct pcmcia_device *link)
local_info_t *dev; local_info_t *dev;
int last_fn, last_ret; int last_fn, last_ret;
struct pcmcia_device_id *did; struct pcmcia_device_id *did;
cistpl_cftable_entry_t dflt = { 0 };
dev = link->priv; dev = link->priv;
did = handle_to_dev(link).driver_data; did = handle_to_dev(link).driver_data;
@@ -297,7 +294,7 @@ static int atmel_config(struct pcmcia_device *link)
these things without consulting the CIS, and most client drivers these things without consulting the CIS, and most client drivers
will only use the CIS to fill in implementation-defined details. will only use the CIS to fill in implementation-defined details.
*/ */
if (pcmcia_loop_config(link, atmel_config_check, &dflt)) if (pcmcia_loop_config(link, atmel_config_check, NULL))
goto failed; goto failed;
/* /*
+11 -13
View File
@@ -537,23 +537,21 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
* socket and make the device available to the system */ * socket and make the device available to the system */
struct prism2_config_data { struct prism2_config_data {
cistpl_cftable_entry_t dflt;
config_info_t conf; config_info_t conf;
}; };
static int prism2_config_check(struct pcmcia_device *p_dev, static int prism2_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
struct prism2_config_data *cfg_mem = priv_data; struct prism2_config_data *cfg_mem = priv_data;
if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
cfg_mem->dflt = *cfg;
if (cfg->index == 0) if (cfg->index == 0)
return -ENODEV; return -ENODEV;
PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X " PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X "
"(default 0x%02X)\n", cfg->index, cfg_mem->dflt.index); "(default 0x%02X)\n", cfg->index, dflt->index);
/* Does this card need audio output? */ /* Does this card need audio output? */
if (cfg->flags & CISTPL_CFTABLE_AUDIO) { if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
@@ -570,8 +568,8 @@ static int prism2_config_check(struct pcmcia_device *p_dev,
" this entry\n"); " this entry\n");
return -ENODEV; return -ENODEV;
} }
} else if (cfg_mem->dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
if (cfg_mem->conf.Vcc != cfg_mem->dflt.vcc.param[CISTPL_POWER_VNOM] / if (cfg_mem->conf.Vcc != dflt->vcc.param[CISTPL_POWER_VNOM] /
10000 && !ignore_cis_vcc) { 10000 && !ignore_cis_vcc) {
PDEBUG(DEBUG_EXTRA, " Vcc (default) mismatch " PDEBUG(DEBUG_EXTRA, " Vcc (default) mismatch "
"- skipping this entry\n"); "- skipping this entry\n");
@@ -581,11 +579,11 @@ static int prism2_config_check(struct pcmcia_device *p_dev,
if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
else if (cfg_mem->dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM))
p_dev->conf.Vpp = cfg_mem->dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
/* Do we need to allocate an interrupt? */ /* Do we need to allocate an interrupt? */
if (cfg->irq.IRQInfo1 || cfg_mem->dflt.irq.IRQInfo1) if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
p_dev->conf.Attributes |= CONF_ENABLE_IRQ; p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
else if (!(p_dev->conf.Attributes & CONF_ENABLE_IRQ)) { else if (!(p_dev->conf.Attributes & CONF_ENABLE_IRQ)) {
/* At least Compaq WL200 does not have IRQInfo1 set, /* At least Compaq WL200 does not have IRQInfo1 set,
@@ -597,11 +595,11 @@ static int prism2_config_check(struct pcmcia_device *p_dev,
/* IO window settings */ /* IO window settings */
PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d " PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d "
"cfg_mem->dflt.io.nwin=%d\n", "dflt->io.nwin=%d\n",
cfg->io.nwin, cfg_mem->dflt.io.nwin); cfg->io.nwin, dflt->io.nwin);
p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
if ((cfg->io.nwin > 0) || (cfg_mem->dflt.io.nwin > 0)) { if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &cfg_mem->dflt.io; cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
PDEBUG(DEBUG_EXTRA, "io->flags = 0x%04X, " PDEBUG(DEBUG_EXTRA, "io->flags = 0x%04X, "
"io.base=0x%04x, len=%d\n", io->flags, "io.base=0x%04x, len=%d\n", io->flags,
+8 -10
View File
@@ -165,18 +165,16 @@ static void orinoco_cs_detach(struct pcmcia_device *link)
} while (0) } while (0)
struct orinoco_cs_config_data { struct orinoco_cs_config_data {
cistpl_cftable_entry_t dflt;
config_info_t conf; config_info_t conf;
}; };
static int orinoco_cs_config_check(struct pcmcia_device *p_dev, static int orinoco_cs_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
void *priv_data) void *priv_data)
{ {
struct orinoco_cs_config_data *cfg_mem = priv_data; struct orinoco_cs_config_data *cfg_mem = priv_data;
if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
cfg_mem->dflt = *cfg;
if (cfg->index == 0) if (cfg->index == 0)
goto next_entry; goto next_entry;
@@ -188,9 +186,9 @@ static int orinoco_cs_config_check(struct pcmcia_device *p_dev,
if (!ignore_cis_vcc) if (!ignore_cis_vcc)
goto next_entry; goto next_entry;
} }
} else if (cfg_mem->dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
if (cfg_mem->conf.Vcc != cfg_mem->dflt.vcc.param[CISTPL_POWER_VNOM] / 10000) { if (cfg_mem->conf.Vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) {
DEBUG(2, "spectrum_cs_config: Vcc mismatch (cfg_mem->conf.Vcc = %d, CIS = %d)\n", cfg_mem->conf.Vcc, cfg_mem->dflt.vcc.param[CISTPL_POWER_VNOM] / 10000); DEBUG(2, "spectrum_cs_config: Vcc mismatch (cfg_mem->conf.Vcc = %d, CIS = %d)\n", cfg_mem->conf.Vcc, dflt->vcc.param[CISTPL_POWER_VNOM] / 10000);
if (!ignore_cis_vcc) if (!ignore_cis_vcc)
goto next_entry; goto next_entry;
} }
@@ -199,17 +197,17 @@ static int orinoco_cs_config_check(struct pcmcia_device *p_dev,
if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
p_dev->conf.Vpp = p_dev->conf.Vpp =
cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
else if (cfg_mem->dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM))
p_dev->conf.Vpp = p_dev->conf.Vpp =
cfg_mem->dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
/* Do we need to allocate an interrupt? */ /* Do we need to allocate an interrupt? */
p_dev->conf.Attributes |= CONF_ENABLE_IRQ; p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
/* IO window settings */ /* IO window settings */
p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
if ((cfg->io.nwin > 0) || (cfg_mem->dflt.io.nwin > 0)) { if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &cfg_mem->dflt.io; cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
if (!(io->flags & CISTPL_IO_8BIT)) if (!(io->flags & CISTPL_IO_8BIT))
p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16;

Some files were not shown because too many files have changed in this diff Show More