From 53efec9513cfb1acff602c7ebdd945d677808e9e Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 28 Jul 2008 19:44:05 +0200 Subject: pcmcia: only copy CIS override data once Instead of copying CIS override data in socket_sysfs.c or ds.c, and then again in cistpl.c, only do so once. Also, cisdump_t is now only used by the deprecated ioctl. Signed-off-by: Dominik Brodowski --- include/pcmcia/cistpl.h | 10 ++-------- include/pcmcia/ds.h | 6 ++++++ include/pcmcia/ss.h | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/pcmcia/cistpl.h b/include/pcmcia/cistpl.h index e2e10c1e9a06..552a332ad714 100644 --- a/include/pcmcia/cistpl.h +++ b/include/pcmcia/cistpl.h @@ -580,14 +580,8 @@ typedef struct cisinfo_t { #define CISTPL_MAX_CIS_SIZE 0x200 -/* For ReplaceCIS */ -typedef struct cisdump_t { - u_int Length; - cisdata_t Data[CISTPL_MAX_CIS_SIZE]; -} cisdump_t; - - -int pcmcia_replace_cis(struct pcmcia_socket *s, cisdump_t *cis); +int pcmcia_replace_cis(struct pcmcia_socket *s, + const u8 *data, const size_t len); /* don't use outside of PCMCIA core yet */ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int func, tuple_t *tuple); diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index b316027c853d..2d36a4f80e5b 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -68,6 +68,12 @@ typedef struct region_info_t { #define REGION_BAR_MASK 0xe000 #define REGION_BAR_SHIFT 13 +/* For ReplaceCIS */ +typedef struct cisdump_t { + u_int Length; + cisdata_t Data[CISTPL_MAX_CIS_SIZE]; +} cisdump_t; + typedef union ds_ioctl_arg_t { adjust_t adjust; config_info_t config; diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h index ed919dd9bb5c..e34bef0fc74f 100644 --- a/include/pcmcia/ss.h +++ b/include/pcmcia/ss.h @@ -199,8 +199,8 @@ struct pcmcia_socket { io_window_t io[MAX_IO_WIN]; window_t win[MAX_WIN]; struct list_head cis_cache; - u_int fake_cis_len; - char *fake_cis; + size_t fake_cis_len; + u8 *fake_cis; struct list_head socket_list; struct completion socket_released; -- cgit v1.2.3 From a804b574e6c7236222593046fc2b1b8bd0298fce Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Tue, 29 Jul 2008 08:38:30 +0200 Subject: pcmcia: add pcmcia_loop_config() helper By calling pcmcia_loop_config(), a pcmcia driver can iterate over all available configuration options. During a driver's probe() phase, one doesn't need to use pcmcia_get_{first,next}_tuple, pcmcia_get_tuple_data and pcmcia_parse_tuple directly in most if not all cases. Signed-off-by: Dominik Brodowski --- Documentation/pcmcia/driver-changes.txt | 6 ++++ drivers/pcmcia/pcmcia_resource.c | 62 +++++++++++++++++++++++++++++++++ include/pcmcia/cistpl.h | 6 ++++ 3 files changed, 74 insertions(+) (limited to 'include') diff --git a/Documentation/pcmcia/driver-changes.txt b/Documentation/pcmcia/driver-changes.txt index 96f155e68750..059934363caf 100644 --- a/Documentation/pcmcia/driver-changes.txt +++ b/Documentation/pcmcia/driver-changes.txt @@ -1,5 +1,11 @@ This file details changes in 2.6 which affect PCMCIA card driver authors: +* New configuration loop helper (as of 2.6.28) + By calling pcmcia_loop_config(), a driver can iterate over all available + configuration options. During a driver's probe() phase, one doesn't need + to use pcmcia_get_{first,next}_tuple, pcmcia_get_tuple_data and + pcmcia_parse_tuple directly in most if not all cases. + * New release helper (as of 2.6.17) Instead of calling pcmcia_release_{configuration,io,irq,win}, all that's necessary now is calling pcmcia_disable_device. As there is no valid diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 4884a18cf9e6..9f054bc847f2 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -909,3 +909,65 @@ void pcmcia_disable_device(struct pcmcia_device *p_dev) { pcmcia_release_window(p_dev->win); } EXPORT_SYMBOL(pcmcia_disable_device); + + +struct pcmcia_cfg_mem { + tuple_t tuple; + cisparse_t parse; + u8 buf[256]; +}; + +/** + * pcmcia_loop_config() - loop over configuration options + * @p_dev: the struct pcmcia_device which we need to loop for. + * @conf_check: function to call for each configuration option. + * It gets passed the struct pcmcia_device, the CIS data + * describing the configuration option, and private data + * being passed to pcmcia_loop_config() + * @priv_data: private data to be passed to the conf_check function. + * + * pcmcia_loop_config() loops over all configuration options, and calls + * the driver-specific conf_check() for each one, checking whether + * it is a valid one. + */ +int pcmcia_loop_config(struct pcmcia_device *p_dev, + int (*conf_check) (struct pcmcia_device *p_dev, + cistpl_cftable_entry_t *cfg, + void *priv_data), + void *priv_data) +{ + struct pcmcia_cfg_mem *cfg_mem; + tuple_t *tuple; + int ret = -ENODEV; + + cfg_mem = kzalloc(sizeof(struct pcmcia_cfg_mem), GFP_KERNEL); + if (cfg_mem == NULL) + return -ENOMEM; + + tuple = &cfg_mem->tuple; + tuple->TupleData = cfg_mem->buf; + tuple->TupleDataMax = 255; + tuple->TupleOffset = 0; + tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; + tuple->Attributes = 0; + + ret = pcmcia_get_first_tuple(p_dev, tuple); + while (!ret) { + if (pcmcia_get_tuple_data(p_dev, tuple)) + goto next_entry; + + if (pcmcia_parse_tuple(p_dev, tuple, &cfg_mem->parse)) + goto next_entry; + + ret = conf_check(p_dev, &cfg_mem->parse.cftable_entry, + priv_data); + if (!ret) + break; + +next_entry: + ret = pcmcia_get_next_tuple(p_dev, tuple); + } + + return ret; +} +EXPORT_SYMBOL(pcmcia_loop_config); diff --git a/include/pcmcia/cistpl.h b/include/pcmcia/cistpl.h index e2e10c1e9a06..b2eb914a18df 100644 --- a/include/pcmcia/cistpl.h +++ b/include/pcmcia/cistpl.h @@ -613,4 +613,10 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned #define pcmcia_validate_cis(p_dev, info) \ pccard_validate_cis(p_dev->socket, p_dev->func, info) +int pcmcia_loop_config(struct pcmcia_device *p_dev, + int (*conf_check) (struct pcmcia_device *p_dev, + cistpl_cftable_entry_t *cf, + void *priv_data), + void *priv_data); + #endif /* LINUX_CISTPL_H */ -- cgit v1.2.3 From 8e2fc39ddea7fe8c6798837da282db88a09af793 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sat, 2 Aug 2008 15:30:31 +0200 Subject: 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 --- drivers/ata/pata_pcmcia.c | 33 ++++++++++----------- drivers/bluetooth/bt3c_cs.c | 2 ++ drivers/bluetooth/btuart_cs.c | 2 ++ drivers/bluetooth/dtl1_cs.c | 1 + drivers/char/pcmcia/cm4000_cs.c | 1 + drivers/char/pcmcia/cm4040_cs.c | 1 + drivers/ide/legacy/ide-cs.c | 33 ++++++++++----------- drivers/isdn/hardware/avm/avm_cs.c | 1 + drivers/isdn/hisax/avma1_cs.c | 5 ++-- drivers/isdn/hisax/elsa_cs.c | 1 + drivers/isdn/hisax/sedlbauer_cs.c | 26 ++++++++--------- drivers/isdn/hisax/teles_cs.c | 1 + drivers/net/pcmcia/axnet_cs.c | 1 + drivers/net/pcmcia/pcnet_cs.c | 1 + drivers/net/pcmcia/smc91c92_cs.c | 2 ++ drivers/net/pcmcia/xirc2ps_cs.c | 2 ++ drivers/net/wireless/airo_cs.c | 51 ++++++++++++++------------------- drivers/net/wireless/atmel_cs.c | 9 ++---- drivers/net/wireless/hostap/hostap_cs.c | 24 +++++++--------- drivers/net/wireless/orinoco_cs.c | 18 ++++++------ drivers/net/wireless/spectrum_cs.c | 18 ++++++------ drivers/parport/parport_cs.c | 12 ++------ drivers/pcmcia/pcmcia_resource.c | 7 ++++- drivers/scsi/pcmcia/aha152x_stub.c | 5 ++-- drivers/scsi/pcmcia/fdomain_stub.c | 5 ++-- drivers/scsi/pcmcia/nsp_cs.c | 23 +++++++-------- drivers/scsi/pcmcia/qlogic_stub.c | 5 ++-- drivers/scsi/pcmcia/sym53c500_cs.c | 1 + drivers/serial/serial_cs.c | 4 +++ drivers/telephony/ixj_pcmcia.c | 8 ++---- drivers/usb/host/sl811_cs.c | 19 ++++++------ include/pcmcia/cistpl.h | 1 + 32 files changed, 158 insertions(+), 165 deletions(-) (limited to 'include') diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c index 4b8bd2021a9c..20982065a494 100644 --- a/drivers/ata/pata_pcmcia.c +++ b/drivers/ata/pata_pcmcia.c @@ -151,7 +151,6 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) struct pcmcia_config_check { config_info_t conf; - cistpl_cftable_entry_t dflt; unsigned long ctl_base; int skip_vcc; int is_kme; @@ -159,6 +158,7 @@ struct pcmcia_config_check { static int pcmcia_check_one_config(struct pcmcia_device *pdev, cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, void *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 */ if (!stk->skip_vcc) { if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { - if (stk->conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) - goto next_entry; - } else if (stk->dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { - if (stk->conf.Vcc != stk->dflt.vcc.param[CISTPL_POWER_VNOM] / 10000) - goto next_entry; + if (stk->conf.Vcc != + cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) + return -ENODEV; + } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { + if (stk->conf.Vcc != + dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) + return -ENODEV; } } if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) pdev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; - else if (stk->dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) - pdev->conf.Vpp = stk->dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; + else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) + pdev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; - if ((cfg->io.nwin > 0) || (stk->dflt.io.nwin > 0)) { - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &stk->dflt.io; + if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { + cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; pdev->io.BasePort1 = io->win[0].base; pdev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 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.NumPorts2 = (stk->is_kme) ? 2 : 1; if (pcmcia_request_io(pdev, &pdev->io) != 0) - goto next_entry; + return -ENODEV; stk->ctl_base = pdev->io.BasePort2; } else if ((io->nwin == 1) && (io->win[0].len >= 16)) { pdev->io.NumPorts1 = io->win[0].len; pdev->io.NumPorts2 = 0; if (pcmcia_request_io(pdev, &pdev->io) != 0) - goto next_entry; + return -ENODEV; stk->ctl_base = pdev->io.BasePort1 + 0x0e; } else - goto next_entry; + return -ENODEV; /* If we've got this far, we're done */ return 0; } -next_entry: - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) - memcpy(&stk->dflt, cfg, sizeof(stk->dflt)); - 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)); stk->skip_vcc = io_base = ctl_base = 0; if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) { - memset(&stk->dflt, 0, sizeof(stk->dflt)); stk->skip_vcc = 1; if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) goto failed; /* No suitable config found */ diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index 3436be152485..794a5ef9ea22 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c @@ -680,6 +680,7 @@ static void bt3c_detach(struct pcmcia_device *link) static int bt3c_check_config(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, + cistpl_cftable_entry_t *dflt, void *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, cistpl_cftable_entry_t *cf, + cistpl_cftable_entry_t *dflt, void *priv_data) { static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index 5e31ea2f2d6f..32017f96067c 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c @@ -609,6 +609,7 @@ static void btuart_detach(struct pcmcia_device *link) static int btuart_check_config(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, + cistpl_cftable_entry_t *dflt, void *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, cistpl_cftable_entry_t *cf, + cistpl_cftable_entry_t *dflt, void *priv_data) { static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index 1846e2aa9d4a..1830ebd6ca7b 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c @@ -592,6 +592,7 @@ static void dtl1_detach(struct pcmcia_device *link) static int dtl1_confcheck(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, + cistpl_cftable_entry_t *dflt, void *priv_data) { if ((cf->io.nwin == 1) && (cf->io.win[0].len > 8)) { diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c index 7eafd2f4dbb9..7785fbb4c0f6 100644 --- a/drivers/char/pcmcia/cm4000_cs.c +++ b/drivers/char/pcmcia/cm4000_cs.c @@ -1761,6 +1761,7 @@ static void cmm_cm4000_release(struct pcmcia_device * link) static int cm4000_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, void *priv_data) { if (!cfg->io.nwin) diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c index 71ca8c474c89..468ddef916b3 100644 --- a/drivers/char/pcmcia/cm4040_cs.c +++ b/drivers/char/pcmcia/cm4040_cs.c @@ -528,6 +528,7 @@ static void cm4040_reader_release(struct pcmcia_device *link) static int cm4040_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, void *priv_data) { int rc; diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index 8580becf226a..cc8eeaf80275 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c @@ -222,7 +222,6 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) struct pcmcia_config_check { config_info_t conf; - cistpl_cftable_entry_t dflt; unsigned long ctl_base; int skip_vcc; int is_kme; @@ -230,6 +229,7 @@ struct pcmcia_config_check { static int pcmcia_check_one_config(struct pcmcia_device *pdev, cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, void *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 */ if (!stk->skip_vcc) { if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { - if (stk->conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) - goto next_entry; - } else if (stk->dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { - if (stk->conf.Vcc != stk->dflt.vcc.param[CISTPL_POWER_VNOM] / 10000) - goto next_entry; + if (stk->conf.Vcc != + cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) + return -ENODEV; + } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { + if (stk->conf.Vcc != + dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) + return -ENODEV; } } if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) pdev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; - else if (stk->dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) - pdev->conf.Vpp = stk->dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; + else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) + pdev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; - if ((cfg->io.nwin > 0) || (stk->dflt.io.nwin > 0)) { - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &stk->dflt.io; + if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { + cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; pdev->conf.ConfigIndex = cfg->index; pdev->io.BasePort1 = io->win[0].base; 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.NumPorts2 = (stk->is_kme) ? 2 : 1; if (pcmcia_request_io(pdev, &pdev->io) != 0) - goto next_entry; + return -ENODEV; stk->ctl_base = pdev->io.BasePort2; } else if ((io->nwin == 1) && (io->win[0].len >= 16)) { pdev->io.NumPorts1 = io->win[0].len; pdev->io.NumPorts2 = 0; if (pcmcia_request_io(pdev, &pdev->io) != 0) - goto next_entry; + return -ENODEV; stk->ctl_base = pdev->io.BasePort1 + 0x0e; } else - goto next_entry; + return -ENODEV; /* If we've got this far, we're done */ return 0; } -next_entry: - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) - memcpy(&stk->dflt, cfg, sizeof(stk->dflt)); - return -ENODEV; } @@ -305,7 +303,6 @@ static int ide_config(struct pcmcia_device *link) CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &stk->conf)); stk->skip_vcc = io_base = ctl_base = 0; if (pcmcia_loop_config(link, pcmcia_check_one_config, stk)) { - memset(&stk->dflt, 0, sizeof(stk->dflt)); stk->skip_vcc = 1; if (pcmcia_loop_config(link, pcmcia_check_one_config, stk)) goto failed; /* No suitable config found */ diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c index 3569c68dc942..a8d6949338cd 100644 --- a/drivers/isdn/hardware/avm/avm_cs.c +++ b/drivers/isdn/hardware/avm/avm_cs.c @@ -156,6 +156,7 @@ static void avmcs_detach(struct pcmcia_device *link) static int avmcs_configcheck(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, + cistpl_cftable_entry_t *dflt, void *priv_data) { if (cf->io.nwin <= 0) diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c index 76164d6a3c89..7ce1aabb0aeb 100644 --- a/drivers/isdn/hisax/avma1_cs.c +++ b/drivers/isdn/hisax/avma1_cs.c @@ -175,8 +175,9 @@ static void avma1cs_detach(struct pcmcia_device *link) ======================================================================*/ static int avma1cs_configcheck(struct pcmcia_device *p_dev, - cistpl_cftable_entry_t *cf, - void *priv_data) + cistpl_cftable_entry_t *cf, + cistpl_cftable_entry_t *dflt, + void *priv_data) { if (cf->io.nwin <= 0) return -ENODEV; diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c index c9899e51a262..29c55b0b86b4 100644 --- a/drivers/isdn/hisax/elsa_cs.c +++ b/drivers/isdn/hisax/elsa_cs.c @@ -206,6 +206,7 @@ static void elsa_cs_detach(struct pcmcia_device *link) static int elsa_cs_configcheck(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, + cistpl_cftable_entry_t *dflt, void *priv_data) { int j; diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c index 2c611f91cfba..2746acbd8b70 100644 --- a/drivers/isdn/hisax/sedlbauer_cs.c +++ b/drivers/isdn/hisax/sedlbauer_cs.c @@ -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) struct sedlbauer_config_data { - cistpl_cftable_entry_t dflt; config_info_t conf; win_req_t req; }; static int sedlbauer_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, void *priv_data) { struct sedlbauer_config_data *cfg_mem = priv_data; - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) - cfg_mem->dflt = *cfg; if (cfg->index == 0) 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 */ /* Note that the CIS values need to be rescaled */ if (cfg->vcc.present & (1<conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000) + if (cfg_mem->conf.Vcc != + cfg->vcc.param[CISTPL_POWER_VNOM]/10000) return -ENODEV; - } else if (cfg_mem->dflt.vcc.present & (1<conf.Vcc != cfg_mem->dflt.vcc.param[CISTPL_POWER_VNOM]/10000) + } else if (dflt->vcc.present & (1<conf.Vcc != + dflt->vcc.param[CISTPL_POWER_VNOM]/10000) return -ENODEV; } if (cfg->vpp1.present & (1<conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; - else if (cfg_mem->dflt.vpp1.present & (1<conf.Vpp = cfg_mem->dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; + else if (dflt->vpp1.present & (1<conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000; /* 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; /* IO window settings */ p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; - if ((cfg->io.nwin > 0) || (cfg_mem->dflt.io.nwin > 0)) { - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &cfg_mem->dflt.io; + if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { + cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; if (!(io->flags & CISTPL_IO_8BIT)) 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 is used. */ - if ((cfg->mem.nwin > 0) || (cfg_mem->dflt.mem.nwin > 0)) { - cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &cfg_mem->dflt.mem; + if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) { + cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &dflt->mem; memreq_t map; cfg_mem->req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; cfg_mem->req.Attributes |= WIN_ENABLE; diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c index ecb75ae8a399..f4f2e2231a9b 100644 --- a/drivers/isdn/hisax/teles_cs.c +++ b/drivers/isdn/hisax/teles_cs.c @@ -196,6 +196,7 @@ static void teles_detach(struct pcmcia_device *link) static int teles_cs_configcheck(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, + cistpl_cftable_entry_t *dflt, void *priv_data) { int j; diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c index 04ece0b77d1d..c99dc5d54d19 100644 --- a/drivers/net/pcmcia/axnet_cs.c +++ b/drivers/net/pcmcia/axnet_cs.c @@ -286,6 +286,7 @@ static int try_io_port(struct pcmcia_device *link) static int axnet_configcheck(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, void *priv_data) { int i; diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index a60608722495..10fc537804b0 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c @@ -514,6 +514,7 @@ static int try_io_port(struct pcmcia_device *link) static int pcnet_confcheck(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, void *priv_data) { int *has_shmem = priv_data; diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index 1e595038a492..05bca83c5e27 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c @@ -461,6 +461,7 @@ static int mhz_3288_power(struct pcmcia_device *link) static int mhz_mfc_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, + cistpl_cftable_entry_t *dflt, void *priv_data) { int k; @@ -651,6 +652,7 @@ static int mot_setup(struct pcmcia_device *link) static int smc_configcheck(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, + cistpl_cftable_entry_t *dflt, void *priv_data) { p_dev->io.BasePort1 = cf->io.win[0].base; diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c index b0de704f229c..a16efa49b855 100644 --- a/drivers/net/pcmcia/xirc2ps_cs.c +++ b/drivers/net/pcmcia/xirc2ps_cs.c @@ -718,6 +718,7 @@ has_ce2_string(struct pcmcia_device * p_dev) static int xirc2ps_config_modem(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, + cistpl_cftable_entry_t *dflt, void *priv_data) { unsigned int ioaddr; @@ -736,6 +737,7 @@ xirc2ps_config_modem(struct pcmcia_device *p_dev, static int xirc2ps_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, + cistpl_cftable_entry_t *dflt, void *priv_data) { int *pass = priv_data; diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c index d7216730f18e..657adf85ab77 100644 --- a/drivers/net/wireless/airo_cs.c +++ b/drivers/net/wireless/airo_cs.c @@ -206,19 +206,12 @@ static void airo_detach(struct pcmcia_device *link) #define CS_CHECK(fn, ret) \ 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, cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, void *priv_data) { - struct airo_cs_config_data *cfg_mem = priv_data; - - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) - cfg_mem->dflt = *cfg; + win_req_t *req = priv_data; if (cfg->index == 0) 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 */ if (cfg->vpp1.present & (1<conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; - else if (cfg_mem->dflt.vpp1.present & (1<conf.Vpp = cfg_mem->dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; + else if (dflt->vpp1.present & (1<conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000; /* 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; /* IO window settings */ p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; - if ((cfg->io.nwin > 0) || (cfg_mem->dflt.io.nwin > 0)) { - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &cfg_mem->dflt.io; + if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { + cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; if (!(io->flags & CISTPL_IO_8BIT)) 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 is used. */ - if ((cfg->mem.nwin > 0) || (cfg_mem->dflt.mem.nwin > 0)) { - cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &cfg_mem->dflt.mem; + if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) { + cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &dflt->mem; memreq_t map; - cfg_mem->req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; - cfg_mem->req.Base = mem->win[0].host_addr; - cfg_mem->req.Size = mem->win[0].len; - cfg_mem->req.AccessSpeed = 0; - if (pcmcia_request_window(&p_dev, &cfg_mem->req, &p_dev->win) != 0) + req->Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; + req->Base = mem->win[0].host_addr; + req->Size = mem->win[0].len; + req->AccessSpeed = 0; + if (pcmcia_request_window(&p_dev, req, &p_dev->win) != 0) return -ENODEV; map.Page = 0; 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) { local_info_t *dev; - struct airo_cs_config_data *cfg_mem; + win_req_t *req; int last_fn, last_ret; dev = link->priv; DEBUG(0, "airo_config(0x%p)\n", link); - cfg_mem = kzalloc(sizeof(struct airo_cs_config_data), GFP_KERNEL); - if (!cfg_mem) + req = kzalloc(sizeof(win_req_t), GFP_KERNEL); + if (!req) 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 * 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) goto failed; @@ -365,17 +358,17 @@ static int airo_config(struct pcmcia_device *link) printk(" & 0x%04x-0x%04x", link->io.BasePort2, link->io.BasePort2+link->io.NumPorts2-1); if (link->win) - printk(", mem 0x%06lx-0x%06lx", cfg_mem->req.Base, - cfg_mem->req.Base+cfg_mem->req.Size-1); + printk(", mem 0x%06lx-0x%06lx", req->Base, + req->Base+req->Size-1); printk("\n"); - kfree(cfg_mem); + kfree(req); return 0; cs_failed: cs_error(link, last_fn, last_ret); failed: airo_release(link); - kfree(cfg_mem); + kfree(req); return -ENODEV; } /* airo_config */ diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c index 12efd44d64a1..c71aae992ecc 100644 --- a/drivers/net/wireless/atmel_cs.c +++ b/drivers/net/wireless/atmel_cs.c @@ -226,14 +226,12 @@ static int card_present(void *arg) static int atmel_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, void *priv_data) { - cistpl_cftable_entry_t *dflt = priv_data; - - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) - *dflt = *cfg; if (cfg->index == 0) return -ENODEV; + /* Does this card need audio output? */ if (cfg->flags & CISTPL_CFTABLE_AUDIO) { p_dev->conf.Attributes |= CONF_ENABLE_SPKR; @@ -278,7 +276,6 @@ static int atmel_config(struct pcmcia_device *link) local_info_t *dev; int last_fn, last_ret; struct pcmcia_device_id *did; - cistpl_cftable_entry_t dflt = { 0 }; dev = link->priv; 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 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; /* diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c index 2abaa90b799d..f9595ca71a06 100644 --- a/drivers/net/wireless/hostap/hostap_cs.c +++ b/drivers/net/wireless/hostap/hostap_cs.c @@ -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 */ struct prism2_config_data { - cistpl_cftable_entry_t dflt; config_info_t conf; }; static int prism2_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, void *priv_data) { struct prism2_config_data *cfg_mem = priv_data; - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) - cfg_mem->dflt = *cfg; if (cfg->index == 0) return -ENODEV; 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? */ if (cfg->flags & CISTPL_CFTABLE_AUDIO) { @@ -570,8 +568,8 @@ static int prism2_config_check(struct pcmcia_device *p_dev, " this entry\n"); return -ENODEV; } - } else if (cfg_mem->dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { - if (cfg_mem->conf.Vcc != cfg_mem->dflt.vcc.param[CISTPL_POWER_VNOM] / + } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { + if (cfg_mem->conf.Vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000 && !ignore_cis_vcc) { PDEBUG(DEBUG_EXTRA, " Vcc (default) mismatch " "- 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)) p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; - else if (cfg_mem->dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) - p_dev->conf.Vpp = cfg_mem->dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; + else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) + p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; /* 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; else if (!(p_dev->conf.Attributes & CONF_ENABLE_IRQ)) { /* 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 */ PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d " - "cfg_mem->dflt.io.nwin=%d\n", - cfg->io.nwin, cfg_mem->dflt.io.nwin); + "dflt->io.nwin=%d\n", + cfg->io.nwin, dflt->io.nwin); p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; - if ((cfg->io.nwin > 0) || (cfg_mem->dflt.io.nwin > 0)) { - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &cfg_mem->dflt.io; + if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { + cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; PDEBUG(DEBUG_EXTRA, "io->flags = 0x%04X, " "io.base=0x%04x, len=%d\n", io->flags, diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c index 67a172dfb2db..8a367f96db37 100644 --- a/drivers/net/wireless/orinoco_cs.c +++ b/drivers/net/wireless/orinoco_cs.c @@ -165,18 +165,16 @@ static void orinoco_cs_detach(struct pcmcia_device *link) } while (0) struct orinoco_cs_config_data { - cistpl_cftable_entry_t dflt; config_info_t conf; }; static int orinoco_cs_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, void *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) goto next_entry; @@ -188,9 +186,9 @@ static int orinoco_cs_config_check(struct pcmcia_device *p_dev, if (!ignore_cis_vcc) goto next_entry; } - } else if (cfg_mem->dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { - if (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, cfg_mem->dflt.vcc.param[CISTPL_POWER_VNOM] / 10000); + } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { + 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, dflt->vcc.param[CISTPL_POWER_VNOM] / 10000); if (!ignore_cis_vcc) 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)) 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; + dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; /* Do we need to allocate an interrupt? */ p_dev->conf.Attributes |= CONF_ENABLE_IRQ; /* IO window settings */ p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; - if ((cfg->io.nwin > 0) || (cfg_mem->dflt.io.nwin > 0)) { - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &cfg_mem->dflt.io; + if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { + cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; if (!(io->flags & CISTPL_IO_8BIT)) p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c index 7536aa91dad7..e28878dfaba3 100644 --- a/drivers/net/wireless/spectrum_cs.c +++ b/drivers/net/wireless/spectrum_cs.c @@ -634,18 +634,16 @@ static void spectrum_cs_detach(struct pcmcia_device *link) */ struct spectrum_cs_config_data { - cistpl_cftable_entry_t dflt; config_info_t conf; }; static int spectrum_cs_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, void *priv_data) { struct spectrum_cs_config_data *cfg_mem = priv_data; - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) - cfg_mem->dflt = *cfg; if (cfg->index == 0) goto next_entry; @@ -657,9 +655,9 @@ static int spectrum_cs_config_check(struct pcmcia_device *p_dev, if (!ignore_cis_vcc) goto next_entry; } - } else if (cfg_mem->dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { - if (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, cfg_mem->dflt.vcc.param[CISTPL_POWER_VNOM] / 10000); + } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { + 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, dflt->vcc.param[CISTPL_POWER_VNOM] / 10000); if (!ignore_cis_vcc) goto next_entry; } @@ -668,17 +666,17 @@ static int spectrum_cs_config_check(struct pcmcia_device *p_dev, if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 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; + dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; /* Do we need to allocate an interrupt? */ p_dev->conf.Attributes |= CONF_ENABLE_IRQ; /* IO window settings */ p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; - if ((cfg->io.nwin > 0) || (cfg_mem->dflt.io.nwin > 0)) { - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &cfg_mem->dflt.io; + if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { + cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; if (!(io->flags & CISTPL_IO_8BIT)) p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c index 814c5252d703..05f34e73694b 100644 --- a/drivers/parport/parport_cs.c +++ b/drivers/parport/parport_cs.c @@ -151,9 +151,9 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) static int parport_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, void *priv_data) { - cistpl_cftable_entry_t *dflt = priv_data; if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; if (epp_mode) @@ -166,26 +166,20 @@ static int parport_config_check(struct pcmcia_device *p_dev, p_dev->io.NumPorts2 = io->win[1].len; } if (pcmcia_request_io(p_dev, &p_dev->io) != 0) - goto next_entry; + return -ENODEV; return 0; } - -next_entry: - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) - *dflt = *cfg; - return -ENODEV; } static int parport_config(struct pcmcia_device *link) { parport_info_t *info = link->priv; - cistpl_cftable_entry_t dflt = { 0 }; struct parport *p; int last_ret, last_fn; DEBUG(0, "parport_config(0x%p)\n", link); - last_ret = pcmcia_loop_config(link, parport_config_check, &dflt); + last_ret = pcmcia_loop_config(link, parport_config_check, NULL); if (last_ret) { cs_error(link, RequestIO, last_ret); goto failed; diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index ba34ac8876ff..5ddfd46dea65 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -915,6 +915,7 @@ struct pcmcia_cfg_mem { tuple_t tuple; cisparse_t parse; u8 buf[256]; + cistpl_cftable_entry_t dflt; }; /** @@ -933,10 +934,12 @@ struct pcmcia_cfg_mem { int pcmcia_loop_config(struct pcmcia_device *p_dev, int (*conf_check) (struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, void *priv_data), void *priv_data) { struct pcmcia_cfg_mem *cfg_mem; + tuple_t *tuple; int ret = -ENODEV; @@ -963,8 +966,10 @@ int pcmcia_loop_config(struct pcmcia_device *p_dev, /* default values */ p_dev->conf.ConfigIndex = cfg->index; + if (cfg->flags & CISTPL_CFTABLE_DEFAULT) + cfg_mem->dflt = *cfg; - ret = conf_check(p_dev, cfg, priv_data); + ret = conf_check(p_dev, cfg, &cfg_mem->dflt, priv_data); if (!ret) break; diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c index 5e4d8e42ba0b..2ed3077b826a 100644 --- a/drivers/scsi/pcmcia/aha152x_stub.c +++ b/drivers/scsi/pcmcia/aha152x_stub.c @@ -141,8 +141,9 @@ static void aha152x_detach(struct pcmcia_device *link) do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) static int aha152x_config_check(struct pcmcia_device *p_dev, - cistpl_cftable_entry_t *cfg, - void *priv_data) + cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, + void *priv_data) { /* For New Media T&J, look for a SCSI window */ if (cfg->io.win[0].len >= 0x20) diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c index e3d6937c9200..2b6e92d7be07 100644 --- a/drivers/scsi/pcmcia/fdomain_stub.c +++ b/drivers/scsi/pcmcia/fdomain_stub.c @@ -124,8 +124,9 @@ static void fdomain_detach(struct pcmcia_device *link) do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) static int fdomain_config_check(struct pcmcia_device *p_dev, - cistpl_cftable_entry_t *cfg, - void *priv_data) + cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, + void *priv_data) { p_dev->io.BasePort1 = cfg->io.win[0].base; return pcmcia_request_io(p_dev, &p_dev->io); 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 { nsp_hw_data *data; win_req_t req; config_info_t conf; - cistpl_cftable_entry_t dflt; }; static int nsp_cs_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, void *priv_data) { struct nsp_cs_configdata *cfg_mem = priv_data; - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) - memcpy(&cfg_mem->dflt, cfg, sizeof(cistpl_cftable_entry_t)); if (cfg->index == 0) return -ENODEV; @@ -1637,28 +1635,27 @@ static int nsp_cs_config_check(struct pcmcia_device *p_dev, if (cfg->vcc.present & (1<conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000) return -ENODEV; - else if (cfg_mem->dflt.vcc.present & (1<conf.Vcc != cfg_mem->dflt.vcc.param[CISTPL_POWER_VNOM]/10000) + else if (dflt->vcc.present & (1<conf.Vcc != dflt->vcc.param[CISTPL_POWER_VNOM]/10000) return -ENODEV; } if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) { 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; + dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; } /* 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; - } /* IO window settings */ p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; - if ((cfg->io.nwin > 0) || (cfg_mem->dflt.io.nwin > 0)) { - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &cfg_mem->dflt.io; + if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { + cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; if (!(io->flags & CISTPL_IO_8BIT)) p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; @@ -1677,10 +1674,10 @@ static int nsp_cs_config_check(struct pcmcia_device *p_dev, goto next_entry; } - if ((cfg->mem.nwin > 0) || (cfg_mem->dflt.mem.nwin > 0)) { + if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) { memreq_t map; cistpl_mem_t *mem = - (cfg->mem.nwin) ? &cfg->mem : &cfg_mem->dflt.mem; + (cfg->mem.nwin) ? &cfg->mem : &dflt->mem; cfg_mem->req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; cfg_mem->req.Attributes |= WIN_ENABLE; cfg_mem->req.Base = mem->win[0].host_addr; diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c index a361275b20a3..da6b3603198b 100644 --- a/drivers/scsi/pcmcia/qlogic_stub.c +++ b/drivers/scsi/pcmcia/qlogic_stub.c @@ -196,8 +196,9 @@ static void qlogic_detach(struct pcmcia_device *link) do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) static int qlogic_config_check(struct pcmcia_device *p_dev, - cistpl_cftable_entry_t *cfg, - void *priv_data) + cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, + void *priv_data) { p_dev->io.BasePort1 = cfg->io.win[0].base; p_dev->io.NumPorts1 = cfg->io.win[0].len; diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c index 23a5219051a9..eba193134dfa 100644 --- a/drivers/scsi/pcmcia/sym53c500_cs.c +++ b/drivers/scsi/pcmcia/sym53c500_cs.c @@ -702,6 +702,7 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) static int SYM53C500_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, void *priv_data) { p_dev->io.BasePort1 = cfg->io.win[0].base; diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c index 693738160010..f8658686439d 100644 --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c @@ -443,6 +443,7 @@ first_tuple(struct pcmcia_device *handle, tuple_t * tuple, cisparse_t * parse) static int simple_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, + cistpl_cftable_entry_t *dflt, void *priv_data) { static const int size_table[2] = { 8, 16 }; @@ -465,6 +466,7 @@ static int simple_config_check(struct pcmcia_device *p_dev, static int simple_config_check_notpicky(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, + cistpl_cftable_entry_t *dflt, void *priv_data) { static const unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; @@ -546,6 +548,7 @@ found_port: static int multi_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, + cistpl_cftable_entry_t *dflt, void *priv_data) { int *base2 = priv_data; @@ -565,6 +568,7 @@ static int multi_config_check(struct pcmcia_device *p_dev, static int multi_config_check_notpicky(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, + cistpl_cftable_entry_t *dflt, void *priv_data) { int *base2 = priv_data; diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c index ba2c7a2125a0..b41df211b786 100644 --- a/drivers/telephony/ixj_pcmcia.c +++ b/drivers/telephony/ixj_pcmcia.c @@ -126,10 +126,9 @@ static void ixj_get_serial(struct pcmcia_device * link, IXJ * j) static int ixj_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, void *priv_data) { - cistpl_cftable_entry_t *dflt = priv_data; - if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; p_dev->io.BasePort1 = io->win[0].base; @@ -138,10 +137,7 @@ static int ixj_config_check(struct pcmcia_device *p_dev, p_dev->io.BasePort2 = io->win[1].base; p_dev->io.NumPorts2 = io->win[1].len; } - if (pcmcia_request_io(p_dev, &p_dev->io)) { - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) - *dflt = *cfg; - } else + if (!pcmcia_request_io(p_dev, &p_dev->io)) return 0; } return -ENODEV; diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c index 5b55c72c710b..78cc32e7b014 100644 --- a/drivers/usb/host/sl811_cs.c +++ b/drivers/usb/host/sl811_cs.c @@ -156,19 +156,16 @@ static void sl811_cs_release(struct pcmcia_device * link) } struct sl811_css_cfg { - cistpl_cftable_entry_t dflt; config_info_t conf; }; static int sl811_cs_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, void *priv_data) { struct sl811_css_cfg *cfg_mem = priv_data; - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) - memcpy(&cfg_mem->dflt, cfg, sizeof(cistpl_cftable_entry_t)); - if (cfg->index == 0) return -ENODEV; @@ -178,8 +175,8 @@ static int sl811_cs_config_check(struct pcmcia_device *p_dev, if (cfg->vcc.param[CISTPL_POWER_VNOM]/10000 != cfg_mem->conf.Vcc) return -ENODEV; - } else if (cfg_mem->dflt.vcc.present & (1<dflt.vcc.param[CISTPL_POWER_VNOM]/10000 + } else if (dflt->vcc.present & (1<vcc.param[CISTPL_POWER_VNOM]/10000 != cfg_mem->conf.Vcc) return -ENODEV; } @@ -187,18 +184,18 @@ static int sl811_cs_config_check(struct pcmcia_device *p_dev, if (cfg->vpp1.present & (1<conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; - else if (cfg_mem->dflt.vpp1.present & (1<vpp1.present & (1<conf.Vpp = - cfg_mem->dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; + dflt->vpp1.param[CISTPL_POWER_VNOM]/10000; /* we need 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; /* IO window settings */ p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; - if ((cfg->io.nwin > 0) || (cfg_mem->dflt.io.nwin > 0)) { - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &cfg_mem->dflt.io; + if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { + cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; diff --git a/include/pcmcia/cistpl.h b/include/pcmcia/cistpl.h index b2eb914a18df..0aa702705d00 100644 --- a/include/pcmcia/cistpl.h +++ b/include/pcmcia/cistpl.h @@ -616,6 +616,7 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned int pcmcia_loop_config(struct pcmcia_device *p_dev, int (*conf_check) (struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, + cistpl_cftable_entry_t *dflt, void *priv_data), void *priv_data); -- cgit v1.2.3 From ad913c11928f51abb6174f165db8d8d205b22e21 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sat, 2 Aug 2008 16:12:00 +0200 Subject: pcmcia: pcmcia_config_loop() improvement by passing vcc By passing the current Vcc setting to the pcmcia_config_loop callback function, we can remove pcmcia_get_configuration_info() calls from many drivers. Signed-off-by: Dominik Brodowski --- drivers/ata/pata_pcmcia.c | 12 ++++------ drivers/bluetooth/bt3c_cs.c | 2 ++ drivers/bluetooth/btuart_cs.c | 11 +++++---- drivers/bluetooth/dtl1_cs.c | 1 + drivers/char/pcmcia/cm4000_cs.c | 1 + drivers/char/pcmcia/cm4040_cs.c | 1 + drivers/ide/legacy/ide-cs.c | 12 ++++------ drivers/isdn/hardware/avm/avm_cs.c | 1 + drivers/isdn/hisax/avma1_cs.c | 1 + drivers/isdn/hisax/elsa_cs.c | 1 + drivers/isdn/hisax/sedlbauer_cs.c | 42 +++++++++++++-------------------- drivers/isdn/hisax/teles_cs.c | 1 + drivers/net/pcmcia/axnet_cs.c | 1 + drivers/net/pcmcia/pcnet_cs.c | 1 + drivers/net/pcmcia/smc91c92_cs.c | 2 ++ drivers/net/pcmcia/xirc2ps_cs.c | 2 ++ drivers/net/wireless/airo_cs.c | 1 + drivers/net/wireless/atmel_cs.c | 1 + drivers/net/wireless/hostap/hostap_cs.c | 23 ++++-------------- drivers/net/wireless/orinoco_cs.c | 28 +++++----------------- drivers/net/wireless/spectrum_cs.c | 28 +++++----------------- drivers/parport/parport_cs.c | 2 ++ drivers/pcmcia/pcmcia_resource.c | 7 +++++- drivers/scsi/pcmcia/aha152x_stub.c | 1 + drivers/scsi/pcmcia/fdomain_stub.c | 1 + drivers/scsi/pcmcia/nsp_cs.c | 8 +++---- drivers/scsi/pcmcia/qlogic_stub.c | 1 + drivers/scsi/pcmcia/sym53c500_cs.c | 1 + drivers/serial/serial_cs.c | 4 ++++ drivers/telephony/ixj_pcmcia.c | 1 + drivers/usb/host/sl811_cs.c | 35 +++++++-------------------- include/pcmcia/cistpl.h | 1 + 32 files changed, 93 insertions(+), 142 deletions(-) (limited to 'include') diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c index 20982065a494..6e4d31d8d14e 100644 --- a/drivers/ata/pata_pcmcia.c +++ b/drivers/ata/pata_pcmcia.c @@ -150,7 +150,6 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) struct pcmcia_config_check { - config_info_t conf; unsigned long ctl_base; int skip_vcc; int is_kme; @@ -159,6 +158,7 @@ struct pcmcia_config_check { static int pcmcia_check_one_config(struct pcmcia_device *pdev, cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { struct pcmcia_config_check *stk = priv_data; @@ -166,12 +166,10 @@ static int pcmcia_check_one_config(struct pcmcia_device *pdev, /* Check for matching Vcc, unless we're desperate */ if (!stk->skip_vcc) { if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { - if (stk->conf.Vcc != - cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) + if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) return -ENODEV; } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { - if (stk->conf.Vcc != - dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) + if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) return -ENODEV; } } @@ -257,10 +255,8 @@ static int pcmcia_init_one(struct pcmcia_device *pdev) if (!stk) goto out1; stk->is_kme = is_kme; - - /* Not sure if this is right... look up the current Vcc */ - CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(pdev, &stk->conf)); stk->skip_vcc = io_base = ctl_base = 0; + if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) { stk->skip_vcc = 1; if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index 794a5ef9ea22..3fd8022a6351 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c @@ -681,6 +681,7 @@ static void bt3c_detach(struct pcmcia_device *link) static int bt3c_check_config(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { unsigned long try = (unsigned long) priv_data; @@ -701,6 +702,7 @@ static int bt3c_check_config(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 *dflt, + unsigned int vcc, void *priv_data) { static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index 32017f96067c..17183125434f 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c @@ -610,16 +610,17 @@ static void btuart_detach(struct pcmcia_device *link) static int btuart_check_config(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { - unsigned long try = (unsigned long) priv_data; + int *try = priv_data; if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) p_dev->conf.Vpp = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && (cf->io.win[0].base != 0)) { p_dev->io.BasePort1 = cf->io.win[0].base; - p_dev->io.IOAddrLines = (try == 0) ? 16 : + p_dev->io.IOAddrLines = (*try == 0) ? 16 : cf->io.flags & CISTPL_IO_LINES_MASK; if (!pcmcia_request_io(p_dev, &p_dev->io)) return 0; @@ -630,6 +631,7 @@ static int btuart_check_config(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 *dflt, + unsigned int vcc, void *priv_data) { static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; @@ -650,13 +652,12 @@ static int btuart_config(struct pcmcia_device *link) { btuart_info_t *info = link->priv; int i; - unsigned long try; + int try; /* First pass: look for a config entry that looks normal. Two tries: without IO aliases, then with aliases */ for (try = 0; try < 2; try++) - if (!pcmcia_loop_config(link, btuart_check_config, - (void *) try)) + if (!pcmcia_loop_config(link, btuart_check_config, &try)) goto found_port; /* Second pass: try to find an entry that isn't picky about diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index 1830ebd6ca7b..ec12560e0342 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c @@ -593,6 +593,7 @@ static void dtl1_detach(struct pcmcia_device *link) static int dtl1_confcheck(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { if ((cf->io.nwin == 1) && (cf->io.win[0].len > 8)) { diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c index 7785fbb4c0f6..1c5bf99895ed 100644 --- a/drivers/char/pcmcia/cm4000_cs.c +++ b/drivers/char/pcmcia/cm4000_cs.c @@ -1762,6 +1762,7 @@ static void cmm_cm4000_release(struct pcmcia_device * link) static int cm4000_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { if (!cfg->io.nwin) diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c index 468ddef916b3..e047bac56f0e 100644 --- a/drivers/char/pcmcia/cm4040_cs.c +++ b/drivers/char/pcmcia/cm4040_cs.c @@ -529,6 +529,7 @@ static void cm4040_reader_release(struct pcmcia_device *link) static int cm4040_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { int rc; diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index cc8eeaf80275..6472cd8231f7 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c @@ -221,7 +221,6 @@ out_release: do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) struct pcmcia_config_check { - config_info_t conf; unsigned long ctl_base; int skip_vcc; int is_kme; @@ -230,6 +229,7 @@ struct pcmcia_config_check { static int pcmcia_check_one_config(struct pcmcia_device *pdev, cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { struct pcmcia_config_check *stk = priv_data; @@ -237,12 +237,10 @@ static int pcmcia_check_one_config(struct pcmcia_device *pdev, /* Check for matching Vcc, unless we're desperate */ if (!stk->skip_vcc) { if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { - if (stk->conf.Vcc != - cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) + if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) return -ENODEV; } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { - if (stk->conf.Vcc != - dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) + if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) return -ENODEV; } } @@ -298,10 +296,8 @@ static int ide_config(struct pcmcia_device *link) if (!stk) goto err_mem; stk->is_kme = is_kme; - - /* Not sure if this is right... look up the current Vcc */ - CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &stk->conf)); stk->skip_vcc = io_base = ctl_base = 0; + if (pcmcia_loop_config(link, pcmcia_check_one_config, stk)) { stk->skip_vcc = 1; if (pcmcia_loop_config(link, pcmcia_check_one_config, stk)) diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c index a8d6949338cd..388046539705 100644 --- a/drivers/isdn/hardware/avm/avm_cs.c +++ b/drivers/isdn/hardware/avm/avm_cs.c @@ -157,6 +157,7 @@ static void avmcs_detach(struct pcmcia_device *link) static int avmcs_configcheck(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { if (cf->io.nwin <= 0) diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c index 7ce1aabb0aeb..8fd3ca0fb93a 100644 --- a/drivers/isdn/hisax/avma1_cs.c +++ b/drivers/isdn/hisax/avma1_cs.c @@ -177,6 +177,7 @@ static void avma1cs_detach(struct pcmcia_device *link) static int avma1cs_configcheck(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { if (cf->io.nwin <= 0) diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c index 29c55b0b86b4..2bf0016dea5e 100644 --- a/drivers/isdn/hisax/elsa_cs.c +++ b/drivers/isdn/hisax/elsa_cs.c @@ -207,6 +207,7 @@ static void elsa_cs_detach(struct pcmcia_device *link) static int elsa_cs_configcheck(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { int j; diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c index 2746acbd8b70..9a3c9f5e4fe8 100644 --- a/drivers/isdn/hisax/sedlbauer_cs.c +++ b/drivers/isdn/hisax/sedlbauer_cs.c @@ -217,17 +217,13 @@ static void sedlbauer_detach(struct pcmcia_device *link) #define CS_CHECK(fn, ret) \ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) -struct sedlbauer_config_data { - config_info_t conf; - win_req_t req; -}; - static int sedlbauer_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { - struct sedlbauer_config_data *cfg_mem = priv_data; + win_req_t *req = priv_data; if (cfg->index == 0) return -ENODEV; @@ -241,12 +237,10 @@ static int sedlbauer_config_check(struct pcmcia_device *p_dev, /* Use power settings for Vcc and Vpp if present */ /* Note that the CIS values need to be rescaled */ if (cfg->vcc.present & (1<conf.Vcc != - cfg->vcc.param[CISTPL_POWER_VNOM]/10000) + if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000) return -ENODEV; } else if (dflt->vcc.present & (1<conf.Vcc != - dflt->vcc.param[CISTPL_POWER_VNOM]/10000) + if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM]/10000) return -ENODEV; } @@ -294,12 +288,12 @@ static int sedlbauer_config_check(struct pcmcia_device *p_dev, if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) { cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &dflt->mem; memreq_t map; - cfg_mem->req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; - cfg_mem->req.Attributes |= WIN_ENABLE; - cfg_mem->req.Base = mem->win[0].host_addr; - cfg_mem->req.Size = mem->win[0].len; - cfg_mem->req.AccessSpeed = 0; - if (pcmcia_request_window(&p_dev, &cfg_mem->req, &p_dev->win) != 0) + req->Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; + req->Attributes |= WIN_ENABLE; + req->Base = mem->win[0].host_addr; + req->Size = mem->win[0].len; + req->AccessSpeed = 0; + if (pcmcia_request_window(&p_dev, req, &p_dev->win) != 0) return -ENODEV; map.Page = 0; map.CardOffset = mem->win[0].card_addr; @@ -314,20 +308,16 @@ static int sedlbauer_config_check(struct pcmcia_device *p_dev, static int sedlbauer_config(struct pcmcia_device *link) { local_info_t *dev = link->priv; - struct sedlbauer_config_data *cfg_mem; + win_req_t *req; int last_fn, last_ret; IsdnCard_t icard; DEBUG(0, "sedlbauer_config(0x%p)\n", link); - cfg_mem = kzalloc(sizeof(struct sedlbauer_config_data), GFP_KERNEL); - if (!cfg_mem) + req = kzalloc(sizeof(win_req_t), GFP_KERNEL); + if (!req) return -ENOMEM; - /* Look up the current Vcc */ - CS_CHECK(GetConfigurationInfo, - pcmcia_get_configuration_info(link, &cfg_mem->conf)); - /* In this loop, we scan the CIS for configuration table entries, each of which describes a valid card configuration, including @@ -340,7 +330,7 @@ static int sedlbauer_config(struct pcmcia_device *link) these things without consulting the CIS, and most client drivers will only use the CIS to fill in implementation-defined details. */ - last_ret = pcmcia_loop_config(link, sedlbauer_config_check, cfg_mem); + last_ret = pcmcia_loop_config(link, sedlbauer_config_check, req); if (last_ret) goto failed; @@ -381,8 +371,8 @@ static int sedlbauer_config(struct pcmcia_device *link) printk(" & 0x%04x-0x%04x", link->io.BasePort2, link->io.BasePort2+link->io.NumPorts2-1); if (link->win) - printk(", mem 0x%06lx-0x%06lx", cfg_mem->req.Base, - cfg_mem->req.Base+cfg_mem->req.Size-1); + printk(", mem 0x%06lx-0x%06lx", req->Base, + req->Base+req->Size-1); printk("\n"); icard.para[0] = link->irq.AssignedIRQ; diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c index f4f2e2231a9b..21cabd0aadbe 100644 --- a/drivers/isdn/hisax/teles_cs.c +++ b/drivers/isdn/hisax/teles_cs.c @@ -197,6 +197,7 @@ static void teles_detach(struct pcmcia_device *link) static int teles_cs_configcheck(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { int j; diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c index c99dc5d54d19..061d889794c5 100644 --- a/drivers/net/pcmcia/axnet_cs.c +++ b/drivers/net/pcmcia/axnet_cs.c @@ -287,6 +287,7 @@ static int try_io_port(struct pcmcia_device *link) static int axnet_configcheck(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { int i; diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index 10fc537804b0..aa17434faa0e 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c @@ -515,6 +515,7 @@ static int try_io_port(struct pcmcia_device *link) static int pcnet_confcheck(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { int *has_shmem = priv_data; diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index 05bca83c5e27..b3f2085ddca9 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c @@ -462,6 +462,7 @@ static int mhz_3288_power(struct pcmcia_device *link) static int mhz_mfc_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { int k; @@ -653,6 +654,7 @@ static int mot_setup(struct pcmcia_device *link) static int smc_configcheck(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { p_dev->io.BasePort1 = cf->io.win[0].base; diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c index a16efa49b855..d97e6e917c3c 100644 --- a/drivers/net/pcmcia/xirc2ps_cs.c +++ b/drivers/net/pcmcia/xirc2ps_cs.c @@ -719,6 +719,7 @@ static int xirc2ps_config_modem(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { unsigned int ioaddr; @@ -738,6 +739,7 @@ static int xirc2ps_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { int *pass = priv_data; diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c index 657adf85ab77..fac1526e49aa 100644 --- a/drivers/net/wireless/airo_cs.c +++ b/drivers/net/wireless/airo_cs.c @@ -209,6 +209,7 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) static int airo_cs_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { win_req_t *req = priv_data; diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c index c71aae992ecc..4830d51900a3 100644 --- a/drivers/net/wireless/atmel_cs.c +++ b/drivers/net/wireless/atmel_cs.c @@ -227,6 +227,7 @@ static int card_present(void *arg) static int atmel_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { if (cfg->index == 0) diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c index f9595ca71a06..c768d42d5177 100644 --- a/drivers/net/wireless/hostap/hostap_cs.c +++ b/drivers/net/wireless/hostap/hostap_cs.c @@ -536,17 +536,12 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) /* run after a CARD_INSERTION event is received to configure the PCMCIA * socket and make the device available to the system */ -struct prism2_config_data { - config_info_t conf; -}; - static int prism2_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { - struct prism2_config_data *cfg_mem = priv_data; - if (cfg->index == 0) return -ENODEV; @@ -562,14 +557,14 @@ static int prism2_config_check(struct pcmcia_device *p_dev, /* Use power settings for Vcc and Vpp if present */ /* Note that the CIS values need to be rescaled */ if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { - if (cfg_mem->conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / + if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000 && !ignore_cis_vcc) { PDEBUG(DEBUG_EXTRA, " Vcc mismatch - skipping" " this entry\n"); return -ENODEV; } } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { - if (cfg_mem->conf.Vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / + if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000 && !ignore_cis_vcc) { PDEBUG(DEBUG_EXTRA, " Vcc (default) mismatch " "- skipping this entry\n"); @@ -627,7 +622,6 @@ static int prism2_config(struct pcmcia_device *link) { struct net_device *dev; struct hostap_interface *iface; - struct prism2_config_data *cfg_mem; local_info_t *local; int ret = 1; int last_fn, last_ret; @@ -635,21 +629,14 @@ static int prism2_config(struct pcmcia_device *link) PDEBUG(DEBUG_FLOW, "prism2_config()\n"); - cfg_mem = kzalloc(sizeof(struct prism2_config_data), GFP_KERNEL); - if (!cfg_mem) - return -ENOMEM; - hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL); if (hw_priv == NULL) { ret = -ENOMEM; goto failed; } - CS_CHECK(GetConfigurationInfo, - pcmcia_get_configuration_info(link, &cfg_mem->conf)); - /* Look for an appropriate configuration table entry in the CIS */ - last_ret = pcmcia_loop_config(link, prism2_config_check, cfg_mem); + last_ret = pcmcia_loop_config(link, prism2_config_check, NULL); if (last_ret) { if (!ignore_cis_vcc) printk(KERN_ERR "GetNextTuple(): No matching " @@ -724,7 +711,6 @@ static int prism2_config(struct pcmcia_device *link) if (ret == 0 && local->ddev) strcpy(hw_priv->node.dev_name, local->ddev->name); } - kfree(cfg_mem); return ret; cs_failed: @@ -732,7 +718,6 @@ static int prism2_config(struct pcmcia_device *link) failed: kfree(hw_priv); - kfree(cfg_mem); prism2_release((u_long)link); return ret; } diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c index 8a367f96db37..c7b57d9d499d 100644 --- a/drivers/net/wireless/orinoco_cs.c +++ b/drivers/net/wireless/orinoco_cs.c @@ -164,31 +164,26 @@ static void orinoco_cs_detach(struct pcmcia_device *link) last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; \ } while (0) -struct orinoco_cs_config_data { - config_info_t conf; -}; - static int orinoco_cs_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { - struct orinoco_cs_config_data *cfg_mem = priv_data; - if (cfg->index == 0) goto next_entry; /* Use power settings for Vcc and Vpp if present */ /* Note that the CIS values need to be rescaled */ if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { - if (cfg_mem->conf.Vcc != cfg->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->vcc.param[CISTPL_POWER_VNOM] / 10000); + if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) { + DEBUG(2, "spectrum_cs_config: Vcc mismatch (vcc = %d, CIS = %d)\n", vcc, cfg->vcc.param[CISTPL_POWER_VNOM] / 10000); if (!ignore_cis_vcc) goto next_entry; } } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { - 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, dflt->vcc.param[CISTPL_POWER_VNOM] / 10000); + if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) { + DEBUG(2, "spectrum_cs_config: Vcc mismatch (vcc = %d, CIS = %d)\n", vcc, dflt->vcc.param[CISTPL_POWER_VNOM] / 10000); if (!ignore_cis_vcc) goto next_entry; } @@ -236,7 +231,6 @@ next_entry: static int orinoco_cs_config(struct pcmcia_device *link) { - struct orinoco_cs_config_data *cfg_mem; struct net_device *dev = link->priv; struct orinoco_private *priv = netdev_priv(dev); struct orinoco_pccard *card = priv->card; @@ -244,14 +238,6 @@ orinoco_cs_config(struct pcmcia_device *link) int last_fn, last_ret; void __iomem *mem; - cfg_mem = kzalloc(sizeof(struct orinoco_cs_config_data), GFP_KERNEL); - if (!cfg_mem) - return -ENOMEM; - - /* Look up the current Vcc */ - CS_CHECK(GetConfigurationInfo, - pcmcia_get_configuration_info(link, &cfg_mem->conf)); - /* * In this loop, we scan the CIS for configuration table * entries, each of which describes a valid card @@ -266,7 +252,7 @@ orinoco_cs_config(struct pcmcia_device *link) * and most client drivers will only use the CIS to fill in * implementation-defined details. */ - last_ret = pcmcia_loop_config(link, orinoco_cs_config_check, cfg_mem); + last_ret = pcmcia_loop_config(link, orinoco_cs_config_check, NULL); if (last_ret) { if (!ignore_cis_vcc) printk(KERN_ERR PFX "GetNextTuple(): No matching " @@ -324,7 +310,6 @@ orinoco_cs_config(struct pcmcia_device *link) "0x%04x-0x%04x\n", dev->name, dev->dev.parent->bus_id, link->irq.AssignedIRQ, link->io.BasePort1, link->io.BasePort1 + link->io.NumPorts1 - 1); - kfree(cfg_mem); return 0; cs_failed: @@ -332,7 +317,6 @@ orinoco_cs_config(struct pcmcia_device *link) failed: orinoco_cs_release(link); - kfree(cfg_mem); return -ENODEV; } /* orinoco_cs_config */ diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c index e28878dfaba3..d7e9d9c3042c 100644 --- a/drivers/net/wireless/spectrum_cs.c +++ b/drivers/net/wireless/spectrum_cs.c @@ -633,31 +633,26 @@ static void spectrum_cs_detach(struct pcmcia_device *link) * device available to the system. */ -struct spectrum_cs_config_data { - config_info_t conf; -}; - static int spectrum_cs_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { - struct spectrum_cs_config_data *cfg_mem = priv_data; - if (cfg->index == 0) goto next_entry; /* Use power settings for Vcc and Vpp if present */ /* Note that the CIS values need to be rescaled */ if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { - if (cfg_mem->conf.Vcc != cfg->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->vcc.param[CISTPL_POWER_VNOM] / 10000); + if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) { + DEBUG(2, "spectrum_cs_config: Vcc mismatch (vcc = %d, CIS = %d)\n", vcc, cfg->vcc.param[CISTPL_POWER_VNOM] / 10000); if (!ignore_cis_vcc) goto next_entry; } } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { - 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, dflt->vcc.param[CISTPL_POWER_VNOM] / 10000); + if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) { + DEBUG(2, "spectrum_cs_config: Vcc mismatch (vcc = %d, CIS = %d)\n", vcc, dflt->vcc.param[CISTPL_POWER_VNOM] / 10000); if (!ignore_cis_vcc) goto next_entry; } @@ -705,7 +700,6 @@ next_entry: static int spectrum_cs_config(struct pcmcia_device *link) { - struct spectrum_cs_config_data *cfg_mem; struct net_device *dev = link->priv; struct orinoco_private *priv = netdev_priv(dev); struct orinoco_pccard *card = priv->card; @@ -713,14 +707,6 @@ spectrum_cs_config(struct pcmcia_device *link) int last_fn, last_ret; void __iomem *mem; - cfg_mem = kzalloc(sizeof(struct spectrum_cs_config_data), GFP_KERNEL); - if (!cfg_mem) - return -ENOMEM; - - /* Look up the current Vcc */ - CS_CHECK(GetConfigurationInfo, - pcmcia_get_configuration_info(link, &cfg_mem->conf)); - /* * In this loop, we scan the CIS for configuration table * entries, each of which describes a valid card @@ -735,7 +721,7 @@ spectrum_cs_config(struct pcmcia_device *link) * and most client drivers will only use the CIS to fill in * implementation-defined details. */ - last_ret = pcmcia_loop_config(link, spectrum_cs_config_check, cfg_mem); + last_ret = pcmcia_loop_config(link, spectrum_cs_config_check, NULL); if (last_ret) { if (!ignore_cis_vcc) printk(KERN_ERR PFX "GetNextTuple(): No matching " @@ -799,7 +785,6 @@ spectrum_cs_config(struct pcmcia_device *link) link->irq.AssignedIRQ, link->io.BasePort1, link->io.BasePort1 + link->io.NumPorts1 - 1); - kfree(cfg_mem); return 0; cs_failed: @@ -807,7 +792,6 @@ spectrum_cs_config(struct pcmcia_device *link) failed: spectrum_cs_release(link); - kfree(cfg_mem); return -ENODEV; } /* spectrum_cs_config */ diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c index 05f34e73694b..b1899e9c1f65 100644 --- a/drivers/parport/parport_cs.c +++ b/drivers/parport/parport_cs.c @@ -152,6 +152,7 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) static int parport_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { @@ -169,6 +170,7 @@ static int parport_config_check(struct pcmcia_device *p_dev, return -ENODEV; return 0; } + return -ENODEV; } static int parport_config(struct pcmcia_device *link) diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 5ddfd46dea65..0cf3ef30625e 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -935,6 +935,7 @@ int pcmcia_loop_config(struct pcmcia_device *p_dev, int (*conf_check) (struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data), void *priv_data) { @@ -942,11 +943,15 @@ int pcmcia_loop_config(struct pcmcia_device *p_dev, tuple_t *tuple; int ret = -ENODEV; + unsigned int vcc; cfg_mem = kzalloc(sizeof(struct pcmcia_cfg_mem), GFP_KERNEL); if (cfg_mem == NULL) return -ENOMEM; + /* get the current Vcc setting */ + vcc = p_dev->socket->socket.Vcc; + tuple = &cfg_mem->tuple; tuple->TupleData = cfg_mem->buf; tuple->TupleDataMax = 255; @@ -969,7 +974,7 @@ int pcmcia_loop_config(struct pcmcia_device *p_dev, if (cfg->flags & CISTPL_CFTABLE_DEFAULT) cfg_mem->dflt = *cfg; - ret = conf_check(p_dev, cfg, &cfg_mem->dflt, priv_data); + ret = conf_check(p_dev, cfg, &cfg_mem->dflt, vcc, priv_data); if (!ret) break; diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c index 2ed3077b826a..165ff884f48e 100644 --- a/drivers/scsi/pcmcia/aha152x_stub.c +++ b/drivers/scsi/pcmcia/aha152x_stub.c @@ -143,6 +143,7 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) static int aha152x_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { /* For New Media T&J, look for a SCSI window */ diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c index 2b6e92d7be07..06254f46a0dd 100644 --- a/drivers/scsi/pcmcia/fdomain_stub.c +++ b/drivers/scsi/pcmcia/fdomain_stub.c @@ -126,6 +126,7 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) static int fdomain_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { p_dev->io.BasePort1 = cfg->io.win[0].base; diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index aa4523462578..7c19bf264873 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c @@ -1611,12 +1611,12 @@ static void nsp_cs_detach(struct pcmcia_device *link) struct nsp_cs_configdata { nsp_hw_data *data; win_req_t req; - config_info_t conf; }; static int nsp_cs_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { struct nsp_cs_configdata *cfg_mem = priv_data; @@ -1633,10 +1633,10 @@ static int nsp_cs_config_check(struct pcmcia_device *p_dev, /* Use power settings for Vcc and Vpp if present */ /* Note that the CIS values need to be rescaled */ if (cfg->vcc.present & (1<conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000) + if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000) return -ENODEV; else if (dflt->vcc.present & (1<conf.Vcc != dflt->vcc.param[CISTPL_POWER_VNOM]/10000) + if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM]/10000) return -ENODEV; } @@ -1719,8 +1719,6 @@ static int nsp_cs_config(struct pcmcia_device *link) return -ENOMEM; cfg_mem->data = data; - /* Look up the current Vcc */ - CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &cfg_mem->conf)); ret = pcmcia_loop_config(link, nsp_cs_config_check, cfg_mem); goto cs_failed; diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c index da6b3603198b..20c3e5e6d88a 100644 --- a/drivers/scsi/pcmcia/qlogic_stub.c +++ b/drivers/scsi/pcmcia/qlogic_stub.c @@ -198,6 +198,7 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) static int qlogic_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { p_dev->io.BasePort1 = cfg->io.win[0].base; diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c index eba193134dfa..b330c11a1752 100644 --- a/drivers/scsi/pcmcia/sym53c500_cs.c +++ b/drivers/scsi/pcmcia/sym53c500_cs.c @@ -703,6 +703,7 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) static int SYM53C500_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { p_dev->io.BasePort1 = cfg->io.win[0].base; diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c index f8658686439d..7e00e672bfe7 100644 --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c @@ -444,6 +444,7 @@ first_tuple(struct pcmcia_device *handle, tuple_t * tuple, cisparse_t * parse) static int simple_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { static const int size_table[2] = { 8, 16 }; @@ -467,6 +468,7 @@ static int simple_config_check(struct pcmcia_device *p_dev, static int simple_config_check_notpicky(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { static const unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; @@ -549,6 +551,7 @@ found_port: static int multi_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { int *base2 = priv_data; @@ -569,6 +572,7 @@ static int multi_config_check(struct pcmcia_device *p_dev, static int multi_config_check_notpicky(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { int *base2 = priv_data; diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c index b41df211b786..347c3ed1d9f1 100644 --- a/drivers/telephony/ixj_pcmcia.c +++ b/drivers/telephony/ixj_pcmcia.c @@ -127,6 +127,7 @@ static void ixj_get_serial(struct pcmcia_device * link, IXJ * j) static int ixj_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c index 78cc32e7b014..ca733b7caea4 100644 --- a/drivers/usb/host/sl811_cs.c +++ b/drivers/usb/host/sl811_cs.c @@ -155,29 +155,22 @@ static void sl811_cs_release(struct pcmcia_device * link) platform_device_unregister(&platform_dev); } -struct sl811_css_cfg { - config_info_t conf; -}; - static int sl811_cs_config_check(struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data) { - struct sl811_css_cfg *cfg_mem = priv_data; - if (cfg->index == 0) return -ENODEV; /* Use power settings for Vcc and Vpp if present */ /* Note that the CIS values need to be rescaled */ if (cfg->vcc.present & (1<vcc.param[CISTPL_POWER_VNOM]/10000 != - cfg_mem->conf.Vcc) + if (cfg->vcc.param[CISTPL_POWER_VNOM]/10000 != vcc) return -ENODEV; } else if (dflt->vcc.present & (1<vcc.param[CISTPL_POWER_VNOM]/10000 - != cfg_mem->conf.Vcc) + if (dflt->vcc.param[CISTPL_POWER_VNOM]/10000 != vcc) return -ENODEV; } @@ -214,29 +207,20 @@ static int sl811_cs_config(struct pcmcia_device *link) struct device *parent = &handle_to_dev(link); local_info_t *dev = link->priv; int last_fn, last_ret; - struct sl811_css_cfg *cfg_mem; DBG(0, "sl811_cs_config(0x%p)\n", link); - cfg_mem = kzalloc(sizeof(struct sl811_css_cfg), GFP_KERNEL); - if (!cfg_mem) - return -ENOMEM; - - /* Look up the current Vcc */ - CS_CHECK(GetConfigurationInfo, - pcmcia_get_configuration_info(link, &cfg_mem->conf)); - - if (pcmcia_loop_config(link, sl811_cs_config_check, cfg_mem)) - return -ENODEV; + if (pcmcia_loop_config(link, sl811_cs_config_check, NULL)) + goto failed; /* require an IRQ and two registers */ if (!link->io.NumPorts1 || link->io.NumPorts1 < 2) - goto cs_failed; + goto failed; if (link->conf.Attributes & CONF_ENABLE_IRQ) CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); else - goto cs_failed; + goto failed; CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); @@ -257,13 +241,12 @@ static int sl811_cs_config(struct pcmcia_device *link) if (sl811_hc_init(parent, link->io.BasePort1, link->irq.AssignedIRQ) < 0) { cs_failed: - printk("sl811_cs_config failed\n"); cs_error(link, last_fn, last_ret); +failed: + printk(KERN_WARNING "sl811_cs_config failed\n"); sl811_cs_release(link); - kfree(cfg_mem); return -ENODEV; } - kfree(cfg_mem); return 0; } diff --git a/include/pcmcia/cistpl.h b/include/pcmcia/cistpl.h index 0aa702705d00..0092910a597d 100644 --- a/include/pcmcia/cistpl.h +++ b/include/pcmcia/cistpl.h @@ -617,6 +617,7 @@ int pcmcia_loop_config(struct pcmcia_device *p_dev, int (*conf_check) (struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, cistpl_cftable_entry_t *dflt, + unsigned int vcc, void *priv_data), void *priv_data); -- cgit v1.2.3 From 64f346425175ad33812cd693fbca48cd512dab63 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sat, 2 Aug 2008 17:00:46 +0200 Subject: pcmcia: move pccard_get_configuration_info to ioctl With the PCMCIA ioctl being the only remaining user of _get_configuration_info, move the function to pcmcia_ioctl.c Signed-off-by: Dominik Brodowski --- drivers/pcmcia/cs_internal.h | 1 - drivers/pcmcia/pcmcia_ioctl.c | 72 ++++++++++++++++++++++++++++++++++++ drivers/pcmcia/pcmcia_resource.c | 79 ---------------------------------------- include/pcmcia/cs.h | 1 - 4 files changed, 72 insertions(+), 81 deletions(-) (limited to 'include') diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 481a823c94b4..384a76bd38eb 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h @@ -116,7 +116,6 @@ extern void pccard_sysfs_remove_socket(struct device *dev); extern struct rw_semaphore pcmcia_socket_list_rwsem; extern struct list_head pcmcia_socket_list; int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, int idx, win_req_t *req); -int pccard_get_configuration_info(struct pcmcia_socket *s, struct pcmcia_device *p_dev, config_info_t *config); int pccard_reset_card(struct pcmcia_socket *skt); diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index f555a505214f..53dadc111002 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c @@ -287,6 +287,78 @@ static int pccard_get_status(struct pcmcia_socket *s, return CS_SUCCESS; } /* pccard_get_status */ +int pccard_get_configuration_info(struct pcmcia_socket *s, + struct pcmcia_device *p_dev, + config_info_t *config) +{ + config_t *c; + + if (!(s->state & SOCKET_PRESENT)) + return CS_NO_CARD; + + +#ifdef CONFIG_CARDBUS + if (s->state & SOCKET_CARDBUS) { + memset(config, 0, sizeof(config_info_t)); + config->Vcc = s->socket.Vcc; + config->Vpp1 = config->Vpp2 = s->socket.Vpp; + config->Option = s->cb_dev->subordinate->number; + if (s->state & SOCKET_CARDBUS_CONFIG) { + config->Attributes = CONF_VALID_CLIENT; + config->IntType = INT_CARDBUS; + config->AssignedIRQ = s->irq.AssignedIRQ; + if (config->AssignedIRQ) + config->Attributes |= CONF_ENABLE_IRQ; + if (s->io[0].res) { + config->BasePort1 = s->io[0].res->start; + config->NumPorts1 = s->io[0].res->end - + config->BasePort1 + 1; + } + } + return CS_SUCCESS; + } +#endif + + if (p_dev) { + c = p_dev->function_config; + config->Function = p_dev->func; + } else { + c = NULL; + config->Function = 0; + } + + if ((c == NULL) || !(c->state & CONFIG_LOCKED)) { + config->Attributes = 0; + config->Vcc = s->socket.Vcc; + config->Vpp1 = config->Vpp2 = s->socket.Vpp; + return CS_SUCCESS; + } + + config->Attributes = c->Attributes | CONF_VALID_CLIENT; + config->Vcc = s->socket.Vcc; + config->Vpp1 = config->Vpp2 = s->socket.Vpp; + config->IntType = c->IntType; + config->ConfigBase = c->ConfigBase; + config->Status = c->Status; + config->Pin = c->Pin; + config->Copy = c->Copy; + config->Option = c->Option; + config->ExtStatus = c->ExtStatus; + config->Present = config->CardValues = c->CardValues; + config->IRQAttributes = c->irq.Attributes; + config->AssignedIRQ = s->irq.AssignedIRQ; + config->BasePort1 = c->io.BasePort1; + config->NumPorts1 = c->io.NumPorts1; + config->Attributes1 = c->io.Attributes1; + config->BasePort2 = c->io.BasePort2; + config->NumPorts2 = c->io.NumPorts2; + config->Attributes2 = c->io.Attributes2; + config->IOAddrLines = c->io.IOAddrLines; + + return CS_SUCCESS; +} /* pccard_get_configuration_info */ + + /*====================================================================== These manage a ring buffer of events pending for one user process diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 9afe420c41f4..c5a2b005091c 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -197,85 +197,6 @@ int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, EXPORT_SYMBOL(pcmcia_access_configuration_register); -int pccard_get_configuration_info(struct pcmcia_socket *s, - struct pcmcia_device *p_dev, - config_info_t *config) -{ - config_t *c; - - if (!(s->state & SOCKET_PRESENT)) - return CS_NO_CARD; - - -#ifdef CONFIG_CARDBUS - if (s->state & SOCKET_CARDBUS) { - memset(config, 0, sizeof(config_info_t)); - config->Vcc = s->socket.Vcc; - config->Vpp1 = config->Vpp2 = s->socket.Vpp; - config->Option = s->cb_dev->subordinate->number; - if (s->state & SOCKET_CARDBUS_CONFIG) { - config->Attributes = CONF_VALID_CLIENT; - config->IntType = INT_CARDBUS; - config->AssignedIRQ = s->irq.AssignedIRQ; - if (config->AssignedIRQ) - config->Attributes |= CONF_ENABLE_IRQ; - if (s->io[0].res) { - config->BasePort1 = s->io[0].res->start; - config->NumPorts1 = s->io[0].res->end - config->BasePort1 + 1; - } - } - return CS_SUCCESS; - } -#endif - - if (p_dev) { - c = p_dev->function_config; - config->Function = p_dev->func; - } else { - c = NULL; - config->Function = 0; - } - - if ((c == NULL) || !(c->state & CONFIG_LOCKED)) { - config->Attributes = 0; - config->Vcc = s->socket.Vcc; - config->Vpp1 = config->Vpp2 = s->socket.Vpp; - return CS_SUCCESS; - } - - config->Attributes = c->Attributes | CONF_VALID_CLIENT; - config->Vcc = s->socket.Vcc; - config->Vpp1 = config->Vpp2 = s->socket.Vpp; - config->IntType = c->IntType; - config->ConfigBase = c->ConfigBase; - config->Status = c->Status; - config->Pin = c->Pin; - config->Copy = c->Copy; - config->Option = c->Option; - config->ExtStatus = c->ExtStatus; - config->Present = config->CardValues = c->CardValues; - config->IRQAttributes = c->irq.Attributes; - config->AssignedIRQ = s->irq.AssignedIRQ; - config->BasePort1 = c->io.BasePort1; - config->NumPorts1 = c->io.NumPorts1; - config->Attributes1 = c->io.Attributes1; - config->BasePort2 = c->io.BasePort2; - config->NumPorts2 = c->io.NumPorts2; - config->Attributes2 = c->io.Attributes2; - config->IOAddrLines = c->io.IOAddrLines; - - return CS_SUCCESS; -} /* pccard_get_configuration_info */ - -int pcmcia_get_configuration_info(struct pcmcia_device *p_dev, - config_info_t *config) -{ - return pccard_get_configuration_info(p_dev->socket, p_dev, - config); -} -EXPORT_SYMBOL(pcmcia_get_configuration_info); - - /** pcmcia_get_window */ int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index 45d84b275789..ea51a8c4cc50 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -372,7 +372,6 @@ enum service { struct pcmcia_socket; int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, conf_reg_t *reg); -int pcmcia_get_configuration_info(struct pcmcia_device *p_dev, config_info_t *config); int pcmcia_get_mem_page(window_handle_t win, memreq_t *req); int pcmcia_map_mem_page(window_handle_t win, memreq_t *req); int pcmcia_modify_configuration(struct pcmcia_device *p_dev, modconf_t *mod); -- cgit v1.2.3 From 1a53088c101789bfca431de709ff6e45e8c77003 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 3 Aug 2008 08:57:51 +0200 Subject: pcmcia: move config_info_t definition to ioctl-related parts in header files Signed-off-by: Dominik Brodowski --- include/pcmcia/cs.h | 21 --------------------- include/pcmcia/ds.h | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 21 deletions(-) (limited to 'include') diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index ea51a8c4cc50..201705c51bbd 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -73,27 +73,6 @@ typedef struct event_callback_args_t { void *client_data; } event_callback_args_t; -/* for GetConfigurationInfo */ -typedef struct config_info_t { - u_char Function; - u_int Attributes; - u_int Vcc, Vpp1, Vpp2; - u_int IntType; - u_int ConfigBase; - u_char Status, Pin, Copy, Option, ExtStatus; - u_int Present; - u_int CardValues; - u_int AssignedIRQ; - u_int IRQAttributes; - ioaddr_t BasePort1; - ioaddr_t NumPorts1; - u_int Attributes1; - ioaddr_t BasePort2; - ioaddr_t NumPorts2; - u_int Attributes2; - u_int IOAddrLines; -} config_info_t; - /* For CardValues field */ #define CV_OPTION_VALUE 0x01 #define CV_STATUS_VALUE 0x02 diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index 2d36a4f80e5b..a06bbec386bd 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -74,6 +74,27 @@ typedef struct cisdump_t { cisdata_t Data[CISTPL_MAX_CIS_SIZE]; } cisdump_t; +/* for GetConfigurationInfo */ +typedef struct config_info_t { + u_char Function; + u_int Attributes; + u_int Vcc, Vpp1, Vpp2; + u_int IntType; + u_int ConfigBase; + u_char Status, Pin, Copy, Option, ExtStatus; + u_int Present; + u_int CardValues; + u_int AssignedIRQ; + u_int IRQAttributes; + ioaddr_t BasePort1; + ioaddr_t NumPorts1; + u_int Attributes1; + ioaddr_t BasePort2; + ioaddr_t NumPorts2; + u_int Attributes2; + u_int IOAddrLines; +} config_info_t; + typedef union ds_ioctl_arg_t { adjust_t adjust; config_info_t config; -- cgit v1.2.3 From 5ff87db6792844ae24cc784512a95e0c94521b19 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 3 Aug 2008 10:36:50 +0200 Subject: pcmcia: deprecate unused CS_ error codes Deprecate unused CS_ error codes by replacing their definitions with generic error messages, and removing them from the error_t lookup table. Signed-off-by: Dominik Brodowski --- drivers/pcmcia/ds.c | 10 ---------- include/pcmcia/cs.h | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 20 deletions(-) (limited to 'include') diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 20bef0c12c14..7142fd647e7b 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -75,29 +75,19 @@ typedef struct lookup_t { static const lookup_t error_table[] = { { CS_SUCCESS, "Operation succeeded" }, - { CS_BAD_ADAPTER, "Bad adapter" }, { CS_BAD_ATTRIBUTE, "Bad attribute", }, { CS_BAD_BASE, "Bad base address" }, - { CS_BAD_EDC, "Bad EDC" }, { CS_BAD_IRQ, "Bad IRQ" }, { CS_BAD_OFFSET, "Bad offset" }, { CS_BAD_PAGE, "Bad page number" }, - { CS_READ_FAILURE, "Read failure" }, { CS_BAD_SIZE, "Bad size" }, - { CS_BAD_SOCKET, "Bad socket" }, { CS_BAD_TYPE, "Bad type" }, { CS_BAD_VCC, "Bad Vcc" }, { CS_BAD_VPP, "Bad Vpp" }, - { CS_BAD_WINDOW, "Bad window" }, - { CS_WRITE_FAILURE, "Write failure" }, { CS_NO_CARD, "No card present" }, { CS_UNSUPPORTED_FUNCTION, "Usupported function" }, { CS_UNSUPPORTED_MODE, "Unsupported mode" }, - { CS_BAD_SPEED, "Bad speed" }, - { CS_BUSY, "Resource busy" }, { CS_GENERAL_FAILURE, "General failure" }, - { CS_WRITE_PROTECTED, "Write protected" }, - { CS_BAD_ARG_LENGTH, "Bad argument length" }, { CS_BAD_ARGS, "Bad arguments" }, { CS_CONFIGURATION_LOCKED, "Configuration locked" }, { CS_IN_USE, "Resource in use" }, diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index 201705c51bbd..695baf6cf1fd 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -289,29 +289,29 @@ typedef struct error_info_t { /* Return codes */ #define CS_SUCCESS 0x00 -#define CS_BAD_ADAPTER 0x01 +#define CS_BAD_ADAPTER -ENODEV #define CS_BAD_ATTRIBUTE 0x02 #define CS_BAD_BASE 0x03 -#define CS_BAD_EDC 0x04 +#define CS_BAD_EDC -ENODEV #define CS_BAD_IRQ 0x06 #define CS_BAD_OFFSET 0x07 #define CS_BAD_PAGE 0x08 -#define CS_READ_FAILURE 0x09 +#define CS_READ_FAILURE -EIO #define CS_BAD_SIZE 0x0a -#define CS_BAD_SOCKET 0x0b +#define CS_BAD_SOCKET -EINVAL #define CS_BAD_TYPE 0x0d #define CS_BAD_VCC 0x0e #define CS_BAD_VPP 0x0f -#define CS_BAD_WINDOW 0x11 -#define CS_WRITE_FAILURE 0x12 +#define CS_BAD_WINDOW -ENODEV +#define CS_WRITE_FAILURE -EIO #define CS_NO_CARD 0x14 #define CS_UNSUPPORTED_FUNCTION 0x15 #define CS_UNSUPPORTED_MODE 0x16 -#define CS_BAD_SPEED 0x17 -#define CS_BUSY 0x18 +#define CS_BAD_SPEED -ENODEV +#define CS_BUSY -ENODEV #define CS_GENERAL_FAILURE 0x19 -#define CS_WRITE_PROTECTED 0x1a -#define CS_BAD_ARG_LENGTH 0x1b +#define CS_WRITE_PROTECTED -EPERM +#define CS_BAD_ARG_LENGTH -ENODEV #define CS_BAD_ARGS 0x1c #define CS_CONFIGURATION_LOCKED 0x1d #define CS_IN_USE 0x1e -- cgit v1.2.3 From 1168386aa7d850ead2ae135d5a7949a592c6e9a0 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 3 Aug 2008 10:22:47 +0200 Subject: pcmcia: deprecate CS_OUT_OF_RESOURCE CS_OUT_OF_RESOURCE was almost only used to note -ENOMEM situations. Therefore, use -ENOMEM explicitely, and also print out warnings. CC: netdev@vger.kernel.org Signed-off-by: Dominik Brodowski --- drivers/net/pcmcia/smc91c92_cs.c | 4 ++-- drivers/pcmcia/cistpl.c | 43 +++++++++++++++++++++++++--------------- drivers/pcmcia/pcmcia_resource.c | 2 +- drivers/pcmcia/rsrc_nonstatic.c | 32 ++++++++++++++++++------------ include/pcmcia/cs.h | 2 +- 5 files changed, 50 insertions(+), 33 deletions(-) (limited to 'include') diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index 267cbe0afd16..918b4a3eca57 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c @@ -491,7 +491,7 @@ static int mhz_mfc_config(struct pcmcia_device *link) cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); if (!cfg_mem) - return CS_OUT_OF_RESOURCE; + return -ENOMEM; link->conf.Attributes |= CONF_ENABLE_SPKR; link->conf.Status = CCSR_AUDIO_ENA; @@ -690,7 +690,7 @@ static int smc_setup(struct pcmcia_device *link) cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); if (!cfg_mem) - return CS_OUT_OF_RESOURCE; + return -ENOMEM; tuple = &cfg_mem->tuple; parse = &cfg_mem->parse; diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index 1a513d9a8612..8d37768d0b46 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c @@ -352,7 +352,9 @@ int verify_cis_cache(struct pcmcia_socket *s) buf = kmalloc(256, GFP_KERNEL); if (buf == NULL) - return -1; + dev_printk(KERN_WARNING, &s->dev, + "no memory for verifying CIS\n"); + return -ENOMEM; list_for_each_entry(cis, &s->cis_cache, node) { int len = cis->len; @@ -384,15 +386,19 @@ int verify_cis_cache(struct pcmcia_socket *s) int pcmcia_replace_cis(struct pcmcia_socket *s, const u8 *data, const size_t len) { - if (len > CISTPL_MAX_CIS_SIZE) - return CS_BAD_SIZE; - kfree(s->fake_cis); - s->fake_cis = kmalloc(len, GFP_KERNEL); - if (s->fake_cis == NULL) - return CS_OUT_OF_RESOURCE; - s->fake_cis_len = len; - memcpy(s->fake_cis, data, len); - return 0; + if (len > CISTPL_MAX_CIS_SIZE) { + dev_printk(KERN_WARNING, &s->dev, "replacement CIS too big\n"); + return -EINVAL; + } + kfree(s->fake_cis); + s->fake_cis = kmalloc(len, GFP_KERNEL); + if (s->fake_cis == NULL) { + dev_printk(KERN_WARNING, &s->dev, "no memory to replace CIS\n"); + return -ENOMEM; + } + s->fake_cis_len = len; + memcpy(s->fake_cis, data, len); + return 0; } EXPORT_SYMBOL(pcmcia_replace_cis); @@ -1411,8 +1417,10 @@ int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t int ret; buf = kmalloc(256, GFP_KERNEL); - if (buf == NULL) - return CS_OUT_OF_RESOURCE; + if (buf == NULL) { + dev_printk(KERN_WARNING, &s->dev, "no memory to read tuple\n"); + return -ENOMEM; + } tuple.DesiredTuple = code; tuple.Attributes = TUPLE_RETURN_COMMON; ret = pccard_get_first_tuple(s, function, &tuple); @@ -1452,12 +1460,15 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned return CS_BAD_HANDLE; tuple = kmalloc(sizeof(*tuple), GFP_KERNEL); - if (tuple == NULL) - return CS_OUT_OF_RESOURCE; + if (tuple == NULL) { + dev_printk(KERN_WARNING, &s->dev, "no memory to validate CIS\n"); + return -ENOMEM; + } p = kmalloc(sizeof(*p), GFP_KERNEL); if (p == NULL) { - kfree(tuple); - return CS_OUT_OF_RESOURCE; + kfree(tuple); + dev_printk(KERN_WARNING, &s->dev, "no memory to validate CIS\n"); + return -ENOMEM; } count = reserved = 0; diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 48e168e8165b..69d87a7e0766 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -780,7 +780,7 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h for (w = 0; w < MAX_WIN; w++) if (!(s->state & SOCKET_WIN_REQ(w))) break; if (w == MAX_WIN) - return CS_OUT_OF_RESOURCE; + return CS_IN_USE; win = &s->win[w]; win->magic = WINDOW_MAGIC; diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index 9d04fb214ec2..0e4141bac7b1 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c @@ -122,19 +122,22 @@ static void free_region(struct resource *res) static int add_interval(struct resource_map *map, u_long base, u_long num) { - struct resource_map *p, *q; + struct resource_map *p, *q; - for (p = map; ; p = p->next) { - if ((p != map) && (p->base+p->num-1 >= base)) - return -1; - if ((p->next == map) || (p->next->base > base+num-1)) - break; - } - q = kmalloc(sizeof(struct resource_map), GFP_KERNEL); - if (!q) return CS_OUT_OF_RESOURCE; - q->base = base; q->num = num; - q->next = p->next; p->next = q; - return 0; + for (p = map; ; p = p->next) { + if ((p != map) && (p->base+p->num-1 >= base)) + return -1; + if ((p->next == map) || (p->next->base > base+num-1)) + break; + } + q = kmalloc(sizeof(struct resource_map), GFP_KERNEL); + if (!q) { + printk(KERN_WARNING "out of memory to update resources\n"); + return -ENOMEM; + } + q->base = base; q->num = num; + q->next = p->next; p->next = q; + return 0; } /*====================================================================*/ @@ -166,7 +169,10 @@ static int sub_interval(struct resource_map *map, u_long base, u_long num) } else { /* Split the block into two pieces */ p = kmalloc(sizeof(struct resource_map), GFP_KERNEL); - if (!p) return CS_OUT_OF_RESOURCE; + if (!p) { + printk(KERN_WARNING "out of memory to update resources\n"); + return -ENOMEM; + } p->base = base+num; p->num = q->base+q->num - p->base; q->num = base - q->base; diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index 695baf6cf1fd..9e6916c1fa81 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -316,7 +316,7 @@ typedef struct error_info_t { #define CS_CONFIGURATION_LOCKED 0x1d #define CS_IN_USE 0x1e #define CS_NO_MORE_ITEMS 0x1f -#define CS_OUT_OF_RESOURCE 0x20 +#define CS_OUT_OF_RESOURCE -ENOMEM #define CS_BAD_HANDLE 0x21 #define CS_BAD_TUPLE 0x40 -- cgit v1.2.3 From de6405e9d1e7530ea33b62e1a3921338f836a046 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 3 Aug 2008 10:47:59 +0200 Subject: pcmcia: deprecate CS_UNSUPPORTED_* CS_UNSUPPORTED_MODE and CS_UNSUPPORTED_FUNCTION were mostly used to denote trying to use PCMCIA functions on CardBus cards. Signed-off-by: Dominik Brodowski --- drivers/pcmcia/cistpl.c | 2 +- drivers/pcmcia/cs.c | 6 +++--- drivers/pcmcia/ds.c | 3 +-- drivers/pcmcia/pcmcia_ioctl.c | 4 ++-- drivers/pcmcia/pcmcia_resource.c | 8 +++++--- include/pcmcia/cs.h | 4 ++-- 6 files changed, 14 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index 8d37768d0b46..71231e8c7edd 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c @@ -1397,7 +1397,7 @@ int pccard_parse_tuple(tuple_t *tuple, cisparse_t *parse) ret = 0; break; default: - ret = CS_UNSUPPORTED_FUNCTION; + ret = -EINVAL; break; } return ret; diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index 037cb0c7e094..e847c3231da8 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -769,7 +769,7 @@ int pccard_reset_card(struct pcmcia_socket *skt) break; } if (skt->state & SOCKET_CARDBUS) { - ret = CS_UNSUPPORTED_FUNCTION; + ret = -EPERM; break; } @@ -810,7 +810,7 @@ int pcmcia_suspend_card(struct pcmcia_socket *skt) break; } if (skt->state & SOCKET_CARDBUS) { - ret = CS_UNSUPPORTED_FUNCTION; + ret = -EPERM; break; } if (skt->callback) { @@ -840,7 +840,7 @@ int pcmcia_resume_card(struct pcmcia_socket *skt) break; } if (skt->state & SOCKET_CARDBUS) { - ret = CS_UNSUPPORTED_FUNCTION; + ret = -EPERM; break; } ret = socket_resume(skt); diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 7142fd647e7b..4a658e2b6f21 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -85,8 +85,7 @@ static const lookup_t error_table[] = { { CS_BAD_VCC, "Bad Vcc" }, { CS_BAD_VPP, "Bad Vpp" }, { CS_NO_CARD, "No card present" }, - { CS_UNSUPPORTED_FUNCTION, "Usupported function" }, - { CS_UNSUPPORTED_MODE, "Unsupported mode" }, + { -EINVAL, "Bad parameter" }, { CS_GENERAL_FAILURE, "General failure" }, { CS_BAD_ARGS, "Bad arguments" }, { CS_CONFIGURATION_LOCKED, "Configuration locked" }, diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index ef64ceb5e751..40bef470b47c 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c @@ -175,7 +175,7 @@ static inline int adjust_irq(struct pcmcia_socket *s, adjust_t *adj) { static int pcmcia_adjust_resource_info(adjust_t *adj) { struct pcmcia_socket *s; - int ret = CS_UNSUPPORTED_FUNCTION; + int ret = -ENOSYS; unsigned long flags; down_read(&pcmcia_socket_list_rwsem); @@ -975,7 +975,7 @@ static int ds_ioctl(struct inode * inode, struct file * file, err = -ENOSPC; break; case CS_NO_MORE_ITEMS: err = -ENODATA; break; - case CS_UNSUPPORTED_FUNCTION: + case -ENOSYS: err = -ENOSYS; break; default: err = -EIO; break; diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 69d87a7e0766..3b8b0e14d8cf 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -475,8 +475,10 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev, if (!(s->state & SOCKET_PRESENT)) return CS_NO_CARD; - if (req->IntType & INT_CARDBUS) - return CS_UNSUPPORTED_MODE; + if (req->IntType & INT_CARDBUS) { + ds_dbg(p_dev->socket, 0, "IntType may not be INT_CARDBUS\n"); + return -EINVAL; + } c = p_dev->function_config; if (c->state & CONFIG_LOCKED) return CS_CONFIGURATION_LOCKED; @@ -592,7 +594,7 @@ int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req) return CS_NO_CARD; if (!req) - return CS_UNSUPPORTED_MODE; + return -EINVAL; c = p_dev->function_config; if (c->state & CONFIG_LOCKED) return CS_CONFIGURATION_LOCKED; diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index 9e6916c1fa81..6b51d27ddae8 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -305,8 +305,8 @@ typedef struct error_info_t { #define CS_BAD_WINDOW -ENODEV #define CS_WRITE_FAILURE -EIO #define CS_NO_CARD 0x14 -#define CS_UNSUPPORTED_FUNCTION 0x15 -#define CS_UNSUPPORTED_MODE 0x16 +#define CS_UNSUPPORTED_FUNCTION -ENODEV +#define CS_UNSUPPORTED_MODE -ENODEV #define CS_BAD_SPEED -ENODEV #define CS_BUSY -ENODEV #define CS_GENERAL_FAILURE 0x19 -- cgit v1.2.3 From d8b0a49da4f213c637d458319432016f4ea5e12a Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 3 Aug 2008 10:56:13 +0200 Subject: pcmcia: deprecate CS_BAD_VCC and CS_BAD_VPP They were either used to report that changing voltage is not allowed, or that changing voltage failed. Signed-off-by: Dominik Brodowski --- drivers/pcmcia/ds.c | 3 +-- drivers/pcmcia/pcmcia_resource.c | 29 ++++++++++++++++++++--------- include/pcmcia/cs.h | 4 ++-- 3 files changed, 23 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 4a658e2b6f21..f6ff1218b3f3 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -82,8 +82,7 @@ static const lookup_t error_table[] = { { CS_BAD_PAGE, "Bad page number" }, { CS_BAD_SIZE, "Bad size" }, { CS_BAD_TYPE, "Bad type" }, - { CS_BAD_VCC, "Bad Vcc" }, - { CS_BAD_VPP, "Bad Vpp" }, + { -EIO, "Input/Output error" }, { CS_NO_CARD, "No card present" }, { -EINVAL, "Bad parameter" }, { CS_GENERAL_FAILURE, "General failure" }, diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 3b8b0e14d8cf..9b61265fe7be 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -291,20 +291,28 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, s->ops->set_socket(s, &s->socket); } - if (mod->Attributes & CONF_VCC_CHANGE_VALID) - return CS_BAD_VCC; + if (mod->Attributes & CONF_VCC_CHANGE_VALID) { + ds_dbg(s, 0, "changing Vcc is not allowed at this time\n"); + return -EINVAL; + } /* We only allow changing Vpp1 and Vpp2 to the same value */ if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) && (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { if (mod->Vpp1 != mod->Vpp2) - return CS_BAD_VPP; + ds_dbg(s, 0, "Vpp1 and Vpp2 must be the same\n"); + return -EINVAL; s->socket.Vpp = mod->Vpp1; - if (s->ops->set_socket(s, &s->socket)) - return CS_BAD_VPP; + if (s->ops->set_socket(s, &s->socket)) { + dev_printk(KERN_WARNING, &s->dev, + "Unable to set VPP\n"); + return -EIO; + } } else if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) || - (mod->Attributes & CONF_VPP2_CHANGE_VALID)) - return CS_BAD_VPP; + (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { + ds_dbg(s, 0, "changing Vcc is not allowed at this time\n"); + return -EINVAL; + } if (mod->Attributes & CONF_IO_CHANGE_WIDTH) { pccard_io_map io_off = { 0, 0, 0, 0, 1 }; @@ -485,8 +493,11 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev, /* Do power control. We don't allow changes in Vcc. */ s->socket.Vpp = req->Vpp; - if (s->ops->set_socket(s, &s->socket)) - return CS_BAD_VPP; + if (s->ops->set_socket(s, &s->socket)) { + dev_printk(KERN_WARNING, &s->dev, + "Unable to set socket state\n"); + return -EINVAL; + } /* Pick memory or I/O card, DMA mode, interrupt */ c->IntType = req->IntType; diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index 6b51d27ddae8..5d1ed8ec0376 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -300,8 +300,8 @@ typedef struct error_info_t { #define CS_BAD_SIZE 0x0a #define CS_BAD_SOCKET -EINVAL #define CS_BAD_TYPE 0x0d -#define CS_BAD_VCC 0x0e -#define CS_BAD_VPP 0x0f +#define CS_BAD_VCC -EINVAL +#define CS_BAD_VPP -EINVAL #define CS_BAD_WINDOW -ENODEV #define CS_WRITE_FAILURE -EIO #define CS_NO_CARD 0x14 -- cgit v1.2.3 From 3939c1ef1f954409d1441c09fbc08376655758fe Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 3 Aug 2008 11:10:56 +0200 Subject: pcmcia: deprecate CS_NO_CARD It means that no card can be detected in the socket, so return -ENODEV Signed-off-by: Dominik Brodowski --- drivers/pcmcia/cistpl.c | 4 ++-- drivers/pcmcia/cs.c | 16 ++++++++-------- drivers/pcmcia/ds.c | 2 +- drivers/pcmcia/pcmcia_ioctl.c | 4 ++-- drivers/pcmcia/pcmcia_resource.c | 14 +++++++------- include/pcmcia/cs.h | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) (limited to 'include') diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index 71231e8c7edd..a0eae81731c5 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c @@ -427,7 +427,7 @@ int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, tuple if (!s) return CS_BAD_HANDLE; if (!(s->state & SOCKET_PRESENT)) - return CS_NO_CARD; + return -ENODEV; tuple->TupleLink = tuple->Flags = 0; #ifdef CONFIG_CARDBUS if (s->state & SOCKET_CARDBUS) { @@ -507,7 +507,7 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_ if (!s) return CS_BAD_HANDLE; if (!(s->state & SOCKET_PRESENT)) - return CS_NO_CARD; + return -ENODEV; link[1] = tuple->TupleLink; ofs = tuple->CISOffset + tuple->TupleLink; diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index e847c3231da8..15a1203d45fb 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -367,7 +367,7 @@ static int socket_reset(struct pcmcia_socket *skt) skt->ops->get_status(skt, &status); if (!(status & SS_DETECT)) - return CS_NO_CARD; + return -ENODEV; if (status & SS_READY) return 0; @@ -428,14 +428,14 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay) skt->ops->get_status(skt, &status); if (!(status & SS_DETECT)) - return CS_NO_CARD; + return -ENODEV; msleep(initial_delay * 10); for (i = 0; i < 100; i++) { skt->ops->get_status(skt, &status); if (!(status & SS_DETECT)) - return CS_NO_CARD; + return -ENODEV; if (!(status & SS_PENDING)) break; @@ -504,7 +504,7 @@ static int socket_insert(struct pcmcia_socket *skt) cs_dbg(skt, 4, "insert\n"); if (!cs_socket_get(skt)) - return CS_NO_CARD; + return -ENODEV; ret = socket_setup(skt, setup_delay); if (ret == 0) { @@ -761,7 +761,7 @@ int pccard_reset_card(struct pcmcia_socket *skt) mutex_lock(&skt->skt_mutex); do { if (!(skt->state & SOCKET_PRESENT)) { - ret = CS_NO_CARD; + ret = -ENODEV; break; } if (skt->state & SOCKET_SUSPEND) { @@ -806,7 +806,7 @@ int pcmcia_suspend_card(struct pcmcia_socket *skt) mutex_lock(&skt->skt_mutex); do { if (!(skt->state & SOCKET_PRESENT)) { - ret = CS_NO_CARD; + ret = -ENODEV; break; } if (skt->state & SOCKET_CARDBUS) { @@ -836,7 +836,7 @@ int pcmcia_resume_card(struct pcmcia_socket *skt) mutex_lock(&skt->skt_mutex); do { if (!(skt->state & SOCKET_PRESENT)) { - ret = CS_NO_CARD; + ret = -ENODEV; break; } if (skt->state & SOCKET_CARDBUS) { @@ -896,7 +896,7 @@ int pcmcia_insert_card(struct pcmcia_socket *skt) ret = -EBUSY; break; } - if (socket_insert(skt) == CS_NO_CARD) { + if (socket_insert(skt) == -ENODEV) { ret = -ENODEV; break; } diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index f6ff1218b3f3..aaac16aedee3 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -83,7 +83,7 @@ static const lookup_t error_table[] = { { CS_BAD_SIZE, "Bad size" }, { CS_BAD_TYPE, "Bad type" }, { -EIO, "Input/Output error" }, - { CS_NO_CARD, "No card present" }, + { -ENODEV, "No card present" }, { -EINVAL, "Bad parameter" }, { CS_GENERAL_FAILURE, "General failure" }, { CS_BAD_ARGS, "Bad arguments" }, diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index 40bef470b47c..ed8c4fb1e8c1 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c @@ -248,7 +248,7 @@ static int pccard_get_status(struct pcmcia_socket *s, if (s->state & SOCKET_SUSPEND) status->CardState |= CS_EVENT_PM_SUSPEND; if (!(s->state & SOCKET_PRESENT)) - return CS_NO_CARD; + return -ENODEV; c = (p_dev) ? p_dev->function_config : NULL; @@ -294,7 +294,7 @@ int pccard_get_configuration_info(struct pcmcia_socket *s, config_t *c; if (!(s->state & SOCKET_PRESENT)) - return CS_NO_CARD; + return -ENODEV; #ifdef CONFIG_CARDBUS diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 9b61265fe7be..3e013854ec2d 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -169,7 +169,7 @@ int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, u_char val; if (!p_dev || !p_dev->function_config) - return CS_NO_CARD; + return -EINVAL; s = p_dev->socket; c = p_dev->function_config; @@ -206,7 +206,7 @@ int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, int w; if (!s || !(s->state & SOCKET_PRESENT)) - return CS_NO_CARD; + return -ENODEV; for (w = idx; w < MAX_WIN; w++) if (s->state & SOCKET_WIN_REQ(w)) break; @@ -276,7 +276,7 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, c = p_dev->function_config; if (!(s->state & SOCKET_PRESENT)) - return CS_NO_CARD; + return -ENODEV; if (!(c->state & CONFIG_LOCKED)) return CS_CONFIGURATION_LOCKED; @@ -481,7 +481,7 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev, pccard_io_map iomap; if (!(s->state & SOCKET_PRESENT)) - return CS_NO_CARD; + return -ENODEV;; if (req->IntType & INT_CARDBUS) { ds_dbg(p_dev->socket, 0, "IntType may not be INT_CARDBUS\n"); @@ -602,7 +602,7 @@ int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req) config_t *c; if (!(s->state & SOCKET_PRESENT)) - return CS_NO_CARD; + return -ENODEV; if (!req) return -EINVAL; @@ -662,7 +662,7 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req) int type; if (!(s->state & SOCKET_PRESENT)) - return CS_NO_CARD; + return -ENODEV; c = p_dev->function_config; if (c->state & CONFIG_LOCKED) return CS_CONFIGURATION_LOCKED; @@ -771,7 +771,7 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h int w; if (!(s->state & SOCKET_PRESENT)) - return CS_NO_CARD; + return -ENODEV; if (req->Attributes & (WIN_PAGED | WIN_SHARED)) return CS_BAD_ATTRIBUTE; diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index 5d1ed8ec0376..3b4cd51770dd 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -304,7 +304,7 @@ typedef struct error_info_t { #define CS_BAD_VPP -EINVAL #define CS_BAD_WINDOW -ENODEV #define CS_WRITE_FAILURE -EIO -#define CS_NO_CARD 0x14 +#define CS_NO_CARD -ENODEV #define CS_UNSUPPORTED_FUNCTION -ENODEV #define CS_UNSUPPORTED_MODE -ENODEV #define CS_BAD_SPEED -ENODEV -- cgit v1.2.3 From 8567142e87322141f9344d1ab632ccf5190cd0d3 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 3 Aug 2008 11:15:45 +0200 Subject: pcmcia: deprecate CS_GENERAL_FAILURE It's only used by pcmcia_core when socket-related queries time out. Signed-off-by: Dominik Brodowski --- drivers/pcmcia/cs.c | 4 ++-- drivers/pcmcia/ds.c | 1 - include/pcmcia/cs.h | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index 15a1203d45fb..f9424801b9c8 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -376,7 +376,7 @@ static int socket_reset(struct pcmcia_socket *skt) } cs_err(skt, "time out after reset.\n"); - return CS_GENERAL_FAILURE; + return -ETIMEDOUT; } /* @@ -445,7 +445,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay) if (status & SS_PENDING) { cs_err(skt, "voltage interrogation timed out.\n"); - return CS_GENERAL_FAILURE; + return -ETIMEDOUT; } if (status & SS_CARDBUS) { diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index aaac16aedee3..cb500195342f 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -85,7 +85,6 @@ static const lookup_t error_table[] = { { -EIO, "Input/Output error" }, { -ENODEV, "No card present" }, { -EINVAL, "Bad parameter" }, - { CS_GENERAL_FAILURE, "General failure" }, { CS_BAD_ARGS, "Bad arguments" }, { CS_CONFIGURATION_LOCKED, "Configuration locked" }, { CS_IN_USE, "Resource in use" }, diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index 3b4cd51770dd..bec295cb94f6 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -309,7 +309,7 @@ typedef struct error_info_t { #define CS_UNSUPPORTED_MODE -ENODEV #define CS_BAD_SPEED -ENODEV #define CS_BUSY -ENODEV -#define CS_GENERAL_FAILURE 0x19 +#define CS_GENERAL_FAILURE -ETIMEDOUT #define CS_WRITE_PROTECTED -EPERM #define CS_BAD_ARG_LENGTH -ENODEV #define CS_BAD_ARGS 0x1c -- cgit v1.2.3 From ffb8da20271bcfb343e299e5f630dab9ccfb6214 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 3 Aug 2008 11:18:00 +0200 Subject: pcmcia: deprecate CS_BAD_HANDLE CS_BAD_HANDLE means that something went badly wrong: no parameter was passed, or the paramater passed wasn't the correct one. Therefore, replace it with -EINVAL. Signed-off-by: Dominik Brodowski --- drivers/pcmcia/cistpl.c | 8 ++++---- drivers/pcmcia/ds.c | 1 - drivers/pcmcia/pcmcia_resource.c | 12 ++++++------ include/pcmcia/cs.h | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index a0eae81731c5..660e162c502f 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c @@ -425,7 +425,7 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int func, tuple_t *t int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, tuple_t *tuple) { if (!s) - return CS_BAD_HANDLE; + return -EINVAL; if (!(s->state & SOCKET_PRESENT)) return -ENODEV; tuple->TupleLink = tuple->Flags = 0; @@ -505,7 +505,7 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_ int ofs, i, attr; if (!s) - return CS_BAD_HANDLE; + return -EINVAL; if (!(s->state & SOCKET_PRESENT)) return -ENODEV; @@ -603,7 +603,7 @@ int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple) u_int len; if (!s) - return CS_BAD_HANDLE; + return -EINVAL; if (tuple->TupleLink < tuple->TupleOffset) return CS_NO_MORE_ITEMS; @@ -1457,7 +1457,7 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned int ret, reserved, dev_ok = 0, ident_ok = 0; if (!s) - return CS_BAD_HANDLE; + return -EINVAL; tuple = kmalloc(sizeof(*tuple), GFP_KERNEL); if (tuple == NULL) { diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index cb500195342f..6a37198df9f1 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -90,7 +90,6 @@ static const lookup_t error_table[] = { { CS_IN_USE, "Resource in use" }, { CS_NO_MORE_ITEMS, "No more items" }, { CS_OUT_OF_RESOURCE, "Out of resource" }, - { CS_BAD_HANDLE, "Bad handle" }, { CS_BAD_TUPLE, "Bad CIS tuple" } }; diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 3e013854ec2d..55a1238b1c57 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -238,7 +238,7 @@ EXPORT_SYMBOL(pcmcia_get_window); int pcmcia_get_mem_page(window_handle_t win, memreq_t *req) { if ((win == NULL) || (win->magic != WINDOW_MAGIC)) - return CS_BAD_HANDLE; + return -EINVAL; req->Page = 0; req->CardOffset = win->ctl.card_start; return 0; @@ -250,7 +250,7 @@ int pcmcia_map_mem_page(window_handle_t win, memreq_t *req) { struct pcmcia_socket *s; if ((win == NULL) || (win->magic != WINDOW_MAGIC)) - return CS_BAD_HANDLE; + return -EINVAL; if (req->Page != 0) return CS_BAD_PAGE; s = win->sock; @@ -389,7 +389,7 @@ static int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req) config_t *c = p_dev->function_config; if (!p_dev->_io ) - return CS_BAD_HANDLE; + return -EINVAL; p_dev->_io = 0; @@ -415,7 +415,7 @@ static int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req) config_t *c= p_dev->function_config; if (!p_dev->_irq) - return CS_BAD_HANDLE; + return -EINVAL; p_dev->_irq = 0; if (c->state & CONFIG_LOCKED) @@ -446,10 +446,10 @@ int pcmcia_release_window(window_handle_t win) struct pcmcia_socket *s; if ((win == NULL) || (win->magic != WINDOW_MAGIC)) - return CS_BAD_HANDLE; + return -EINVAL; s = win->sock; if (!(win->handle->_win & CLIENT_WIN_REQ(win->index))) - return CS_BAD_HANDLE; + return -EINVAL; /* Shut down memory window */ win->ctl.flags &= ~MAP_ACTIVE; diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index bec295cb94f6..dc5c1eb8ec79 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -317,7 +317,7 @@ typedef struct error_info_t { #define CS_IN_USE 0x1e #define CS_NO_MORE_ITEMS 0x1f #define CS_OUT_OF_RESOURCE -ENOMEM -#define CS_BAD_HANDLE 0x21 +#define CS_BAD_HANDLE -EINVAL #define CS_BAD_TUPLE 0x40 -- cgit v1.2.3 From 943f70f1b5182c5220641ccb7bb905005162e227 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 3 Aug 2008 11:23:42 +0200 Subject: pcmcia: deprecate CS_CONFIGURATION_LOCKED This error code meant that trying to change the configuration after the initialization phase is forbidden. Signed-off-by: Dominik Brodowski --- drivers/pcmcia/ds.c | 2 +- drivers/pcmcia/pcmcia_resource.c | 12 ++++++------ include/pcmcia/cs.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 6a37198df9f1..7f38eb06c81e 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -86,7 +86,7 @@ static const lookup_t error_table[] = { { -ENODEV, "No card present" }, { -EINVAL, "Bad parameter" }, { CS_BAD_ARGS, "Bad arguments" }, - { CS_CONFIGURATION_LOCKED, "Configuration locked" }, + { -EACCES, "Configuration locked" }, { CS_IN_USE, "Resource in use" }, { CS_NO_MORE_ITEMS, "No more items" }, { CS_OUT_OF_RESOURCE, "Out of resource" }, diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 55a1238b1c57..0ac3ea92a1c5 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -175,7 +175,7 @@ int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, c = p_dev->function_config; if (!(c->state & CONFIG_LOCKED)) - return CS_CONFIGURATION_LOCKED; + return -EACCES; addr = (c->ConfigBase + reg->Offset) >> 1; @@ -278,7 +278,7 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, if (!(s->state & SOCKET_PRESENT)) return -ENODEV; if (!(c->state & CONFIG_LOCKED)) - return CS_CONFIGURATION_LOCKED; + return -EACCES; if (mod->Attributes & CONF_IRQ_CHANGE_VALID) { if (mod->Attributes & CONF_ENABLE_IRQ) { @@ -419,7 +419,7 @@ static int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req) p_dev->_irq = 0; if (c->state & CONFIG_LOCKED) - return CS_CONFIGURATION_LOCKED; + return -EACCES; if (c->irq.Attributes != req->Attributes) return CS_BAD_ATTRIBUTE; if (s->irq.AssignedIRQ != req->AssignedIRQ) @@ -489,7 +489,7 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev, } c = p_dev->function_config; if (c->state & CONFIG_LOCKED) - return CS_CONFIGURATION_LOCKED; + return -EACCES; /* Do power control. We don't allow changes in Vcc. */ s->socket.Vpp = req->Vpp; @@ -608,7 +608,7 @@ int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req) return -EINVAL; c = p_dev->function_config; if (c->state & CONFIG_LOCKED) - return CS_CONFIGURATION_LOCKED; + return -EACCES; if (c->state & CONFIG_IO_REQ) return CS_IN_USE; if (req->Attributes1 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS)) @@ -665,7 +665,7 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req) return -ENODEV; c = p_dev->function_config; if (c->state & CONFIG_LOCKED) - return CS_CONFIGURATION_LOCKED; + return -EACCES; if (c->state & CONFIG_IRQ_REQ) return CS_IN_USE; diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index dc5c1eb8ec79..a517a5845af0 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -313,7 +313,7 @@ typedef struct error_info_t { #define CS_WRITE_PROTECTED -EPERM #define CS_BAD_ARG_LENGTH -ENODEV #define CS_BAD_ARGS 0x1c -#define CS_CONFIGURATION_LOCKED 0x1d +#define CS_CONFIGURATION_LOCKED -EACCES #define CS_IN_USE 0x1e #define CS_NO_MORE_ITEMS 0x1f #define CS_OUT_OF_RESOURCE -ENOMEM -- cgit v1.2.3 From f958095ef4fc96e978c6eddcaca29100e5276c7f Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 3 Aug 2008 11:40:19 +0200 Subject: pcmcia: deprecate CS_IN_USE If a resource is already in use, mark it with -EBUSY. Same for cards already asleep. (includes a fix for a bug found by Larry Finger -- thanks!) Signed-off-by: Dominik Brodowski --- drivers/pcmcia/cs.c | 6 +++--- drivers/pcmcia/pcmcia_resource.c | 43 +++++++++++++++++++++++++++------------- include/pcmcia/cs.h | 2 +- 3 files changed, 33 insertions(+), 18 deletions(-) (limited to 'include') diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index f9424801b9c8..1c6c8c8f57c9 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -534,7 +534,7 @@ static int socket_insert(struct pcmcia_socket *skt) static int socket_suspend(struct pcmcia_socket *skt) { if (skt->state & SOCKET_SUSPEND) - return CS_IN_USE; + return -EBUSY; send_event(skt, CS_EVENT_PM_SUSPEND, CS_EVENT_PRI_LOW); skt->socket = dead_socket; @@ -556,7 +556,7 @@ static int socket_resume(struct pcmcia_socket *skt) int ret; if (!(skt->state & SOCKET_SUSPEND)) - return CS_IN_USE; + return -EBUSY; skt->socket = dead_socket; skt->ops->init(skt); @@ -765,7 +765,7 @@ int pccard_reset_card(struct pcmcia_socket *skt) break; } if (skt->state & SOCKET_SUSPEND) { - ret = CS_IN_USE; + ret = -EBUSY; break; } if (skt->state & SOCKET_CARDBUS) { diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 0ac3ea92a1c5..670465d4aac2 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -609,23 +609,30 @@ int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req) c = p_dev->function_config; if (c->state & CONFIG_LOCKED) return -EACCES; - if (c->state & CONFIG_IO_REQ) - return CS_IN_USE; + if (c->state & CONFIG_IO_REQ) { + ds_dbg(s, 0, "IO already configured\n"); + return -EBUSY; + } if (req->Attributes1 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS)) return CS_BAD_ATTRIBUTE; if ((req->NumPorts2 > 0) && (req->Attributes2 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS))) return CS_BAD_ATTRIBUTE; + ds_dbg(s, 1, "trying to allocate resource 1\n"); if (alloc_io_space(s, req->Attributes1, &req->BasePort1, - req->NumPorts1, req->IOAddrLines)) - return CS_IN_USE; + req->NumPorts1, req->IOAddrLines)) { + ds_dbg(s, 0, "allocation of resource 1 failed\n"); + return -EBUSY; + } if (req->NumPorts2) { + ds_dbg(s, 1, "trying to allocate resource 2\n"); if (alloc_io_space(s, req->Attributes2, &req->BasePort2, req->NumPorts2, req->IOAddrLines)) { + ds_dbg(s, 0, "allocation of resource 2 failed\n"); release_io_space(s, req->BasePort1, req->NumPorts1); - return CS_IN_USE; + return -EBUSY; } } @@ -658,7 +665,7 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req) { struct pcmcia_socket *s = p_dev->socket; config_t *c; - int ret = CS_IN_USE, irq = 0; + int ret = -EINVAL, irq = 0; int type; if (!(s->state & SOCKET_PRESENT)) @@ -666,8 +673,10 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req) c = p_dev->function_config; if (c->state & CONFIG_LOCKED) return -EACCES; - if (c->state & CONFIG_IRQ_REQ) - return CS_IN_USE; + if (c->state & CONFIG_IRQ_REQ) { + ds_dbg(s, 0, "IRQ already configured\n"); + return -EBUSY; + } /* Decide what type of interrupt we are registering */ type = 0; @@ -730,8 +739,10 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req) } if (ret && (req->Attributes & IRQ_HANDLE_PRESENT)) { - if (request_irq(irq, req->Handler, type, p_dev->devname, req->Instance)) - return CS_IN_USE; + ret = request_irq(irq, req->Handler, type, + p_dev->devname, req->Instance); + if (ret) + return ret; } /* Make sure the fact the request type was overridden is passed back */ @@ -792,8 +803,10 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h /* Allocate system memory window */ for (w = 0; w < MAX_WIN; w++) if (!(s->state & SOCKET_WIN_REQ(w))) break; - if (w == MAX_WIN) - return CS_IN_USE; + if (w == MAX_WIN) { + ds_dbg(s, 0, "all windows are used already\n"); + return -EINVAL; + } win = &s->win[w]; win->magic = WINDOW_MAGIC; @@ -804,8 +817,10 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h if (!(s->features & SS_CAP_STATIC_MAP)) { win->ctl.res = pcmcia_find_mem_region(req->Base, req->Size, align, (req->Attributes & WIN_MAP_BELOW_1MB), s); - if (!win->ctl.res) - return CS_IN_USE; + if (!win->ctl.res) { + ds_dbg(s, 0, "allocating mem region failed\n"); + return -EINVAL; + } } (*p_dev)->_win |= CLIENT_WIN_REQ(w); diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index a517a5845af0..2dc1411b27c9 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -314,7 +314,7 @@ typedef struct error_info_t { #define CS_BAD_ARG_LENGTH -ENODEV #define CS_BAD_ARGS 0x1c #define CS_CONFIGURATION_LOCKED -EACCES -#define CS_IN_USE 0x1e +#define CS_IN_USE -EBUSY #define CS_NO_MORE_ITEMS 0x1f #define CS_OUT_OF_RESOURCE -ENOMEM #define CS_BAD_HANDLE -EINVAL -- cgit v1.2.3 From 635d19bea0e91df473a81391ec8f3db2d049a218 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 3 Aug 2008 11:47:29 +0200 Subject: pcmcia: deprecate CS_NO_MORE_ITEMS CS_NO_MORE_ITEMS is returned by the CIS tuple reading and parsing code if the end of a tuple chain is reached. As at least one PCMCIA driver relies on matching this return value, replace it with -ENOSPC which is now uniquely used for this purpose within the in-kernel pcmcia subsystem. CC: Russell King CC: linux-serial@vger.kernel.org CC: Michael Buesch Signed-off-by: Dominik Brodowski --- drivers/pcmcia/cistpl.c | 10 +++++----- drivers/pcmcia/ds.c | 2 +- drivers/pcmcia/pcmcia_ioctl.c | 2 +- drivers/pcmcia/pcmcia_resource.c | 2 +- drivers/serial/serial_cs.c | 2 +- drivers/ssb/pcmcia.c | 2 +- include/pcmcia/cs.h | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index 660e162c502f..a59e09dd8557 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c @@ -450,7 +450,7 @@ int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, tuple if (pccard_get_next_tuple(s, function, tuple) == 0) { tuple->DesiredTuple = CISTPL_LINKTARGET; if (pccard_get_next_tuple(s, function, tuple) != 0) - return CS_NO_MORE_ITEMS; + return -ENOSPC; } else tuple->CISOffset = tuple->TupleLink = 0; tuple->DesiredTuple = req; @@ -526,7 +526,7 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_ /* End of chain? Follow long link if possible */ if (link[0] == CISTPL_END) { if ((ofs = follow_link(s, tuple)) < 0) - return CS_NO_MORE_ITEMS; + return -ENOSPC; attr = SPACE(tuple->Flags); read_cis_cache(s, attr, ofs, 2, link); } @@ -584,7 +584,7 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_ } if (i == MAX_TUPLES) { cs_dbg(s, 1, "cs: overrun in pcmcia_get_next_tuple\n"); - return CS_NO_MORE_ITEMS; + return -ENOSPC; } tuple->TupleCode = link[0]; @@ -606,7 +606,7 @@ int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple) return -EINVAL; if (tuple->TupleLink < tuple->TupleOffset) - return CS_NO_MORE_ITEMS; + return -ENOSPC; len = tuple->TupleLink - tuple->TupleOffset; tuple->TupleDataLen = tuple->TupleLink; if (len == 0) @@ -1490,7 +1490,7 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned cards have only a broken VERS_2 tuple; hence the bogus test. */ if ((pccard_read_tuple(s, function, CISTPL_MANFID, p) == 0) || (pccard_read_tuple(s, function, CISTPL_VERS_1, p) == 0) || - (pccard_read_tuple(s, function, CISTPL_VERS_2, p) != CS_NO_MORE_ITEMS)) + (pccard_read_tuple(s, function, CISTPL_VERS_2, p) != -ENOSPC)) ident_ok++; if (!dev_ok && !ident_ok) diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 7f38eb06c81e..591d9627bb2a 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -88,7 +88,7 @@ static const lookup_t error_table[] = { { CS_BAD_ARGS, "Bad arguments" }, { -EACCES, "Configuration locked" }, { CS_IN_USE, "Resource in use" }, - { CS_NO_MORE_ITEMS, "No more items" }, + { -ENOSPC, "No more items" }, { CS_OUT_OF_RESOURCE, "Out of resource" }, { CS_BAD_TUPLE, "Bad CIS tuple" } }; diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index ed8c4fb1e8c1..a6289e5a75e1 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c @@ -973,7 +973,7 @@ static int ds_ioctl(struct inode * inode, struct file * file, err = -EBUSY; break; case CS_OUT_OF_RESOURCE: err = -ENOSPC; break; - case CS_NO_MORE_ITEMS: + case -ENOSPC: err = -ENODATA; break; case -ENOSYS: err = -ENOSYS; break; diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 670465d4aac2..8f2c805e793b 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -211,7 +211,7 @@ int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, if (s->state & SOCKET_WIN_REQ(w)) break; if (w == MAX_WIN) - return CS_NO_MORE_ITEMS; + return -EINVAL; win = &s->win[w]; req->Base = win->ctl.res->start; req->Size = win->ctl.res->end - win->ctl.res->start + 1; diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c index ea7e3c0e02d9..dbb3bf3065fa 100644 --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c @@ -432,7 +432,7 @@ first_tuple(struct pcmcia_device *handle, tuple_t * tuple, cisparse_t * parse) int i; i = pcmcia_get_first_tuple(handle, tuple); if (i != 0) - return CS_NO_MORE_ITEMS; + return i; i = pcmcia_get_tuple_data(handle, tuple); if (i != 0) return i; diff --git a/drivers/ssb/pcmcia.c b/drivers/ssb/pcmcia.c index 96993080c7d1..fbfadbac67e8 100644 --- a/drivers/ssb/pcmcia.c +++ b/drivers/ssb/pcmcia.c @@ -733,7 +733,7 @@ int ssb_pcmcia_get_invariants(struct ssb_bus *bus, break; } res = pcmcia_get_next_tuple(bus->host_pcmcia, &tuple); - if (res == CS_NO_MORE_ITEMS) + if (res == -ENOSPC) break; GOTO_ERROR_ON(res != 0, "VEN next tpl"); res = pcmcia_get_tuple_data(bus->host_pcmcia, &tuple); diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index 2dc1411b27c9..20440defd1d0 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -315,7 +315,7 @@ typedef struct error_info_t { #define CS_BAD_ARGS 0x1c #define CS_CONFIGURATION_LOCKED -EACCES #define CS_IN_USE -EBUSY -#define CS_NO_MORE_ITEMS 0x1f +#define CS_NO_MORE_ITEMS -ENOSPC #define CS_OUT_OF_RESOURCE -ENOMEM #define CS_BAD_HANDLE -EINVAL -- cgit v1.2.3 From 610e23749e87920136e1a221266a43cb7e3823f1 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 3 Aug 2008 11:58:53 +0200 Subject: pcmcia: deprecate CS_BAD_ATTRIBUTE, CS_BAD_TYPE and CS_BAD_PAGE CS_BAD_TYPE was only used in cs.c and already properly annotated by error messages. CS_BAD_ATTRIBUTE and CS_BAD_PAGE mean a badly written driver, so ds_dbg() output and -EINVAL seems to be enough. (includes bugfix from and Signed-off-by: Harvey Harrison ) Signed-off-by: Dominik Brodowski --- drivers/pcmcia/cs.c | 6 +++--- drivers/pcmcia/ds.c | 9 +++------ drivers/pcmcia/pcmcia_ioctl.c | 16 ++++++++-------- drivers/pcmcia/pcmcia_resource.c | 30 ++++++++++++++++++++---------- include/pcmcia/cs.h | 6 +++--- 5 files changed, 37 insertions(+), 30 deletions(-) (limited to 'include') diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index 1c6c8c8f57c9..48386f31e610 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -451,7 +451,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay) if (status & SS_CARDBUS) { if (!(skt->features & SS_CAP_CARDBUS)) { cs_err(skt, "cardbus cards are not supported.\n"); - return CS_BAD_TYPE; + return -EINVAL; } skt->state |= SOCKET_CARDBUS; } @@ -465,7 +465,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay) skt->socket.Vcc = skt->socket.Vpp = 50; else { cs_err(skt, "unsupported voltage key.\n"); - return CS_BAD_TYPE; + return -EIO; } if (skt->power_hook) @@ -482,7 +482,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay) skt->ops->get_status(skt, &status); if (!(status & SS_POWERON)) { cs_err(skt, "unable to apply power.\n"); - return CS_BAD_TYPE; + return -EIO; } status = socket_reset(skt); diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 591d9627bb2a..4092a5976e62 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -74,22 +74,19 @@ typedef struct lookup_t { } lookup_t; static const lookup_t error_table[] = { - { CS_SUCCESS, "Operation succeeded" }, - { CS_BAD_ATTRIBUTE, "Bad attribute", }, + { 0, "Operation succeeded" }, { CS_BAD_BASE, "Bad base address" }, { CS_BAD_IRQ, "Bad IRQ" }, { CS_BAD_OFFSET, "Bad offset" }, - { CS_BAD_PAGE, "Bad page number" }, { CS_BAD_SIZE, "Bad size" }, - { CS_BAD_TYPE, "Bad type" }, { -EIO, "Input/Output error" }, { -ENODEV, "No card present" }, { -EINVAL, "Bad parameter" }, { CS_BAD_ARGS, "Bad arguments" }, { -EACCES, "Configuration locked" }, - { CS_IN_USE, "Resource in use" }, + { -EBUSY, "Resource in use" }, { -ENOSPC, "No more items" }, - { CS_OUT_OF_RESOURCE, "Out of resource" }, + { -ENOMEM, "Out of resource" }, { CS_BAD_TUPLE, "Bad CIS tuple" } }; diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index a6289e5a75e1..e27c71ebfda2 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c @@ -964,19 +964,19 @@ static int ds_ioctl(struct inode * inode, struct file * file, if ((err == 0) && (ret != 0)) { ds_dbg(2, "ds_ioctl: ret = %d\n", ret); switch (ret) { - case CS_BAD_SOCKET: case CS_NO_CARD: - err = -ENODEV; break; - case CS_BAD_ARGS: case CS_BAD_ATTRIBUTE: case CS_BAD_IRQ: + case -ENODEV: + case -EINVAL: + case -EBUSY: + case -ENOSYS: + err = ret; + break; + case CS_BAD_ARGS: case CS_BAD_IRQ: case CS_BAD_TUPLE: err = -EINVAL; break; - case CS_IN_USE: - err = -EBUSY; break; - case CS_OUT_OF_RESOURCE: + case -ENOMEM: err = -ENOSPC; break; case -ENOSPC: err = -ENODATA; break; - case -ENOSYS: - err = -ENOSYS; break; default: err = -EIO; break; } diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 8f2c805e793b..35a61577ae4e 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -251,9 +251,11 @@ int pcmcia_map_mem_page(window_handle_t win, memreq_t *req) struct pcmcia_socket *s; if ((win == NULL) || (win->magic != WINDOW_MAGIC)) return -EINVAL; - if (req->Page != 0) - return CS_BAD_PAGE; s = win->sock; + if (req->Page != 0) { + ds_dbg(s, 0, "failure: requested page is zero\n"); + return -EINVAL; + } win->ctl.card_start = req->CardOffset; if (s->ops->set_mem_map(s, &win->ctl) != 0) return CS_BAD_OFFSET; @@ -420,8 +422,10 @@ static int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req) if (c->state & CONFIG_LOCKED) return -EACCES; - if (c->irq.Attributes != req->Attributes) - return CS_BAD_ATTRIBUTE; + if (c->irq.Attributes != req->Attributes) { + ds_dbg(s, 0, "IRQ attributes must match assigned ones\n"); + return -EINVAL; + } if (s->irq.AssignedIRQ != req->AssignedIRQ) return CS_BAD_IRQ; if (--s->irq.Config == 0) { @@ -613,11 +617,15 @@ int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req) ds_dbg(s, 0, "IO already configured\n"); return -EBUSY; } - if (req->Attributes1 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS)) - return CS_BAD_ATTRIBUTE; + if (req->Attributes1 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS)) { + ds_dbg(s, 0, "bad attribute setting for IO region 1\n"); + return -EINVAL; + } if ((req->NumPorts2 > 0) && - (req->Attributes2 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS))) - return CS_BAD_ATTRIBUTE; + (req->Attributes2 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS))) { + ds_dbg(s, 0, "bad attribute setting for IO region 2\n"); + return -EINVAL; + } ds_dbg(s, 1, "trying to allocate resource 1\n"); if (alloc_io_space(s, req->Attributes1, &req->BasePort1, @@ -783,8 +791,10 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h if (!(s->state & SOCKET_PRESENT)) return -ENODEV; - if (req->Attributes & (WIN_PAGED | WIN_SHARED)) - return CS_BAD_ATTRIBUTE; + if (req->Attributes & (WIN_PAGED | WIN_SHARED)) { + ds_dbg(s, 0, "bad attribute setting for iomem region\n"); + return -EINVAL; + } /* Window size defaults to smallest available */ if (req->Size == 0) diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index 20440defd1d0..70c32e97b492 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -290,16 +290,16 @@ typedef struct error_info_t { /* Return codes */ #define CS_SUCCESS 0x00 #define CS_BAD_ADAPTER -ENODEV -#define CS_BAD_ATTRIBUTE 0x02 +#define CS_BAD_ATTRIBUTE -EINVAL #define CS_BAD_BASE 0x03 #define CS_BAD_EDC -ENODEV #define CS_BAD_IRQ 0x06 #define CS_BAD_OFFSET 0x07 -#define CS_BAD_PAGE 0x08 +#define CS_BAD_PAGE -EINVAL #define CS_READ_FAILURE -EIO #define CS_BAD_SIZE 0x0a #define CS_BAD_SOCKET -EINVAL -#define CS_BAD_TYPE 0x0d +#define CS_BAD_TYPE -EINVAL #define CS_BAD_VCC -EINVAL #define CS_BAD_VPP -EINVAL #define CS_BAD_WINDOW -ENODEV -- cgit v1.2.3 From 69ba44331e81e4a15b504175ec70b7b4b4e5a8b9 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 3 Aug 2008 12:10:53 +0200 Subject: pcmcia: deprecate CS_BAD_BASE, CS_BAD_IRQ, CS_BAD_OFFSET and CS_BAD_SIZE These four error values mostly mean a badly written driver, so ds_dbg() output and -EINVAL seems to be enough. Signed-off-by: Dominik Brodowski --- drivers/pcmcia/ds.c | 4 ---- drivers/pcmcia/pcmcia_ioctl.c | 5 ++--- drivers/pcmcia/pcmcia_resource.c | 24 ++++++++++++++++-------- include/pcmcia/cs.h | 8 ++++---- 4 files changed, 22 insertions(+), 19 deletions(-) (limited to 'include') diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 4092a5976e62..3ccf4091e877 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -75,10 +75,6 @@ typedef struct lookup_t { static const lookup_t error_table[] = { { 0, "Operation succeeded" }, - { CS_BAD_BASE, "Bad base address" }, - { CS_BAD_IRQ, "Bad IRQ" }, - { CS_BAD_OFFSET, "Bad offset" }, - { CS_BAD_SIZE, "Bad size" }, { -EIO, "Input/Output error" }, { -ENODEV, "No card present" }, { -EINVAL, "Bad parameter" }, diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index e27c71ebfda2..99563134ac0f 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c @@ -149,7 +149,7 @@ static int adjust_irq(struct pcmcia_socket *s, adjust_t *adj) irq = adj->resource.irq.IRQ; if ((irq < 0) || (irq > 15)) - return CS_BAD_IRQ; + return -EINVAL; if (adj->Action != REMOVE_MANAGED_RESOURCE) return 0; @@ -970,8 +970,7 @@ static int ds_ioctl(struct inode * inode, struct file * file, case -ENOSYS: err = ret; break; - case CS_BAD_ARGS: case CS_BAD_IRQ: - case CS_BAD_TUPLE: + case CS_BAD_ARGS: case CS_BAD_TUPLE: err = -EINVAL; break; case -ENOMEM: err = -ENOSPC; break; diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 35a61577ae4e..fee57139a96f 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -257,8 +257,10 @@ int pcmcia_map_mem_page(window_handle_t win, memreq_t *req) return -EINVAL; } win->ctl.card_start = req->CardOffset; - if (s->ops->set_mem_map(s, &win->ctl) != 0) - return CS_BAD_OFFSET; + if (s->ops->set_mem_map(s, &win->ctl) != 0) { + ds_dbg(s, 0, "failed to set_mem_map\n"); + return -EIO; + } return 0; } /* pcmcia_map_mem_page */ EXPORT_SYMBOL(pcmcia_map_mem_page); @@ -426,8 +428,10 @@ static int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req) ds_dbg(s, 0, "IRQ attributes must match assigned ones\n"); return -EINVAL; } - if (s->irq.AssignedIRQ != req->AssignedIRQ) - return CS_BAD_IRQ; + if (s->irq.AssignedIRQ != req->AssignedIRQ) { + ds_dbg(s, 0, "IRQ must match assigned one\n"); + return -EINVAL; + } if (--s->irq.Config == 0) { c->state &= ~CONFIG_IRQ_REQ; s->irq.AssignedIRQ = 0; @@ -802,11 +806,15 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h align = (((s->features & SS_CAP_MEM_ALIGN) || (req->Attributes & WIN_STRICT_ALIGN)) ? req->Size : s->map_size); - if (req->Size & (s->map_size-1)) - return CS_BAD_SIZE; + if (req->Size & (s->map_size-1)) { + ds_dbg(s, 0, "invalid map size\n"); + return -EINVAL; + } if ((req->Base && (s->features & SS_CAP_STATIC_MAP)) || - (req->Base & (align-1))) - return CS_BAD_BASE; + (req->Base & (align-1))) { + ds_dbg(s, 0, "invalid base address\n"); + return -EINVAL; + } if (req->Base) align = 0; diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index 70c32e97b492..4951eb94493a 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -291,13 +291,13 @@ typedef struct error_info_t { #define CS_SUCCESS 0x00 #define CS_BAD_ADAPTER -ENODEV #define CS_BAD_ATTRIBUTE -EINVAL -#define CS_BAD_BASE 0x03 +#define CS_BAD_BASE -EINVAL #define CS_BAD_EDC -ENODEV -#define CS_BAD_IRQ 0x06 -#define CS_BAD_OFFSET 0x07 +#define CS_BAD_IRQ -EINVAL +#define CS_BAD_OFFSET -EIO #define CS_BAD_PAGE -EINVAL #define CS_READ_FAILURE -EIO -#define CS_BAD_SIZE 0x0a +#define CS_BAD_SIZE -EINVAL #define CS_BAD_SOCKET -EINVAL #define CS_BAD_TYPE -EINVAL #define CS_BAD_VCC -EINVAL -- cgit v1.2.3 From 926c5402c287f6d911f7d00f936f09ea00880527 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 3 Aug 2008 12:15:11 +0200 Subject: pcmcia: deprecate CS_BAD_ARGS CS_BAD_ARGS mean a badly written driver or invalid userspace ioctl access, so translate that to -EINVAL. Signed-off-by: Dominik Brodowski --- drivers/pcmcia/ds.c | 1 - drivers/pcmcia/pcmcia_ioctl.c | 8 ++++---- drivers/pcmcia/pcmcia_resource.c | 10 ++++++---- include/pcmcia/cs.h | 4 ++-- 4 files changed, 12 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 3ccf4091e877..5b24938ca154 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -78,7 +78,6 @@ static const lookup_t error_table[] = { { -EIO, "Input/Output error" }, { -ENODEV, "No card present" }, { -EINVAL, "Bad parameter" }, - { CS_BAD_ARGS, "Bad arguments" }, { -EACCES, "Configuration locked" }, { -EBUSY, "Resource in use" }, { -ENOSPC, "No more items" }, diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index 99563134ac0f..f2352c227570 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c @@ -836,7 +836,7 @@ static int ds_ioctl(struct inode * inode, struct file * file, case DS_GET_CONFIGURATION_INFO: if (buf->config.Function && (buf->config.Function >= s->functions)) - ret = CS_BAD_ARGS; + ret = -EINVAL; else { struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->config.Function); ret = pccard_get_configuration_info(s, p_dev, &buf->config); @@ -867,7 +867,7 @@ static int ds_ioctl(struct inode * inode, struct file * file, case DS_GET_STATUS: if (buf->status.Function && (buf->status.Function >= s->functions)) - ret = CS_BAD_ARGS; + ret = -EINVAL; else { struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->status.Function); ret = pccard_get_status(s, p_dev, &buf->status); @@ -898,7 +898,7 @@ static int ds_ioctl(struct inode * inode, struct file * file, goto free_out; } - ret = CS_BAD_ARGS; + ret = -EINVAL; if (!(buf->conf_reg.Function && (buf->conf_reg.Function >= s->functions))) { @@ -970,7 +970,7 @@ static int ds_ioctl(struct inode * inode, struct file * file, case -ENOSYS: err = ret; break; - case CS_BAD_ARGS: case CS_BAD_TUPLE: + case CS_BAD_TUPLE: err = -EINVAL; break; case -ENOMEM: err = -ENOSPC; break; diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index fee57139a96f..de13c424101c 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -189,7 +189,7 @@ int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, pcmcia_write_cis_mem(s, 1, addr, 1, &val); break; default: - return CS_BAD_ARGS; + return -EINVAL; break; } return 0; @@ -401,7 +401,7 @@ static int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req) (c->io.NumPorts1 != req->NumPorts1) || (c->io.BasePort2 != req->BasePort2) || (c->io.NumPorts2 != req->NumPorts2)) - return CS_BAD_ARGS; + return -EINVAL; c->state &= ~CONFIG_IO_REQ; @@ -855,8 +855,10 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h if (req->Attributes & WIN_USE_WAIT) win->ctl.flags |= MAP_USE_WAIT; win->ctl.card_start = 0; - if (s->ops->set_mem_map(s, &win->ctl) != 0) - return CS_BAD_ARGS; + if (s->ops->set_mem_map(s, &win->ctl) != 0) { + ds_dbg(s, 0, "failed to set memory mapping\n"); + return -EIO; + } s->state |= SOCKET_WIN_REQ(w); /* Return window handle */ diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index 4951eb94493a..56f94e297500 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -294,7 +294,7 @@ typedef struct error_info_t { #define CS_BAD_BASE -EINVAL #define CS_BAD_EDC -ENODEV #define CS_BAD_IRQ -EINVAL -#define CS_BAD_OFFSET -EIO +#define CS_BAD_OFFSET -EINVAL #define CS_BAD_PAGE -EINVAL #define CS_READ_FAILURE -EIO #define CS_BAD_SIZE -EINVAL @@ -312,7 +312,7 @@ typedef struct error_info_t { #define CS_GENERAL_FAILURE -ETIMEDOUT #define CS_WRITE_PROTECTED -EPERM #define CS_BAD_ARG_LENGTH -ENODEV -#define CS_BAD_ARGS 0x1c +#define CS_BAD_ARGS -EINVAL #define CS_CONFIGURATION_LOCKED -EACCES #define CS_IN_USE -EBUSY #define CS_NO_MORE_ITEMS -ENOSPC -- cgit v1.2.3 From 3f9c5f4cb7e00d424a56a6431e9c98b3b17851e4 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 3 Aug 2008 12:22:40 +0200 Subject: pcmcia: deprecate CS_BAD_TUPLE CS_BAD_TUPLE was used to denote a bad tuple being passed to the parse function. Therefore, replace it with -EINVAL and a verbose message. Signed-off-by: Dominik Brodowski --- drivers/pcmcia/cistpl.c | 144 +++++++++++++++++++++++++++--------------- drivers/pcmcia/cs_internal.h | 6 ++ drivers/pcmcia/ds.c | 1 - drivers/pcmcia/pcmcia_ioctl.c | 2 - include/pcmcia/cs.h | 2 +- 5 files changed, 99 insertions(+), 56 deletions(-) (limited to 'include') diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index a59e09dd8557..772fc96d5ec3 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c @@ -647,22 +647,28 @@ static int parse_device(tuple_t *tuple, cistpl_device_t *device) case 3: device->dev[i].speed = 150; break; case 4: device->dev[i].speed = 100; break; case 7: - if (++p == q) return CS_BAD_TUPLE; + if (++p == q) + return -EINVAL; device->dev[i].speed = SPEED_CVT(*p); while (*p & 0x80) - if (++p == q) return CS_BAD_TUPLE; + if (++p == q) + return -EINVAL; break; default: - return CS_BAD_TUPLE; + return -EINVAL; } - if (++p == q) return CS_BAD_TUPLE; - if (*p == 0xff) break; + if (++p == q) + return -EINVAL; + if (*p == 0xff) + break; scale = *p & 7; - if (scale == 7) return CS_BAD_TUPLE; + if (scale == 7) + return -EINVAL; device->dev[i].size = ((*p >> 3) + 1) * (512 << (scale*2)); device->ndev++; - if (++p == q) break; + if (++p == q) + break; } return 0; @@ -674,7 +680,7 @@ static int parse_checksum(tuple_t *tuple, cistpl_checksum_t *csum) { u_char *p; if (tuple->TupleDataLen < 5) - return CS_BAD_TUPLE; + return -EINVAL; p = (u_char *) tuple->TupleData; csum->addr = tuple->CISOffset + get_unaligned_le16(p) - 2; csum->len = get_unaligned_le16(p + 2); @@ -687,7 +693,7 @@ static int parse_checksum(tuple_t *tuple, cistpl_checksum_t *csum) static int parse_longlink(tuple_t *tuple, cistpl_longlink_t *link) { if (tuple->TupleDataLen < 4) - return CS_BAD_TUPLE; + return -EINVAL; link->addr = get_unaligned_le32(tuple->TupleData); return 0; } @@ -704,7 +710,7 @@ static int parse_longlink_mfc(tuple_t *tuple, link->nfn = *p; p++; if (tuple->TupleDataLen <= link->nfn*5) - return CS_BAD_TUPLE; + return -EINVAL; for (i = 0; i < link->nfn; i++) { link->fn[i].space = *p; p++; link->fn[i].addr = get_unaligned_le32(p); @@ -720,16 +726,19 @@ static int parse_strings(u_char *p, u_char *q, int max, { int i, j, ns; - if (p == q) return CS_BAD_TUPLE; + if (p == q) + return -EINVAL; ns = 0; j = 0; for (i = 0; i < max; i++) { - if (*p == 0xff) break; + if (*p == 0xff) + break; ofs[i] = j; ns++; for (;;) { s[j++] = (*p == 0xff) ? '\0' : *p; if ((*p == '\0') || (*p == 0xff)) break; - if (++p == q) return CS_BAD_TUPLE; + if (++p == q) + return -EINVAL; } if ((*p == 0xff) || (++p == q)) break; } @@ -737,7 +746,7 @@ static int parse_strings(u_char *p, u_char *q, int max, *found = ns; return 0; } else { - return (ns == max) ? 0 : CS_BAD_TUPLE; + return (ns == max) ? 0 : -EINVAL; } } @@ -752,7 +761,8 @@ static int parse_vers_1(tuple_t *tuple, cistpl_vers_1_t *vers_1) vers_1->major = *p; p++; vers_1->minor = *p; p++; - if (p >= q) return CS_BAD_TUPLE; + if (p >= q) + return -EINVAL; return parse_strings(p, q, CISTPL_VERS_1_MAX_PROD_STRINGS, vers_1->str, vers_1->ofs, &vers_1->ns); @@ -796,7 +806,7 @@ static int parse_jedec(tuple_t *tuple, cistpl_jedec_t *jedec) static int parse_manfid(tuple_t *tuple, cistpl_manfid_t *m) { if (tuple->TupleDataLen < 4) - return CS_BAD_TUPLE; + return -EINVAL; m->manf = get_unaligned_le16(tuple->TupleData); m->card = get_unaligned_le16(tuple->TupleData + 2); return 0; @@ -808,7 +818,7 @@ static int parse_funcid(tuple_t *tuple, cistpl_funcid_t *f) { u_char *p; if (tuple->TupleDataLen < 2) - return CS_BAD_TUPLE; + return -EINVAL; p = (u_char *)tuple->TupleData; f->func = p[0]; f->sysinit = p[1]; @@ -822,7 +832,7 @@ static int parse_funce(tuple_t *tuple, cistpl_funce_t *f) u_char *p; int i; if (tuple->TupleDataLen < 1) - return CS_BAD_TUPLE; + return -EINVAL; p = (u_char *)tuple->TupleData; f->type = p[0]; for (i = 1; i < tuple->TupleDataLen; i++) @@ -841,7 +851,7 @@ static int parse_config(tuple_t *tuple, cistpl_config_t *config) rasz = *p & 0x03; rmsz = (*p & 0x3c) >> 2; if (tuple->TupleDataLen < rasz+rmsz+4) - return CS_BAD_TUPLE; + return -EINVAL; config->last_idx = *(++p); p++; config->base = 0; @@ -1009,10 +1019,12 @@ static u_char *parse_mem(u_char *p, u_char *q, cistpl_mem_t *mem) static u_char *parse_irq(u_char *p, u_char *q, cistpl_irq_t *irq) { - if (p == q) return NULL; + if (p == q) + return NULL; irq->IRQInfo1 = *p; p++; if (irq->IRQInfo1 & IRQ_INFO2_VALID) { - if (p+2 > q) return NULL; + if (p+2 > q) + return NULL; irq->IRQInfo2 = (p[1]<<8) + p[0]; p += 2; } @@ -1033,7 +1045,8 @@ static int parse_cftable_entry(tuple_t *tuple, if (*p & 0x40) entry->flags |= CISTPL_CFTABLE_DEFAULT; if (*p & 0x80) { - if (++p == q) return CS_BAD_TUPLE; + if (++p == q) + return -EINVAL; if (*p & 0x10) entry->flags |= CISTPL_CFTABLE_BVDS; if (*p & 0x20) @@ -1047,30 +1060,35 @@ static int parse_cftable_entry(tuple_t *tuple, entry->interface = 0; /* Process optional features */ - if (++p == q) return CS_BAD_TUPLE; + if (++p == q) + return -EINVAL; features = *p; p++; /* Power options */ if ((features & 3) > 0) { p = parse_power(p, q, &entry->vcc); - if (p == NULL) return CS_BAD_TUPLE; + if (p == NULL) + return -EINVAL; } else entry->vcc.present = 0; if ((features & 3) > 1) { p = parse_power(p, q, &entry->vpp1); - if (p == NULL) return CS_BAD_TUPLE; + if (p == NULL) + return -EINVAL; } else entry->vpp1.present = 0; if ((features & 3) > 2) { p = parse_power(p, q, &entry->vpp2); - if (p == NULL) return CS_BAD_TUPLE; + if (p == NULL) + return -EINVAL; } else entry->vpp2.present = 0; /* Timing options */ if (features & 0x04) { p = parse_timing(p, q, &entry->timing); - if (p == NULL) return CS_BAD_TUPLE; + if (p == NULL) + return -EINVAL; } else { entry->timing.wait = 0; entry->timing.ready = 0; @@ -1080,14 +1098,16 @@ static int parse_cftable_entry(tuple_t *tuple, /* I/O window options */ if (features & 0x08) { p = parse_io(p, q, &entry->io); - if (p == NULL) return CS_BAD_TUPLE; + if (p == NULL) + return -EINVAL; } else entry->io.nwin = 0; /* Interrupt options */ if (features & 0x10) { p = parse_irq(p, q, &entry->irq); - if (p == NULL) return CS_BAD_TUPLE; + if (p == NULL) + return -EINVAL; } else entry->irq.IRQInfo1 = 0; @@ -1101,7 +1121,8 @@ static int parse_cftable_entry(tuple_t *tuple, entry->mem.win[0].card_addr = 0; entry->mem.win[0].host_addr = 0; p += 2; - if (p > q) return CS_BAD_TUPLE; + if (p > q) + return -EINVAL; break; case 0x40: entry->mem.nwin = 1; @@ -1109,20 +1130,24 @@ static int parse_cftable_entry(tuple_t *tuple, entry->mem.win[0].card_addr = get_unaligned_le16(p + 2) << 8; entry->mem.win[0].host_addr = 0; p += 4; - if (p > q) return CS_BAD_TUPLE; + if (p > q) + return -EINVAL; break; case 0x60: p = parse_mem(p, q, &entry->mem); - if (p == NULL) return CS_BAD_TUPLE; + if (p == NULL) + return -EINVAL; break; } /* Misc features */ if (features & 0x80) { - if (p == q) return CS_BAD_TUPLE; + if (p == q) + return -EINVAL; entry->flags |= (*p << 8); while (*p & 0x80) - if (++p == q) return CS_BAD_TUPLE; + if (++p == q) + return -EINVAL; p++; } @@ -1139,7 +1164,7 @@ static int parse_bar(tuple_t *tuple, cistpl_bar_t *bar) { u_char *p; if (tuple->TupleDataLen < 6) - return CS_BAD_TUPLE; + return -EINVAL; p = (u_char *)tuple->TupleData; bar->attr = *p; p += 2; @@ -1153,7 +1178,7 @@ static int parse_config_cb(tuple_t *tuple, cistpl_config_t *config) p = (u_char *)tuple->TupleData; if ((*p != 3) || (tuple->TupleDataLen < 6)) - return CS_BAD_TUPLE; + return -EINVAL; config->last_idx = *(++p); p++; config->base = get_unaligned_le32(p); @@ -1174,29 +1199,34 @@ static int parse_cftable_entry_cb(tuple_t *tuple, entry->flags |= CISTPL_CFTABLE_DEFAULT; /* Process optional features */ - if (++p == q) return CS_BAD_TUPLE; + if (++p == q) + return -EINVAL; features = *p; p++; /* Power options */ if ((features & 3) > 0) { p = parse_power(p, q, &entry->vcc); - if (p == NULL) return CS_BAD_TUPLE; + if (p == NULL) + return -EINVAL; } else entry->vcc.present = 0; if ((features & 3) > 1) { p = parse_power(p, q, &entry->vpp1); - if (p == NULL) return CS_BAD_TUPLE; + if (p == NULL) + return -EINVAL; } else entry->vpp1.present = 0; if ((features & 3) > 2) { p = parse_power(p, q, &entry->vpp2); - if (p == NULL) return CS_BAD_TUPLE; + if (p == NULL) + return -EINVAL; } else entry->vpp2.present = 0; /* I/O window options */ if (features & 0x08) { - if (p == q) return CS_BAD_TUPLE; + if (p == q) + return -EINVAL; entry->io = *p; p++; } else entry->io = 0; @@ -1204,26 +1234,31 @@ static int parse_cftable_entry_cb(tuple_t *tuple, /* Interrupt options */ if (features & 0x10) { p = parse_irq(p, q, &entry->irq); - if (p == NULL) return CS_BAD_TUPLE; + if (p == NULL) + return -EINVAL; } else entry->irq.IRQInfo1 = 0; if (features & 0x20) { - if (p == q) return CS_BAD_TUPLE; + if (p == q) + return -EINVAL; entry->mem = *p; p++; } else entry->mem = 0; /* Misc features */ if (features & 0x80) { - if (p == q) return CS_BAD_TUPLE; + if (p == q) + return -EINVAL; entry->flags |= (*p << 8); if (*p & 0x80) { - if (++p == q) return CS_BAD_TUPLE; + if (++p == q) + return -EINVAL; entry->flags |= (*p << 16); } while (*p & 0x80) - if (++p == q) return CS_BAD_TUPLE; + if (++p == q) + return -EINVAL; p++; } @@ -1265,7 +1300,7 @@ static int parse_vers_2(tuple_t *tuple, cistpl_vers_2_t *v2) u_char *p, *q; if (tuple->TupleDataLen < 10) - return CS_BAD_TUPLE; + return -EINVAL; p = tuple->TupleData; q = p + tuple->TupleDataLen; @@ -1289,13 +1324,16 @@ static int parse_org(tuple_t *tuple, cistpl_org_t *org) p = tuple->TupleData; q = p + tuple->TupleDataLen; - if (p == q) return CS_BAD_TUPLE; + if (p == q) + return -EINVAL; org->data_org = *p; - if (++p == q) return CS_BAD_TUPLE; + if (++p == q) + return -EINVAL; for (i = 0; i < 30; i++) { org->desc[i] = *p; if (*p == '\0') break; - if (++p == q) return CS_BAD_TUPLE; + if (++p == q) + return -EINVAL; } return 0; } @@ -1307,7 +1345,7 @@ static int parse_format(tuple_t *tuple, cistpl_format_t *fmt) u_char *p; if (tuple->TupleDataLen < 10) - return CS_BAD_TUPLE; + return -EINVAL; p = tuple->TupleData; @@ -1326,7 +1364,7 @@ int pccard_parse_tuple(tuple_t *tuple, cisparse_t *parse) int ret = 0; if (tuple->TupleDataLen > tuple->TupleDataMax) - return CS_BAD_TUPLE; + return -EINVAL; switch (tuple->TupleCode) { case CISTPL_DEVICE: case CISTPL_DEVICE_A: @@ -1400,6 +1438,8 @@ int pccard_parse_tuple(tuple_t *tuple, cisparse_t *parse) ret = -EINVAL; break; } + if (ret) + __cs_dbg(0, "parse_tuple failed %d\n", ret); return ret; } EXPORT_SYMBOL(pccard_parse_tuple); diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 384a76bd38eb..3fcdf4fbca0e 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h @@ -137,9 +137,15 @@ extern int cs_debug_level(int); dev_printk(KERN_DEBUG, &skt->dev, \ "cs: " fmt, ## arg); \ } while (0) +#define __cs_dbg(lvl, fmt, arg...) do { \ + if (cs_debug_level(lvl)) \ + printk(KERN_DEBUG \ + "cs: " fmt, ## arg); \ +} while (0) #else #define cs_dbg(skt, lvl, fmt, arg...) do { } while (0) +#define __cs_dbg(lvl, fmt, arg...) do { } while (0) #endif #define cs_err(skt, fmt, arg...) \ diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 5b24938ca154..55a46af33ca4 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -82,7 +82,6 @@ static const lookup_t error_table[] = { { -EBUSY, "Resource in use" }, { -ENOSPC, "No more items" }, { -ENOMEM, "Out of resource" }, - { CS_BAD_TUPLE, "Bad CIS tuple" } }; diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index f2352c227570..d4c3f9aa3d83 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c @@ -970,8 +970,6 @@ static int ds_ioctl(struct inode * inode, struct file * file, case -ENOSYS: err = ret; break; - case CS_BAD_TUPLE: - err = -EINVAL; break; case -ENOMEM: err = -ENOSPC; break; case -ENOSPC: diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index 56f94e297500..d672fdefdf22 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -319,7 +319,7 @@ typedef struct error_info_t { #define CS_OUT_OF_RESOURCE -ENOMEM #define CS_BAD_HANDLE -EINVAL -#define CS_BAD_TUPLE 0x40 +#define CS_BAD_TUPLE -EINVAL #ifdef __KERNEL__ -- cgit v1.2.3 From 9c8b7965f594fdff37c59446b9314ed7b4b44d07 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 3 Aug 2008 12:27:56 +0200 Subject: pcmcia: remove CS_ error codes alltogether Remoe the CS_ error codes. Drivers are expected to use default error definitions (errno.h etc.). Only one CS_ error code -- CS_IN_USE -- is used internally by the (deprecated) pcmcia-cs userspace package. Therefore, keep this one around so that it still compiles. Signed-off-by: Dominik Brodowski --- include/pcmcia/cs.h | 33 --------------------------------- include/pcmcia/ds.h | 3 +++ 2 files changed, 3 insertions(+), 33 deletions(-) (limited to 'include') diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index d672fdefdf22..3585e1be4c5c 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -287,39 +287,6 @@ typedef struct error_info_t { #define CS_EVENT_3VCARD 0x200000 #define CS_EVENT_XVCARD 0x400000 -/* Return codes */ -#define CS_SUCCESS 0x00 -#define CS_BAD_ADAPTER -ENODEV -#define CS_BAD_ATTRIBUTE -EINVAL -#define CS_BAD_BASE -EINVAL -#define CS_BAD_EDC -ENODEV -#define CS_BAD_IRQ -EINVAL -#define CS_BAD_OFFSET -EINVAL -#define CS_BAD_PAGE -EINVAL -#define CS_READ_FAILURE -EIO -#define CS_BAD_SIZE -EINVAL -#define CS_BAD_SOCKET -EINVAL -#define CS_BAD_TYPE -EINVAL -#define CS_BAD_VCC -EINVAL -#define CS_BAD_VPP -EINVAL -#define CS_BAD_WINDOW -ENODEV -#define CS_WRITE_FAILURE -EIO -#define CS_NO_CARD -ENODEV -#define CS_UNSUPPORTED_FUNCTION -ENODEV -#define CS_UNSUPPORTED_MODE -ENODEV -#define CS_BAD_SPEED -ENODEV -#define CS_BUSY -ENODEV -#define CS_GENERAL_FAILURE -ETIMEDOUT -#define CS_WRITE_PROTECTED -EPERM -#define CS_BAD_ARG_LENGTH -ENODEV -#define CS_BAD_ARGS -EINVAL -#define CS_CONFIGURATION_LOCKED -EACCES -#define CS_IN_USE -EBUSY -#define CS_NO_MORE_ITEMS -ENOSPC -#define CS_OUT_OF_RESOURCE -ENOMEM -#define CS_BAD_HANDLE -EINVAL - -#define CS_BAD_TUPLE -EINVAL #ifdef __KERNEL__ diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index a06bbec386bd..9ff9de9ec3f0 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -138,6 +138,9 @@ typedef union ds_ioctl_arg_t { #define DS_UNBIND_REQUEST _IOW ('d', 63, bind_info_t) #define DS_BIND_MTD _IOWR('d', 64, mtd_info_t) +/* used in userspace only */ +#define CS_IN_USE 0x1e + #ifdef __KERNEL__ #include #include -- cgit v1.2.3 From 79ba6757277ea7228480bee4c56c0f028f806b91 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 3 Aug 2008 14:03:07 +0200 Subject: pcmcia: use dev_printk for cs_error() Use dev_printk() in cs_error()-based error reporting. While this function-turned-macro will hopefully go away soon, using dev_printk simplifies the code much. Signed-off-by: Dominik Brodowski --- drivers/pcmcia/ds.c | 50 ++++++++++++++++++-------------------------------- include/pcmcia/ds.h | 13 ++++++++++++- 2 files changed, 30 insertions(+), 33 deletions(-) (limited to 'include') diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 55a46af33ca4..e0624a8fb6e3 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -69,8 +69,8 @@ spinlock_t pcmcia_dev_list_lock; /* String tables for error messages */ typedef struct lookup_t { - int key; - char *msg; + const int key; + const char *msg; } lookup_t; static const lookup_t error_table[] = { @@ -137,46 +137,32 @@ static const lookup_t service_table[] = { { ReplaceCIS, "ReplaceCIS" } }; - -static int pcmcia_report_error(struct pcmcia_device *p_dev, error_info_t *err) +const char *pcmcia_error_func(int func) { int i; - char *serv; - - if (!p_dev) - printk(KERN_NOTICE); - else - printk(KERN_NOTICE "%s: ", p_dev->dev.bus_id); for (i = 0; i < ARRAY_SIZE(service_table); i++) - if (service_table[i].key == err->func) - break; - if (i < ARRAY_SIZE(service_table)) - serv = service_table[i].msg; - else - serv = "Unknown service number"; + if (service_table[i].key == func) + return service_table[i].msg; - for (i = 0; i < ARRAY_SIZE(error_table); i++) - if (error_table[i].key == err->retcode) - break; - if (i < ARRAY_SIZE(error_table)) - printk("%s: %s\n", serv, error_table[i].msg); - else - printk("%s: Unknown error code %#x\n", serv, err->retcode); + return "Unknown service number"; +} +EXPORT_SYMBOL(pcmcia_error_func); - return 0; -} /* report_error */ +const char *pcmcia_error_ret(int ret) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(error_table); i++) + if (error_table[i].key == ret) + return error_table[i].msg; -/* end of code which was in cs.c before */ + return "unknown"; +} +EXPORT_SYMBOL(pcmcia_error_ret); /*======================================================================*/ -void cs_error(struct pcmcia_device *p_dev, int func, int ret) -{ - error_info_t err = { func, ret }; - pcmcia_report_error(p_dev, &err); -} -EXPORT_SYMBOL(cs_error); static void pcmcia_check_driver(struct pcmcia_driver *p_drv) diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index 9ff9de9ec3f0..a98bbf42023a 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -249,7 +249,18 @@ struct pcmcia_device { #define handle_to_dev(handle) (handle->dev) /* error reporting */ -void cs_error(struct pcmcia_device *handle, int func, int ret); + +const char *pcmcia_error_func(int func); +const char *pcmcia_error_ret(int ret); + +#define cs_error(p_dev, func, ret) \ + { \ + dev_printk(KERN_NOTICE, &p_dev->dev, \ + "%s : %s\n", \ + pcmcia_error_func(func), \ + pcmcia_error_ret(ret)); \ + } + #endif /* __KERNEL__ */ #endif /* _LINUX_DS_H */ -- cgit v1.2.3 From c23889ca5afcce60bb01739cd831c3cbcbab2a06 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Tue, 26 Aug 2008 00:09:56 +0200 Subject: pcmcia: cleanup socket services header file The header file for use by (in-kernel) PCMCIA sockets deserved a major cleanup. Some stuff only used by the pcmcia core modules was moved to cs_internal.h Signed-off-by: Dominik Brodowski --- drivers/pcmcia/cs_internal.h | 27 ++++++ include/pcmcia/ss.h | 198 ++++++++++++++++++++----------------------- 2 files changed, 118 insertions(+), 107 deletions(-) (limited to 'include') diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 8e43c4d563d1..2df8d8be1ff9 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h @@ -50,6 +50,30 @@ struct cis_cache_entry { unsigned char cache[0]; }; +struct pccard_resource_ops { + int (*validate_mem) (struct pcmcia_socket *s); + int (*adjust_io_region) (struct resource *res, + unsigned long r_start, + unsigned long r_end, + struct pcmcia_socket *s); + struct resource* (*find_io) (unsigned long base, int num, + unsigned long align, + struct pcmcia_socket *s); + struct resource* (*find_mem) (unsigned long base, unsigned long num, + unsigned long align, int low, + struct pcmcia_socket *s); + int (*add_io) (struct pcmcia_socket *s, + unsigned int action, + unsigned long r_start, + unsigned long r_end); + int (*add_mem) (struct pcmcia_socket *s, + unsigned int action, + unsigned long r_start, + unsigned long r_end); + int (*init) (struct pcmcia_socket *s); + void (*exit) (struct pcmcia_socket *s); +}; + /* Flags in config state */ #define CONFIG_LOCKED 0x01 #define CONFIG_IRQ_REQ 0x02 @@ -144,12 +168,15 @@ struct pcmcia_callback{ /* cs.c */ extern struct rw_semaphore pcmcia_socket_list_rwsem; extern struct list_head pcmcia_socket_list; +extern struct class pcmcia_socket_class; + int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, int idx, win_req_t *req); int pccard_reset_card(struct pcmcia_socket *skt); int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c); +struct pcmcia_socket *pcmcia_get_socket_by_nr(unsigned int nr); /* cistpl.c */ int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h index e34bef0fc74f..9b4ac9385f5d 100644 --- a/include/pcmcia/ss.h +++ b/include/pcmcia/ss.h @@ -53,10 +53,10 @@ /* for GetSocket, SetSocket */ typedef struct socket_state_t { - u_int flags; - u_int csc_mask; - u_char Vcc, Vpp; - u_char io_irq; + u_int flags; + u_int csc_mask; + u_char Vcc, Vpp; + u_char io_irq; } socket_state_t; extern socket_state_t dead_socket; @@ -86,79 +86,22 @@ extern socket_state_t dead_socket; #define HOOK_POWER_PRE 0x01 #define HOOK_POWER_POST 0x02 - typedef struct pccard_io_map { - u_char map; - u_char flags; - u_short speed; - u_int start, stop; + u_char map; + u_char flags; + u_short speed; + u_int start, stop; } pccard_io_map; typedef struct pccard_mem_map { - u_char map; - u_char flags; - u_short speed; - u_long static_start; - u_int card_start; - struct resource *res; + u_char map; + u_char flags; + u_short speed; + u_long static_start; + u_int card_start; + struct resource *res; } pccard_mem_map; -typedef struct cb_bridge_map { - u_char map; - u_char flags; - u_int start, stop; -} cb_bridge_map; - -/* - * Socket operations. - */ -struct pcmcia_socket; - -struct pccard_operations { - int (*init)(struct pcmcia_socket *sock); - int (*suspend)(struct pcmcia_socket *sock); - int (*get_status)(struct pcmcia_socket *sock, u_int *value); - int (*set_socket)(struct pcmcia_socket *sock, socket_state_t *state); - int (*set_io_map)(struct pcmcia_socket *sock, struct pccard_io_map *io); - int (*set_mem_map)(struct pcmcia_socket *sock, struct pccard_mem_map *mem); -}; - -struct pccard_resource_ops { - int (*validate_mem) (struct pcmcia_socket *s); - int (*adjust_io_region) (struct resource *res, - unsigned long r_start, - unsigned long r_end, - struct pcmcia_socket *s); - struct resource* (*find_io) (unsigned long base, int num, - unsigned long align, - struct pcmcia_socket *s); - struct resource* (*find_mem) (unsigned long base, unsigned long num, - unsigned long align, int low, - struct pcmcia_socket *s); - int (*add_io) (struct pcmcia_socket *s, - unsigned int action, - unsigned long r_start, - unsigned long r_end); - int (*add_mem) (struct pcmcia_socket *s, - unsigned int action, - unsigned long r_start, - unsigned long r_end); - int (*init) (struct pcmcia_socket *s); - void (*exit) (struct pcmcia_socket *s); -}; -/* SS_CAP_STATIC_MAP */ -extern struct pccard_resource_ops pccard_static_ops; -/* !SS_CAP_STATIC_MAP */ -extern struct pccard_resource_ops pccard_nonstatic_ops; - -/* static mem, dynamic IO sockets */ -extern struct pccard_resource_ops pccard_iodyn_ops; - -/* - * Calls to set up low-level "Socket Services" drivers - */ -struct pcmcia_socket; - typedef struct io_window_t { u_int InUse, Config; struct resource *res; @@ -179,10 +122,25 @@ typedef struct window_t { /* Maximum number of memory windows per socket */ #define MAX_WIN 4 + +/* + * Socket operations. + */ +struct pcmcia_socket; +struct pccard_resource_ops; struct config_t; struct pcmcia_callback; struct user_info_t; +struct pccard_operations { + int (*init)(struct pcmcia_socket *s); + int (*suspend)(struct pcmcia_socket *s); + int (*get_status)(struct pcmcia_socket *s, u_int *value); + int (*set_socket)(struct pcmcia_socket *s, socket_state_t *state); + int (*set_io_map)(struct pcmcia_socket *s, struct pccard_io_map *io); + int (*set_mem_map)(struct pcmcia_socket *s, struct pccard_mem_map *mem); +}; + struct pcmcia_socket { struct module *owner; spinlock_t lock; @@ -218,12 +176,12 @@ struct pcmcia_socket { struct pci_dev * cb_dev; - /* socket setup is done so resources should be able to be allocated. Only - * if set to 1, calls to find_{io,mem}_region are handled, and insertion - * events are actually managed by the PCMCIA layer.*/ + /* socket setup is done so resources should be able to be allocated. + * Only if set to 1, calls to find_{io,mem}_region are handled, and + * insertio events are actually managed by the PCMCIA layer.*/ u8 resource_setup_done:1; - /* is set to one if resource setup is done using adjust_resource_info() */ + /* It's old if resource setup is done using adjust_resource_info() */ u8 resource_setup_old:1; u8 resource_setup_new:1; @@ -236,75 +194,101 @@ struct pcmcia_socket { /* Zoom video behaviour is so chip specific its not worth adding this to _ops */ - void (*zoom_video)(struct pcmcia_socket *, int); + void (*zoom_video)(struct pcmcia_socket *, + int); /* so is power hook */ int (*power_hook)(struct pcmcia_socket *sock, int operation); -#ifdef CONFIG_CARDBUS + /* allows tuning the CB bridge before loading driver for the CB card */ +#ifdef CONFIG_CARDBUS void (*tune_bridge)(struct pcmcia_socket *sock, struct pci_bus *bus); #endif /* state thread */ - struct mutex skt_mutex; /* protects socket h/w state */ - struct task_struct *thread; struct completion thread_done; - spinlock_t thread_lock; /* protects thread_events */ unsigned int thread_events; + /* protects socket h/w state */ + struct mutex skt_mutex; + /* protects thread_events */ + spinlock_t thread_lock; /* pcmcia (16-bit) */ struct pcmcia_callback *callback; #if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) - struct list_head devices_list; /* PCMCIA devices */ - u8 device_count; /* the number of devices, used - * only internally and subject - * to incorrectness and change */ + /* The following elements refer to 16-bit PCMCIA devices inserted + * into the socket */ + struct list_head devices_list; + + /* the number of devices, used only internally and subject to + * incorrectness and change */ + u8 device_count; + /* 16-bit state: */ struct { - u8 present:1, /* PCMCIA card is present in socket */ - busy:1, /* "master" ioctl is used */ - dead:1, /* pcmcia module is being unloaded */ - device_add_pending:1, /* a multifunction-device - * add event is pending */ - mfc_pfc:1, /* the pending event adds a mfc (1) or pfc (0) */ - reserved:3; - } pcmcia_state; - - struct work_struct device_add; /* for adding further pseudo-multifunction - * devices */ + /* PCMCIA card is present in socket */ + u8 present:1; + /* "master" ioctl is used */ + u8 busy:1; + /* pcmcia module is being unloaded */ + u8 dead:1; + /* a multifunction-device add event is pending */ + u8 device_add_pending:1; + /* the pending event adds a mfc (1) or pfc (0) */ + u8 mfc_pfc:1; + + u8 reserved:3; + } pcmcia_state; + + + /* for adding further pseudo-multifunction devices */ + struct work_struct device_add; #ifdef CONFIG_PCMCIA_IOCTL struct user_info_t *user; wait_queue_head_t queue; -#endif -#endif +#endif /* CONFIG_PCMCIA_IOCTL */ +#endif /* CONFIG_PCMCIA */ /* cardbus (32-bit) */ #ifdef CONFIG_CARDBUS struct resource * cb_cis_res; void __iomem *cb_cis_virt; -#endif +#endif /* CONFIG_CARDBUS */ /* socket device */ struct device dev; - void *driver_data; /* data internal to the socket driver */ - + /* data internal to the socket driver */ + void *driver_data; }; -struct pcmcia_socket * pcmcia_get_socket_by_nr(unsigned int nr); +/* socket drivers must define the resource operations type they use. There + * are three options: + * - pccard_static_ops iomem and ioport areas are assigned statically + * - pccard_iodyn_ops iomem areas is assigned statically, ioport + * areas dynamically + * - pccard_nonstatic_ops iomem and ioport areas are assigned dynamically. + * If this option is selected, use + * "select PCCARD_NONSTATIC" in Kconfig. + */ +extern struct pccard_resource_ops pccard_static_ops; +extern struct pccard_resource_ops pccard_iodyn_ops; +extern struct pccard_resource_ops pccard_nonstatic_ops; +/* socket drivers are expected to use these callbacks in their .drv struct */ +extern int pcmcia_socket_dev_suspend(struct device *dev, pm_message_t state); +extern int pcmcia_socket_dev_resume(struct device *dev); + +/* socket drivers use this callback in their IRQ handler */ +extern void pcmcia_parse_events(struct pcmcia_socket *socket, + unsigned int events); -extern void pcmcia_parse_events(struct pcmcia_socket *socket, unsigned int events); +/* to register and unregister a socket */ extern int pcmcia_register_socket(struct pcmcia_socket *socket); extern void pcmcia_unregister_socket(struct pcmcia_socket *socket); -extern struct class pcmcia_socket_class; - -/* socket drivers are expected to use these callbacks in their .drv struct */ -extern int pcmcia_socket_dev_suspend(struct device *dev, pm_message_t state); -extern int pcmcia_socket_dev_resume(struct device *dev); #endif /* _LINUX_SS_H */ -- cgit v1.2.3 From a58357862e71919555ea96cd272e535593a8b3da Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Thu, 28 Aug 2008 00:41:16 +0200 Subject: pcmcia: cleanup device driver header file The header file primarily used for (in-kernel) PCMCIA device drivers also deserved a major cleanup. This header file also serves as the dumping ground for all typedefs and definitions only used by the deprecated PCMCIA ioctl and the deprecated PCMCIA userspace tools using this ioctl. Signed-off-by: Dominik Brodowski --- include/pcmcia/ciscode.h | 2 +- include/pcmcia/cs.h | 37 +----- include/pcmcia/ds.h | 327 +++++++++++++++++++++++++++++------------------ 3 files changed, 202 insertions(+), 164 deletions(-) (limited to 'include') diff --git a/include/pcmcia/ciscode.h b/include/pcmcia/ciscode.h index ad6e278ba7f2..b417985708f2 100644 --- a/include/pcmcia/ciscode.h +++ b/include/pcmcia/ciscode.h @@ -119,7 +119,7 @@ #define MANFID_TOSHIBA 0x0098 -#define MANFID_UNGERMANN 0x02c0 +#define MANFID_UNGERMANN 0x02c0 #define MANFID_XIRCOM 0x0105 diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index 3585e1be4c5c..42c8759f0bdc 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -28,45 +28,10 @@ typedef struct conf_reg_t { #define CS_WRITE 2 /* for AdjustResourceInfo */ -typedef struct adjust_t { - u_int Action; - u_int Resource; - u_int Attributes; - union { - struct memory { - u_long Base; - u_long Size; - } memory; - struct io { - ioaddr_t BasePort; - ioaddr_t NumPorts; - u_int IOAddrLines; - } io; - struct irq { - u_int IRQ; - } irq; - } resource; -} adjust_t; - /* Action field */ #define REMOVE_MANAGED_RESOURCE 1 #define ADD_MANAGED_RESOURCE 2 -#define GET_FIRST_MANAGED_RESOURCE 3 -#define GET_NEXT_MANAGED_RESOURCE 4 -/* Resource field */ -#define RES_MEMORY_RANGE 1 -#define RES_IO_RANGE 2 -#define RES_IRQ 3 -/* Attribute field */ -#define RES_IRQ_TYPE 0x03 -#define RES_IRQ_TYPE_EXCLUSIVE 0 -#define RES_IRQ_TYPE_TIME 1 -#define RES_IRQ_TYPE_DYNAMIC 2 -#define RES_IRQ_CSC 0x04 -#define RES_SHARED 0x08 -#define RES_RESERVED 0x10 -#define RES_ALLOCATED 0x20 -#define RES_REMOVED 0x40 + typedef struct event_callback_args_t { struct pcmcia_device *client_handle; diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index a98bbf42023a..bdf7d5e474f7 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -10,7 +10,7 @@ * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. * * (C) 1999 David A. Hinds - * (C) 2003 - 2004 Dominik Brodowski + * (C) 2003 - 2008 Dominik Brodowski */ #ifndef _LINUX_DS_H @@ -23,138 +23,21 @@ #include #include -typedef struct tuple_parse_t { - tuple_t tuple; - cisdata_t data[255]; - cisparse_t parse; -} tuple_parse_t; - -typedef struct win_info_t { - window_handle_t handle; - win_req_t window; - memreq_t map; -} win_info_t; - -typedef struct bind_info_t { - dev_info_t dev_info; - u_char function; - struct pcmcia_device *instance; - char name[DEV_NAME_LEN]; - u_short major, minor; - void *next; -} bind_info_t; - -typedef struct mtd_info_t { - dev_info_t dev_info; - u_int Attributes; - u_int CardOffset; -} mtd_info_t; - -typedef struct region_info_t { - u_int Attributes; - u_int CardOffset; - u_int RegionSize; - u_int AccessSpeed; - u_int BlockSize; - u_int PartMultiple; - u_char JedecMfr, JedecInfo; - memory_handle_t next; -} region_info_t; -#define REGION_TYPE 0x0001 -#define REGION_TYPE_CM 0x0000 -#define REGION_TYPE_AM 0x0001 -#define REGION_PREFETCH 0x0008 -#define REGION_CACHEABLE 0x0010 -#define REGION_BAR_MASK 0xe000 -#define REGION_BAR_SHIFT 13 - -/* For ReplaceCIS */ -typedef struct cisdump_t { - u_int Length; - cisdata_t Data[CISTPL_MAX_CIS_SIZE]; -} cisdump_t; - -/* for GetConfigurationInfo */ -typedef struct config_info_t { - u_char Function; - u_int Attributes; - u_int Vcc, Vpp1, Vpp2; - u_int IntType; - u_int ConfigBase; - u_char Status, Pin, Copy, Option, ExtStatus; - u_int Present; - u_int CardValues; - u_int AssignedIRQ; - u_int IRQAttributes; - ioaddr_t BasePort1; - ioaddr_t NumPorts1; - u_int Attributes1; - ioaddr_t BasePort2; - ioaddr_t NumPorts2; - u_int Attributes2; - u_int IOAddrLines; -} config_info_t; - -typedef union ds_ioctl_arg_t { - adjust_t adjust; - config_info_t config; - tuple_t tuple; - tuple_parse_t tuple_parse; - client_req_t client_req; - cs_status_t status; - conf_reg_t conf_reg; - cisinfo_t cisinfo; - region_info_t region; - bind_info_t bind_info; - mtd_info_t mtd_info; - win_info_t win_info; - cisdump_t cisdump; -} ds_ioctl_arg_t; - -#define DS_ADJUST_RESOURCE_INFO _IOWR('d', 2, adjust_t) -#define DS_GET_CONFIGURATION_INFO _IOWR('d', 3, config_info_t) -#define DS_GET_FIRST_TUPLE _IOWR('d', 4, tuple_t) -#define DS_GET_NEXT_TUPLE _IOWR('d', 5, tuple_t) -#define DS_GET_TUPLE_DATA _IOWR('d', 6, tuple_parse_t) -#define DS_PARSE_TUPLE _IOWR('d', 7, tuple_parse_t) -#define DS_RESET_CARD _IO ('d', 8) -#define DS_GET_STATUS _IOWR('d', 9, cs_status_t) -#define DS_ACCESS_CONFIGURATION_REGISTER _IOWR('d', 10, conf_reg_t) -#define DS_VALIDATE_CIS _IOR ('d', 11, cisinfo_t) -#define DS_SUSPEND_CARD _IO ('d', 12) -#define DS_RESUME_CARD _IO ('d', 13) -#define DS_EJECT_CARD _IO ('d', 14) -#define DS_INSERT_CARD _IO ('d', 15) -#define DS_GET_FIRST_REGION _IOWR('d', 16, region_info_t) -#define DS_GET_NEXT_REGION _IOWR('d', 17, region_info_t) -#define DS_REPLACE_CIS _IOWR('d', 18, cisdump_t) -#define DS_GET_FIRST_WINDOW _IOR ('d', 19, win_info_t) -#define DS_GET_NEXT_WINDOW _IOWR('d', 20, win_info_t) -#define DS_GET_MEM_PAGE _IOWR('d', 21, win_info_t) - -#define DS_BIND_REQUEST _IOWR('d', 60, bind_info_t) -#define DS_GET_DEVICE_INFO _IOWR('d', 61, bind_info_t) -#define DS_GET_NEXT_DEVICE _IOWR('d', 62, bind_info_t) -#define DS_UNBIND_REQUEST _IOW ('d', 63, bind_info_t) -#define DS_BIND_MTD _IOWR('d', 64, mtd_info_t) - -/* used in userspace only */ -#define CS_IN_USE 0x1e - #ifdef __KERNEL__ #include #include -typedef struct dev_node_t { - char dev_name[DEV_NAME_LEN]; - u_short major, minor; - struct dev_node_t *next; -} dev_node_t; - - +/* + * PCMCIA device drivers (16-bit cards only; 32-bit cards require CardBus + * a.k.a. PCI drivers + */ struct pcmcia_socket; +struct pcmcia_device; struct config_t; +/* dynamic device IDs for PCMCIA device drivers. See + * Documentation/pcmcia/driver.txt for details. +*/ struct pcmcia_dynids { spinlock_t lock; struct list_head list; @@ -177,6 +60,14 @@ struct pcmcia_driver { int pcmcia_register_driver(struct pcmcia_driver *driver); void pcmcia_unregister_driver(struct pcmcia_driver *driver); +/* Some drivers use dev_node_t to store char or block device information. + * Don't use this in new drivers, though. + */ +typedef struct dev_node_t { + char dev_name[DEV_NAME_LEN]; + u_short major, minor; + struct dev_node_t *next; +} dev_node_t; struct pcmcia_device { /* the socket and the device_no [for multifunction devices] @@ -246,9 +137,14 @@ struct pcmcia_device { #define to_pcmcia_dev(n) container_of(n, struct pcmcia_device, dev) #define to_pcmcia_drv(n) container_of(n, struct pcmcia_driver, drv) +/* deprecated -- don't use! */ #define handle_to_dev(handle) (handle->dev) -/* error reporting */ + +/* (deprecated) error reporting by PCMCIA devices. Use dev_printk() + * or dev_dbg() directly in the driver, without referring to pcmcia_error_func() + * and/or pcmcia_error_ret() for those functions will go away soon. + */ const char *pcmcia_error_func(int func); const char *pcmcia_error_ret(int ret); @@ -263,4 +159,181 @@ const char *pcmcia_error_ret(int ret); #endif /* __KERNEL__ */ + + + +/* Below, there are only definitions which are used by + * - the PCMCIA ioctl + * - deprecated PCMCIA userspace tools only + * + * here be dragons ... here be dragons ... here be dragons ... here be drag + */ + +#if defined(CONFIG_PCMCIA_IOCTL) || !defined(__KERNEL__) + +/* for AdjustResourceInfo */ +typedef struct adjust_t { + u_int Action; + u_int Resource; + u_int Attributes; + union { + struct memory { + u_long Base; + u_long Size; + } memory; + struct io { + ioaddr_t BasePort; + ioaddr_t NumPorts; + u_int IOAddrLines; + } io; + struct irq { + u_int IRQ; + } irq; + } resource; +} adjust_t; + +/* Action field */ +#define REMOVE_MANAGED_RESOURCE 1 +#define ADD_MANAGED_RESOURCE 2 +#define GET_FIRST_MANAGED_RESOURCE 3 +#define GET_NEXT_MANAGED_RESOURCE 4 +/* Resource field */ +#define RES_MEMORY_RANGE 1 +#define RES_IO_RANGE 2 +#define RES_IRQ 3 +/* Attribute field */ +#define RES_IRQ_TYPE 0x03 +#define RES_IRQ_TYPE_EXCLUSIVE 0 +#define RES_IRQ_TYPE_TIME 1 +#define RES_IRQ_TYPE_DYNAMIC 2 +#define RES_IRQ_CSC 0x04 +#define RES_SHARED 0x08 +#define RES_RESERVED 0x10 +#define RES_ALLOCATED 0x20 +#define RES_REMOVED 0x40 + + +typedef struct tuple_parse_t { + tuple_t tuple; + cisdata_t data[255]; + cisparse_t parse; +} tuple_parse_t; + +typedef struct win_info_t { + window_handle_t handle; + win_req_t window; + memreq_t map; +} win_info_t; + +typedef struct bind_info_t { + dev_info_t dev_info; + u_char function; + struct pcmcia_device *instance; + char name[DEV_NAME_LEN]; + u_short major, minor; + void *next; +} bind_info_t; + +typedef struct mtd_info_t { + dev_info_t dev_info; + u_int Attributes; + u_int CardOffset; +} mtd_info_t; + +typedef struct region_info_t { + u_int Attributes; + u_int CardOffset; + u_int RegionSize; + u_int AccessSpeed; + u_int BlockSize; + u_int PartMultiple; + u_char JedecMfr, JedecInfo; + memory_handle_t next; +} region_info_t; + +#define REGION_TYPE 0x0001 +#define REGION_TYPE_CM 0x0000 +#define REGION_TYPE_AM 0x0001 +#define REGION_PREFETCH 0x0008 +#define REGION_CACHEABLE 0x0010 +#define REGION_BAR_MASK 0xe000 +#define REGION_BAR_SHIFT 13 + +/* For ReplaceCIS */ +typedef struct cisdump_t { + u_int Length; + cisdata_t Data[CISTPL_MAX_CIS_SIZE]; +} cisdump_t; + +/* for GetConfigurationInfo */ +typedef struct config_info_t { + u_char Function; + u_int Attributes; + u_int Vcc, Vpp1, Vpp2; + u_int IntType; + u_int ConfigBase; + u_char Status, Pin, Copy, Option, ExtStatus; + u_int Present; + u_int CardValues; + u_int AssignedIRQ; + u_int IRQAttributes; + ioaddr_t BasePort1; + ioaddr_t NumPorts1; + u_int Attributes1; + ioaddr_t BasePort2; + ioaddr_t NumPorts2; + u_int Attributes2; + u_int IOAddrLines; +} config_info_t; + +typedef union ds_ioctl_arg_t { + adjust_t adjust; + config_info_t config; + tuple_t tuple; + tuple_parse_t tuple_parse; + client_req_t client_req; + cs_status_t status; + conf_reg_t conf_reg; + cisinfo_t cisinfo; + region_info_t region; + bind_info_t bind_info; + mtd_info_t mtd_info; + win_info_t win_info; + cisdump_t cisdump; +} ds_ioctl_arg_t; + +#define DS_ADJUST_RESOURCE_INFO _IOWR('d', 2, adjust_t) +#define DS_GET_CONFIGURATION_INFO _IOWR('d', 3, config_info_t) +#define DS_GET_FIRST_TUPLE _IOWR('d', 4, tuple_t) +#define DS_GET_NEXT_TUPLE _IOWR('d', 5, tuple_t) +#define DS_GET_TUPLE_DATA _IOWR('d', 6, tuple_parse_t) +#define DS_PARSE_TUPLE _IOWR('d', 7, tuple_parse_t) +#define DS_RESET_CARD _IO ('d', 8) +#define DS_GET_STATUS _IOWR('d', 9, cs_status_t) +#define DS_ACCESS_CONFIGURATION_REGISTER _IOWR('d', 10, conf_reg_t) +#define DS_VALIDATE_CIS _IOR ('d', 11, cisinfo_t) +#define DS_SUSPEND_CARD _IO ('d', 12) +#define DS_RESUME_CARD _IO ('d', 13) +#define DS_EJECT_CARD _IO ('d', 14) +#define DS_INSERT_CARD _IO ('d', 15) +#define DS_GET_FIRST_REGION _IOWR('d', 16, region_info_t) +#define DS_GET_NEXT_REGION _IOWR('d', 17, region_info_t) +#define DS_REPLACE_CIS _IOWR('d', 18, cisdump_t) +#define DS_GET_FIRST_WINDOW _IOR ('d', 19, win_info_t) +#define DS_GET_NEXT_WINDOW _IOWR('d', 20, win_info_t) +#define DS_GET_MEM_PAGE _IOWR('d', 21, win_info_t) + +#define DS_BIND_REQUEST _IOWR('d', 60, bind_info_t) +#define DS_GET_DEVICE_INFO _IOWR('d', 61, bind_info_t) +#define DS_GET_NEXT_DEVICE _IOWR('d', 62, bind_info_t) +#define DS_UNBIND_REQUEST _IOW ('d', 63, bind_info_t) +#define DS_BIND_MTD _IOWR('d', 64, mtd_info_t) + + +/* used in userspace only */ +#define CS_IN_USE 0x1e + + +#endif /* !defined(__KERNEL__) || defined(CONFIG_PCMCIA_IOCTL) */ + #endif /* _LINUX_DS_H */ -- cgit v1.2.3 From d39bd56452b509f8d6054883b8a0129950ba50cc Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Thu, 28 Aug 2008 01:05:34 +0200 Subject: pcmcia: encapsulate ioaddr_t By now, ioaddr_t should only be used by the deprecated ioctl, as it does not correctly reflect the maximum ioport range at least on some architectures. Signed-off-by: Dominik Brodowski --- drivers/pcmcia/au1000_generic.c | 2 +- drivers/pcmcia/au1000_generic.h | 2 +- drivers/usb/host/sl811_cs.c | 3 ++- include/pcmcia/cs_types.h | 8 -------- include/pcmcia/ds.h | 8 ++++++++ 5 files changed, 12 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c index 75e8f8505e47..fc1de46fd20a 100644 --- a/drivers/pcmcia/au1000_generic.c +++ b/drivers/pcmcia/au1000_generic.c @@ -292,7 +292,7 @@ au1x00_pcmcia_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *map) skt->spd_io[map->map] = speed; } - map->start=(ioaddr_t)(u32)skt->virt_io; + map->start=(unsigned int)(u32)skt->virt_io; map->stop=map->start+MAP_SIZE; return 0; diff --git a/drivers/pcmcia/au1000_generic.h b/drivers/pcmcia/au1000_generic.h index a53ef5902518..13a4fbc58711 100644 --- a/drivers/pcmcia/au1000_generic.h +++ b/drivers/pcmcia/au1000_generic.h @@ -116,7 +116,7 @@ struct au1000_pcmcia_socket { struct resource res_attr; void * virt_io; - ioaddr_t phys_io; + unsigned int phys_io; unsigned int phys_attr; unsigned int phys_mem; unsigned short speed_io, speed_attr, speed_mem; diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c index ca733b7caea4..516848dd9b48 100644 --- a/drivers/usb/host/sl811_cs.c +++ b/drivers/usb/host/sl811_cs.c @@ -112,7 +112,8 @@ static struct platform_device platform_dev = { .num_resources = ARRAY_SIZE(resources), }; -static int sl811_hc_init(struct device *parent, ioaddr_t base_addr, int irq) +static int sl811_hc_init(struct device *parent, resource_size_t base_addr, + int irq) { if (platform_dev.dev.parent) return -EBUSY; diff --git a/include/pcmcia/cs_types.h b/include/pcmcia/cs_types.h index f402a0f435b4..315965a37930 100644 --- a/include/pcmcia/cs_types.h +++ b/include/pcmcia/cs_types.h @@ -21,14 +21,6 @@ #include #endif -#if defined(__arm__) || defined(__mips__) || defined(__avr32__) || \ - defined(__bfin__) -/* This (ioaddr_t) is exposed to userspace & hence cannot be changed. */ -typedef u_int ioaddr_t; -#else -typedef u_short ioaddr_t; -#endif - typedef u_short socket_t; typedef u_int event_t; typedef u_char cisdata_t; diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index bdf7d5e474f7..279df0fb036e 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -171,6 +171,14 @@ const char *pcmcia_error_ret(int ret); #if defined(CONFIG_PCMCIA_IOCTL) || !defined(__KERNEL__) +#if defined(__arm__) || defined(__mips__) || defined(__avr32__) || \ + defined(__bfin__) +/* This (ioaddr_t) is exposed to userspace & hence cannot be changed. */ +typedef u_int ioaddr_t; +#else +typedef u_short ioaddr_t; +#endif + /* for AdjustResourceInfo */ typedef struct adjust_t { u_int Action; -- cgit v1.2.3 From 35200d865d49d0207b054074055e1487a0c28ae4 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Thu, 28 Aug 2008 23:44:45 +0200 Subject: pcmcia: device_id header cleanup Wrap in #ifdef to include header just once, and wrap in another #ifdef to avoid it being used in userspace. Also, format the header similar to the other PCMCIA header files. Signed-off-by: Dominik Brodowski --- include/pcmcia/device_id.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/pcmcia/device_id.h b/include/pcmcia/device_id.h index e04e0b0d9a25..c33ea08352b8 100644 --- a/include/pcmcia/device_id.h +++ b/include/pcmcia/device_id.h @@ -1,10 +1,19 @@ /* - * Copyright (2003-2004) Dominik Brodowski - * David Woodhouse + * device_id.h -- PCMCIA driver matching helpers * - * License: GPL v2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * (C) 2003 - 2004 David Woodhouse + * (C) 2003 - 2004 Dominik Brodowski */ +#ifndef _LINUX_PCMCIA_DEVICE_ID_H +#define _LINUX_PCMCIA_DEVICE_ID_H + +#ifdef __KERNEL__ + #define PCMCIA_DEVICE_MANF_CARD(manf, card) { \ .match_flags = PCMCIA_DEV_ID_MATCH_MANF_ID| \ PCMCIA_DEV_ID_MATCH_CARD_ID, \ @@ -256,3 +265,6 @@ #define PCMCIA_DEVICE_NULL { .match_flags = 0, } + +#endif /* __KERNEL__ */ +#endif /* _LINUX_PCMCIA_DEVICE_ID_H */ -- cgit v1.2.3 From 994917f8b718f1cd7114317cc3cbf04fe46c1841 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 31 Aug 2008 15:20:26 +0200 Subject: pcmcia: card services header cleanup 16-bit PCMCIA device handling function definitions are moved to ds.h, internal definitions to cs_internal.h. Signed-off-by: Dominik Brodowski --- drivers/char/pcmcia/ipwireless/main.c | 2 +- drivers/net/pcmcia/nmclan_cs.c | 2 +- drivers/net/wireless/orinoco_cs.c | 2 +- drivers/pcmcia/cs.c | 4 +-- drivers/pcmcia/cs_internal.h | 12 ++++++- drivers/pcmcia/pcmcia_ioctl.c | 2 +- include/pcmcia/cistpl.h | 6 ++-- include/pcmcia/cs.h | 67 ----------------------------------- include/pcmcia/ds.h | 56 ++++++++++++++++++++++++++++- 9 files changed, 76 insertions(+), 77 deletions(-) (limited to 'include') diff --git a/drivers/char/pcmcia/ipwireless/main.c b/drivers/char/pcmcia/ipwireless/main.c index 24ffe0324e53..dcf2b59ca8c5 100644 --- a/drivers/char/pcmcia/ipwireless/main.c +++ b/drivers/char/pcmcia/ipwireless/main.c @@ -65,7 +65,7 @@ static void signalled_reboot_work(struct work_struct *work_reboot) struct ipw_dev *ipw = container_of(work_reboot, struct ipw_dev, work_reboot); struct pcmcia_device *link = ipw->link; - int ret = pccard_reset_card(link->socket); + int ret = pcmcia_reset_card(link->socket); if (ret != 0) cs_error(link, ResetCard, ret); diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c index cfcbea9b7e2e..54df34f21c5f 100644 --- a/drivers/net/pcmcia/nmclan_cs.c +++ b/drivers/net/pcmcia/nmclan_cs.c @@ -925,7 +925,7 @@ static void mace_tx_timeout(struct net_device *dev) printk(KERN_NOTICE "%s: transmit timed out -- ", dev->name); #if RESET_ON_TIMEOUT printk("resetting card\n"); - pcmcia_reset_card(link, NULL); + pcmcia_reset_card(link->socket); #else /* #if RESET_ON_TIMEOUT */ printk("NOT resetting card\n"); #endif /* #if RESET_ON_TIMEOUT */ diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c index c7b57d9d499d..f8d9de2fb4cf 100644 --- a/drivers/net/wireless/orinoco_cs.c +++ b/drivers/net/wireless/orinoco_cs.c @@ -80,7 +80,7 @@ orinoco_cs_hard_reset(struct orinoco_private *priv) /* We need atomic ops here, because we're not holding the lock */ set_bit(0, &card->hard_reset_in_progress); - err = pcmcia_reset_card(link, NULL); + err = pcmcia_reset_card(link->socket); if (err) return err; diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index 48386f31e610..c68c5d338285 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -752,7 +752,7 @@ EXPORT_SYMBOL(pccard_register_pcmcia); * CIS register. */ -int pccard_reset_card(struct pcmcia_socket *skt) +int pcmcia_reset_card(struct pcmcia_socket *skt) { int ret; @@ -791,7 +791,7 @@ int pccard_reset_card(struct pcmcia_socket *skt) return ret; } /* reset_card */ -EXPORT_SYMBOL(pccard_reset_card); +EXPORT_SYMBOL(pcmcia_reset_card); /* These shut down or wake up a socket. They are sort of user diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 2df8d8be1ff9..d71eeee4992b 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h @@ -174,10 +174,18 @@ int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, int idx, win_req_t *req); -int pccard_reset_card(struct pcmcia_socket *skt); int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c); struct pcmcia_socket *pcmcia_get_socket_by_nr(unsigned int nr); +int pcmcia_suspend_card(struct pcmcia_socket *skt); +int pcmcia_resume_card(struct pcmcia_socket *skt); + +int pcmcia_eject_card(struct pcmcia_socket *skt); +int pcmcia_insert_card(struct pcmcia_socket *skt); + +struct pcmcia_socket *pcmcia_get_socket(struct pcmcia_socket *skt); +void pcmcia_put_socket(struct pcmcia_socket *skt); + /* cistpl.c */ int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, u_int len, void *ptr); @@ -187,6 +195,8 @@ void release_cis_mem(struct pcmcia_socket *s); void destroy_cis_cache(struct pcmcia_socket *s); int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t code, void *parse); +int pcmcia_replace_cis(struct pcmcia_socket *s, + const u8 *data, const size_t len); /* rsrc_mgr.c */ int pcmcia_validate_mem(struct pcmcia_socket *s); diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index c400872f5d3b..579ec9455706 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c @@ -861,7 +861,7 @@ static int ds_ioctl(struct inode * inode, struct file * file, ret = pccard_parse_tuple(&buf->tuple, &buf->tuple_parse.parse); break; case DS_RESET_CARD: - ret = pccard_reset_card(s); + ret = pcmcia_reset_card(s); break; case DS_GET_STATUS: if (buf->status.Function && diff --git a/include/pcmcia/cistpl.h b/include/pcmcia/cistpl.h index 75a9d34c6346..7e8c2bcf11a7 100644 --- a/include/pcmcia/cistpl.h +++ b/include/pcmcia/cistpl.h @@ -580,8 +580,8 @@ typedef struct cisinfo_t { #define CISTPL_MAX_CIS_SIZE 0x200 -int pcmcia_replace_cis(struct pcmcia_socket *s, - const u8 *data, const size_t len); +#ifdef __KERNEL__ +struct pcmcia_socket; /* don't use outside of PCMCIA core yet */ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int func, tuple_t *tuple); @@ -615,4 +615,6 @@ int pcmcia_loop_config(struct pcmcia_device *p_dev, void *priv_data), void *priv_data); +#endif /* __KERNEL__ */ + #endif /* LINUX_CISTPL_H */ diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index 42c8759f0bdc..6944a74d3a7c 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -201,16 +201,6 @@ typedef struct win_req_t { #define WIN_BAR_MASK 0xe000 #define WIN_BAR_SHIFT 13 -/* Attributes for RegisterClient -- UNUSED -- */ -#define INFO_MASTER_CLIENT 0x01 -#define INFO_IO_CLIENT 0x02 -#define INFO_MTD_CLIENT 0x04 -#define INFO_MEM_CLIENT 0x08 -#define MAX_NUM_CLIENTS 3 - -#define INFO_CARD_SHARE 0x10 -#define INFO_CARD_EXCL 0x20 - typedef struct cs_status_t { u_char Function; event_t CardState; @@ -252,61 +242,4 @@ typedef struct error_info_t { #define CS_EVENT_3VCARD 0x200000 #define CS_EVENT_XVCARD 0x400000 - -#ifdef __KERNEL__ - -/* - * The main Card Services entry point - */ - -enum service { - AccessConfigurationRegister, AddSocketServices, - AdjustResourceInfo, CheckEraseQueue, CloseMemory, CopyMemory, - DeregisterClient, DeregisterEraseQueue, GetCardServicesInfo, - GetClientInfo, GetConfigurationInfo, GetEventMask, - GetFirstClient, GetFirstPartion, GetFirstRegion, GetFirstTuple, - GetNextClient, GetNextPartition, GetNextRegion, GetNextTuple, - GetStatus, GetTupleData, MapLogSocket, MapLogWindow, MapMemPage, - MapPhySocket, MapPhyWindow, ModifyConfiguration, ModifyWindow, - OpenMemory, ParseTuple, ReadMemory, RegisterClient, - RegisterEraseQueue, RegisterMTD, RegisterTimer, - ReleaseConfiguration, ReleaseExclusive, ReleaseIO, ReleaseIRQ, - ReleaseSocketMask, ReleaseWindow, ReplaceSocketServices, - RequestConfiguration, RequestExclusive, RequestIO, RequestIRQ, - RequestSocketMask, RequestWindow, ResetCard, ReturnSSEntry, - SetEventMask, SetRegion, ValidateCIS, VendorSpecific, - WriteMemory, BindDevice, BindMTD, ReportError, - SuspendCard, ResumeCard, EjectCard, InsertCard, ReplaceCIS, - GetFirstWindow, GetNextWindow, GetMemPage -}; - -struct pcmcia_socket; - -int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, conf_reg_t *reg); -int pcmcia_get_mem_page(window_handle_t win, memreq_t *req); -int pcmcia_map_mem_page(window_handle_t win, memreq_t *req); -int pcmcia_modify_configuration(struct pcmcia_device *p_dev, modconf_t *mod); -int pcmcia_release_window(window_handle_t win); -int pcmcia_request_configuration(struct pcmcia_device *p_dev, config_req_t *req); -int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req); -int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req); -int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_handle_t *wh); -int pcmcia_suspend_card(struct pcmcia_socket *skt); -int pcmcia_resume_card(struct pcmcia_socket *skt); -int pcmcia_eject_card(struct pcmcia_socket *skt); -int pcmcia_insert_card(struct pcmcia_socket *skt); -int pccard_reset_card(struct pcmcia_socket *skt); - -struct pcmcia_device * pcmcia_dev_present(struct pcmcia_device *p_dev); -void pcmcia_disable_device(struct pcmcia_device *p_dev); - -struct pcmcia_socket * pcmcia_get_socket(struct pcmcia_socket *skt); -void pcmcia_put_socket(struct pcmcia_socket *skt); - -/* compatibility functions */ -#define pcmcia_reset_card(p_dev, req) \ - pccard_reset_card(p_dev->socket) - -#endif /* __KERNEL__ */ - #endif /* _LINUX_CS_H */ diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index 279df0fb036e..29e403230899 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -145,7 +145,26 @@ struct pcmcia_device { * or dev_dbg() directly in the driver, without referring to pcmcia_error_func() * and/or pcmcia_error_ret() for those functions will go away soon. */ - +enum service { + AccessConfigurationRegister, AddSocketServices, + AdjustResourceInfo, CheckEraseQueue, CloseMemory, CopyMemory, + DeregisterClient, DeregisterEraseQueue, GetCardServicesInfo, + GetClientInfo, GetConfigurationInfo, GetEventMask, + GetFirstClient, GetFirstPartion, GetFirstRegion, GetFirstTuple, + GetNextClient, GetNextPartition, GetNextRegion, GetNextTuple, + GetStatus, GetTupleData, MapLogSocket, MapLogWindow, MapMemPage, + MapPhySocket, MapPhyWindow, ModifyConfiguration, ModifyWindow, + OpenMemory, ParseTuple, ReadMemory, RegisterClient, + RegisterEraseQueue, RegisterMTD, RegisterTimer, + ReleaseConfiguration, ReleaseExclusive, ReleaseIO, ReleaseIRQ, + ReleaseSocketMask, ReleaseWindow, ReplaceSocketServices, + RequestConfiguration, RequestExclusive, RequestIO, RequestIRQ, + RequestSocketMask, RequestWindow, ResetCard, ReturnSSEntry, + SetEventMask, SetRegion, ValidateCIS, VendorSpecific, + WriteMemory, BindDevice, BindMTD, ReportError, + SuspendCard, ResumeCard, EjectCard, InsertCard, ReplaceCIS, + GetFirstWindow, GetNextWindow, GetMemPage +}; const char *pcmcia_error_func(int func); const char *pcmcia_error_ret(int ret); @@ -158,6 +177,32 @@ const char *pcmcia_error_ret(int ret); } +/* is the device still there? */ +struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *p_dev); + +/* low-level interface reset */ +int pcmcia_reset_card(struct pcmcia_socket *skt); + +/* CIS config */ +int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, + conf_reg_t *reg); + +/* device configuration */ +int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req); +int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req); +int pcmcia_request_configuration(struct pcmcia_device *p_dev, + config_req_t *req); + +int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, + window_handle_t *wh); +int pcmcia_release_window(window_handle_t win); + +int pcmcia_get_mem_page(window_handle_t win, memreq_t *req); +int pcmcia_map_mem_page(window_handle_t win, memreq_t *req); + +int pcmcia_modify_configuration(struct pcmcia_device *p_dev, modconf_t *mod); +void pcmcia_disable_device(struct pcmcia_device *p_dev); + #endif /* __KERNEL__ */ @@ -341,6 +386,15 @@ typedef union ds_ioctl_arg_t { /* used in userspace only */ #define CS_IN_USE 0x1e +#define INFO_MASTER_CLIENT 0x01 +#define INFO_IO_CLIENT 0x02 +#define INFO_MTD_CLIENT 0x04 +#define INFO_MEM_CLIENT 0x08 +#define MAX_NUM_CLIENTS 3 + +#define INFO_CARD_SHARE 0x10 +#define INFO_CARD_EXCL 0x20 + #endif /* !defined(__KERNEL__) || defined(CONFIG_PCMCIA_IOCTL) */ -- cgit v1.2.3 From 2f3061eb1086f98990d6495b8c63a1b83f2f59aa Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 31 Aug 2008 15:50:33 +0200 Subject: pcmcia: remove unused argument to pcmcia_parse_tuple() Since we're just parsing the tuple being passed to this function, we don't need any device-specific information. Also, remove the call to pcmcia_validate_cis() from pcmciamtd.c, since it is already called by the PCMCIA core. Signed-off-by: Dominik Brodowski --- drivers/char/pcmcia/ipwireless/main.c | 6 +++--- drivers/char/pcmcia/synclink_cs.c | 2 +- drivers/mtd/maps/pcmciamtd.c | 7 +------ drivers/net/pcmcia/fmvj18x_cs.c | 2 +- drivers/net/pcmcia/smc91c92_cs.c | 4 ++-- drivers/net/pcmcia/xirc2ps_cs.c | 4 ++-- drivers/net/wireless/b43/pcmcia.c | 2 +- drivers/net/wireless/hostap/hostap_cs.c | 2 +- drivers/net/wireless/libertas/if_cs.c | 2 +- drivers/pcmcia/cistpl.c | 6 +++--- drivers/pcmcia/cs_internal.h | 2 ++ drivers/pcmcia/pcmcia_ioctl.c | 2 +- drivers/pcmcia/pcmcia_resource.c | 2 +- drivers/serial/serial_cs.c | 2 +- include/pcmcia/cistpl.h | 11 ++--------- 15 files changed, 23 insertions(+), 33 deletions(-) (limited to 'include') diff --git a/drivers/char/pcmcia/ipwireless/main.c b/drivers/char/pcmcia/ipwireless/main.c index dcf2b59ca8c5..5216fce0c62d 100644 --- a/drivers/char/pcmcia/ipwireless/main.c +++ b/drivers/char/pcmcia/ipwireless/main.c @@ -127,7 +127,7 @@ static int config_ipwireless(struct ipw_dev *ipw) goto exit0; } - ret = pcmcia_parse_tuple(link, &tuple, &parse); + ret = pcmcia_parse_tuple(&tuple, &parse); if (ret != 0) { cs_error(link, ParseTuple, ret); @@ -163,7 +163,7 @@ static int config_ipwireless(struct ipw_dev *ipw) goto exit0; } - ret = pcmcia_parse_tuple(link, &tuple, &parse); + ret = pcmcia_parse_tuple(&tuple, &parse); if (ret != 0) { cs_error(link, GetTupleData, ret); @@ -206,7 +206,7 @@ static int config_ipwireless(struct ipw_dev *ipw) goto exit1; } - ret = pcmcia_parse_tuple(link, &tuple, &parse); + ret = pcmcia_parse_tuple(&tuple, &parse); if (ret != 0) { cs_error(link, ParseTuple, ret); diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index d1fceabe3aef..05bf9c55ecc2 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -604,7 +604,7 @@ static int mgslpc_config(struct pcmcia_device *link) cfg = &(parse.cftable_entry); CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); - CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); + CS_CHECK(ParseTuple, pcmcia_parse_tuple(&tuple, &parse)); if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; if (cfg->index == 0) diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c index 27b3d96b7124..d600c2deff73 100644 --- a/drivers/mtd/maps/pcmciamtd.c +++ b/drivers/mtd/maps/pcmciamtd.c @@ -374,7 +374,7 @@ static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *link, cs_error(link, GetTupleData, rc); break; } - rc = pcmcia_parse_tuple(link, &tuple, &parse); + rc = pcmcia_parse_tuple(&tuple, &parse); if (rc != 0) { cs_error(link, ParseTuple, rc); break; @@ -498,11 +498,6 @@ static int pcmciamtd_config(struct pcmcia_device *link) DEBUG(3, "link=0x%p", link); - DEBUG(2, "Validating CIS"); - ret = pcmcia_validate_cis(link, NULL); - if (ret != 0) - cs_error(link, GetTupleData, ret); - card_settings(dev, link, &new_name); dev->pcmcia_map.phys = NO_XIP; diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c index 0ffd981502e1..69d916daa7bb 100644 --- a/drivers/net/pcmcia/fmvj18x_cs.c +++ b/drivers/net/pcmcia/fmvj18x_cs.c @@ -362,7 +362,7 @@ static int fmvj18x_config(struct pcmcia_device *link) tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); - CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); + CS_CHECK(ParseTuple, pcmcia_parse_tuple(&tuple, &parse)); link->conf.ConfigIndex = parse.cftable_entry.index; switch (link->manf_id) { case MANFID_TDK: diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index 918b4a3eca57..c74d6656d266 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c @@ -415,7 +415,7 @@ static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, i = pcmcia_get_tuple_data(handle, tuple); if (i != 0) return i; - return pcmcia_parse_tuple(handle, tuple, parse); + return pcmcia_parse_tuple(tuple, parse); } static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, @@ -426,7 +426,7 @@ static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, if ((i = pcmcia_get_next_tuple(handle, tuple)) != 0 || (i = pcmcia_get_tuple_data(handle, tuple)) != 0) return i; - return pcmcia_parse_tuple(handle, tuple, parse); + return pcmcia_parse_tuple(tuple, parse); } /*====================================================================== diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c index d97e6e917c3c..8366bfc7d28c 100644 --- a/drivers/net/pcmcia/xirc2ps_cs.c +++ b/drivers/net/pcmcia/xirc2ps_cs.c @@ -377,7 +377,7 @@ first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) if ((err = pcmcia_get_first_tuple(handle, tuple)) == 0 && (err = pcmcia_get_tuple_data(handle, tuple)) == 0) - err = pcmcia_parse_tuple(handle, tuple, parse); + err = pcmcia_parse_tuple(tuple, parse); return err; } @@ -388,7 +388,7 @@ next_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) if ((err = pcmcia_get_next_tuple(handle, tuple)) == 0 && (err = pcmcia_get_tuple_data(handle, tuple)) == 0) - err = pcmcia_parse_tuple(handle, tuple, parse); + err = pcmcia_parse_tuple(tuple, parse); return err; } diff --git a/drivers/net/wireless/b43/pcmcia.c b/drivers/net/wireless/b43/pcmcia.c index ab42fb6addf6..3cfc30307a27 100644 --- a/drivers/net/wireless/b43/pcmcia.c +++ b/drivers/net/wireless/b43/pcmcia.c @@ -87,7 +87,7 @@ static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev) res = pcmcia_get_tuple_data(dev, &tuple); if (res != 0) goto err_kfree_ssb; - res = pcmcia_parse_tuple(dev, &tuple, &parse); + res = pcmcia_parse_tuple(&tuple, &parse); if (res != 0) goto err_kfree_ssb; diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c index 2826e674a8e7..633740277352 100644 --- a/drivers/net/wireless/hostap/hostap_cs.c +++ b/drivers/net/wireless/hostap/hostap_cs.c @@ -305,7 +305,7 @@ static int sandisk_enable_wireless(struct net_device *dev) tuple.DesiredTuple = CISTPL_LONGLINK_MFC; if (pcmcia_get_first_tuple(hw_priv->link, &tuple) || pcmcia_get_tuple_data(hw_priv->link, &tuple) || - pcmcia_parse_tuple(hw_priv->link, &tuple, parse) || + pcmcia_parse_tuple(&tuple, parse) || parse->longlink_mfc.nfn < 2) { /* No multi-function links found */ ret = -ENODEV; diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c index 04d7a251e3f0..e2fe2d677324 100644 --- a/drivers/net/wireless/libertas/if_cs.c +++ b/drivers/net/wireless/libertas/if_cs.c @@ -798,7 +798,7 @@ static int if_cs_probe(struct pcmcia_device *p_dev) tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; if ((ret = pcmcia_get_first_tuple(p_dev, &tuple)) != 0 || (ret = pcmcia_get_tuple_data(p_dev, &tuple)) != 0 || - (ret = pcmcia_parse_tuple(p_dev, &tuple, &parse)) != 0) + (ret = pcmcia_parse_tuple(&tuple, &parse)) != 0) { lbs_pr_err("error in pcmcia_get_first_tuple etc\n"); goto out1; diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index 772fc96d5ec3..dcce9f5d8465 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c @@ -1359,7 +1359,7 @@ static int parse_format(tuple_t *tuple, cistpl_format_t *fmt) /*====================================================================*/ -int pccard_parse_tuple(tuple_t *tuple, cisparse_t *parse) +int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse) { int ret = 0; @@ -1442,7 +1442,7 @@ int pccard_parse_tuple(tuple_t *tuple, cisparse_t *parse) __cs_dbg(0, "parse_tuple failed %d\n", ret); return ret; } -EXPORT_SYMBOL(pccard_parse_tuple); +EXPORT_SYMBOL(pcmcia_parse_tuple); /*====================================================================== @@ -1472,7 +1472,7 @@ int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t ret = pccard_get_tuple_data(s, &tuple); if (ret != 0) goto done; - ret = pccard_parse_tuple(&tuple, parse); + ret = pcmcia_parse_tuple(&tuple, parse); done: kfree(buf); return ret; diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index d71eeee4992b..79615e6d540b 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h @@ -197,6 +197,8 @@ int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t code, void *parse); int pcmcia_replace_cis(struct pcmcia_socket *s, const u8 *data, const size_t len); +int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, + unsigned int *count); /* rsrc_mgr.c */ int pcmcia_validate_mem(struct pcmcia_socket *s); diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index 579ec9455706..1703b20cad5d 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c @@ -858,7 +858,7 @@ static int ds_ioctl(struct inode * inode, struct file * file, break; case DS_PARSE_TUPLE: buf->tuple.TupleData = buf->tuple_parse.data; - ret = pccard_parse_tuple(&buf->tuple, &buf->tuple_parse.parse); + ret = pcmcia_parse_tuple(&buf->tuple, &buf->tuple_parse.parse); break; case DS_RESET_CARD: ret = pcmcia_reset_card(s); diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 93a270e15cea..afea2b2558b5 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -937,7 +937,7 @@ int pcmcia_loop_config(struct pcmcia_device *p_dev, if (pcmcia_get_tuple_data(p_dev, tuple)) goto next_entry; - if (pcmcia_parse_tuple(p_dev, tuple, &cfg_mem->parse)) + if (pcmcia_parse_tuple(tuple, &cfg_mem->parse)) goto next_entry; /* default values */ diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c index dbb3bf3065fa..7546aa887fa7 100644 --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c @@ -436,7 +436,7 @@ first_tuple(struct pcmcia_device *handle, tuple_t * tuple, cisparse_t * parse) i = pcmcia_get_tuple_data(handle, tuple); if (i != 0) return i; - return pcmcia_parse_tuple(handle, tuple, parse); + return pcmcia_parse_tuple(tuple, parse); } /*====================================================================*/ diff --git a/include/pcmcia/cistpl.h b/include/pcmcia/cistpl.h index 7e8c2bcf11a7..353abe74be74 100644 --- a/include/pcmcia/cistpl.h +++ b/include/pcmcia/cistpl.h @@ -583,13 +583,12 @@ typedef struct cisinfo_t { #ifdef __KERNEL__ struct pcmcia_socket; +int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse); + /* don't use outside of PCMCIA core yet */ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int func, tuple_t *tuple); int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, tuple_t *tuple); int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple); -int pccard_parse_tuple(tuple_t *tuple, cisparse_t *parse); - -int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned int *count); /* ... but use these wrappers instead */ #define pcmcia_get_first_tuple(p_dev, tuple) \ @@ -601,12 +600,6 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned #define pcmcia_get_tuple_data(p_dev, tuple) \ pccard_get_tuple_data(p_dev->socket, tuple) -#define pcmcia_parse_tuple(p_dev, tuple, parse) \ - pccard_parse_tuple(tuple, parse) - -#define pcmcia_validate_cis(p_dev, info) \ - pccard_validate_cis(p_dev->socket, p_dev->func, info) - int pcmcia_loop_config(struct pcmcia_device *p_dev, int (*conf_check) (struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cf, -- cgit v1.2.3 From 272433e088f843dc4dd5a5ad38dd68b9a93dcebf Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 31 Aug 2008 15:55:58 +0200 Subject: pcmcia: cistpl header cleanup 16-bit PCMCIA device handling function definitions are moved to ds.h. Signed-off-by: Dominik Brodowski --- include/pcmcia/cistpl.h | 30 ------------------------------ include/pcmcia/ds.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 30 deletions(-) (limited to 'include') diff --git a/include/pcmcia/cistpl.h b/include/pcmcia/cistpl.h index 353abe74be74..026323bc47af 100644 --- a/include/pcmcia/cistpl.h +++ b/include/pcmcia/cistpl.h @@ -580,34 +580,4 @@ typedef struct cisinfo_t { #define CISTPL_MAX_CIS_SIZE 0x200 -#ifdef __KERNEL__ -struct pcmcia_socket; - -int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse); - -/* don't use outside of PCMCIA core yet */ -int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int func, tuple_t *tuple); -int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, tuple_t *tuple); -int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple); - -/* ... but use these wrappers instead */ -#define pcmcia_get_first_tuple(p_dev, tuple) \ - pccard_get_first_tuple(p_dev->socket, p_dev->func, tuple) - -#define pcmcia_get_next_tuple(p_dev, tuple) \ - pccard_get_next_tuple(p_dev->socket, p_dev->func, tuple) - -#define pcmcia_get_tuple_data(p_dev, tuple) \ - pccard_get_tuple_data(p_dev->socket, tuple) - -int pcmcia_loop_config(struct pcmcia_device *p_dev, - int (*conf_check) (struct pcmcia_device *p_dev, - cistpl_cftable_entry_t *cf, - cistpl_cftable_entry_t *dflt, - unsigned int vcc, - void *priv_data), - void *priv_data); - -#endif /* __KERNEL__ */ - #endif /* LINUX_CISTPL_H */ diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index 29e403230899..5fb61952bce8 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -176,6 +176,34 @@ const char *pcmcia_error_ret(int ret); pcmcia_error_ret(ret)); \ } +/* CIS access. + * Use the pcmcia_* versions in PCMCIA drivers + */ +int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse); + +int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, + tuple_t *tuple); +#define pcmcia_get_first_tuple(p_dev, tuple) \ + pccard_get_first_tuple(p_dev->socket, p_dev->func, tuple) + +int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, + tuple_t *tuple); +#define pcmcia_get_next_tuple(p_dev, tuple) \ + pccard_get_next_tuple(p_dev->socket, p_dev->func, tuple) + +int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple); +#define pcmcia_get_tuple_data(p_dev, tuple) \ + pccard_get_tuple_data(p_dev->socket, tuple) + + +/* loop CIS entries for valid configuration */ +int pcmcia_loop_config(struct pcmcia_device *p_dev, + int (*conf_check) (struct pcmcia_device *p_dev, + cistpl_cftable_entry_t *cf, + cistpl_cftable_entry_t *dflt, + unsigned int vcc, + void *priv_data), + void *priv_data); /* is the device still there? */ struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *p_dev); -- cgit v1.2.3 From a45b3fb19ba1e4dfc3fc53563a072612092930a9 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 31 Aug 2008 16:00:42 +0200 Subject: pcmcia: ioctl-internal definitions cisinfo_t and cs_status_t are only used by the (deprecated) PCMCIA ioctl. Therefore, move them out of the way. Signed-off-by: Dominik Brodowski --- include/pcmcia/cistpl.h | 5 ----- include/pcmcia/cs.h | 6 ------ include/pcmcia/ds.h | 11 +++++++++++ 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/pcmcia/cistpl.h b/include/pcmcia/cistpl.h index 026323bc47af..cfdd5af77dcc 100644 --- a/include/pcmcia/cistpl.h +++ b/include/pcmcia/cistpl.h @@ -573,11 +573,6 @@ typedef struct tuple_t { #define TUPLE_RETURN_LINK 0x01 #define TUPLE_RETURN_COMMON 0x02 -/* For ValidateCIS */ -typedef struct cisinfo_t { - u_int Chains; -} cisinfo_t; - #define CISTPL_MAX_CIS_SIZE 0x200 #endif /* LINUX_CISTPL_H */ diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index 6944a74d3a7c..904468a191ef 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -201,12 +201,6 @@ typedef struct win_req_t { #define WIN_BAR_MASK 0xe000 #define WIN_BAR_SHIFT 13 -typedef struct cs_status_t { - u_char Function; - event_t CardState; - event_t SocketState; -} cs_status_t; - typedef struct error_info_t { int func; int retcode; diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index 5fb61952bce8..a2be80b9a095 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -367,6 +367,17 @@ typedef struct config_info_t { u_int IOAddrLines; } config_info_t; +/* For ValidateCIS */ +typedef struct cisinfo_t { + u_int Chains; +} cisinfo_t; + +typedef struct cs_status_t { + u_char Function; + event_t CardState; + event_t SocketState; +} cs_status_t; + typedef union ds_ioctl_arg_t { adjust_t adjust; config_info_t config; -- cgit v1.2.3