From 84e2d34004dcd0c90d1af43a143511b334f11a4d Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Tue, 29 Jul 2008 08:38:55 +0200 Subject: pcmcia: use pcmcia_loop_config in misc pcmcia drivers Use the config loop helper in misc pcmcia drivers. CC: Harald Welte CC: CC: Russell King CC: Ed Okerson CC: linux-serial@vger.kernel.org CC: boti@rocketmail.com CC: linux-usb@vger.kernel.org Signed-off-by: Dominik Brodowski --- drivers/telephony/ixj_pcmcia.c | 76 +++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 42 deletions(-) (limited to 'drivers/telephony') diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c index ff9a29b76336..89c5e40ce3a0 100644 --- a/drivers/telephony/ixj_pcmcia.c +++ b/drivers/telephony/ixj_pcmcia.c @@ -124,65 +124,57 @@ static void ixj_get_serial(struct pcmcia_device * link, IXJ * j) return; } +static int ixj_config_check(struct pcmcia_device *p_dev, + cistpl_cftable_entry_t *cfg, + 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->conf.ConfigIndex = cfg->index; + p_dev->io.BasePort1 = io->win[0].base; + p_dev->io.NumPorts1 = io->win[0].len; + if (io->nwin == 2) { + 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 + return 0; + } + return -ENODEV; +} + static int ixj_config(struct pcmcia_device * link) { IXJ *j; ixj_info_t *info; - tuple_t tuple; - u_short buf[128]; - cisparse_t parse; - cistpl_cftable_entry_t *cfg = &parse.cftable_entry; - cistpl_cftable_entry_t dflt = - { - 0 - }; - int last_ret, last_fn; + cistpl_cftable_entry_t dflt = { 0 }; + info = link->priv; DEBUG(0, "ixj_config(0x%p)\n", link); - tuple.TupleData = (cisdata_t *) buf; - tuple.TupleOffset = 0; - tuple.TupleDataMax = 255; - tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; - tuple.Attributes = 0; - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); - while (1) { - if (pcmcia_get_tuple_data(link, &tuple) != 0 || - pcmcia_parse_tuple(link, &tuple, &parse) != 0) - goto next_entry; - if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { - cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; - link->conf.ConfigIndex = cfg->index; - link->io.BasePort1 = io->win[0].base; - link->io.NumPorts1 = io->win[0].len; - if (io->nwin == 2) { - link->io.BasePort2 = io->win[1].base; - link->io.NumPorts2 = io->win[1].len; - } - if (pcmcia_request_io(link, &link->io) != 0) - goto next_entry; - /* If we've got this far, we're done */ - break; - } - next_entry: - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) - dflt = *cfg; - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); - } - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); + if (pcmcia_loop_config(link, ixj_config_check, &dflt)) + goto cs_failed; + + if (pcmcia_request_configuration(link, &link->conf)) + goto cs_failed; /* * Register the card with the core. - */ - j=ixj_pcmcia_probe(link->io.BasePort1,link->io.BasePort1 + 0x10); + */ + j = ixj_pcmcia_probe(link->io.BasePort1, link->io.BasePort1 + 0x10); info->ndev = 1; info->node.major = PHONE_MAJOR; link->dev_node = &info->node; ixj_get_serial(link, j); return 0; + cs_failed: - cs_error(link, last_fn, last_ret); ixj_cs_release(link); return -ENODEV; } -- cgit v1.2.3 From 498ac1899b62626bf6879a251d75c22ec564c559 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sat, 2 Aug 2008 14:59:13 +0200 Subject: pcmcia: pcmcia_config_loop() ConfigIndex unification Almost all drivers set p_dev->conf.ConfigIndex to cfg->index in the pcmcia_config_loop() callback function. Therefore, factor it out. Signed-off-by: Dominik Brodowski --- drivers/telephony/ixj_pcmcia.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/telephony') diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c index 89c5e40ce3a0..ba2c7a2125a0 100644 --- a/drivers/telephony/ixj_pcmcia.c +++ b/drivers/telephony/ixj_pcmcia.c @@ -132,7 +132,6 @@ static int ixj_config_check(struct pcmcia_device *p_dev, if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; - p_dev->conf.ConfigIndex = cfg->index; p_dev->io.BasePort1 = io->win[0].base; p_dev->io.NumPorts1 = io->win[0].len; if (io->nwin == 2) { -- 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/telephony/ixj_pcmcia.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'drivers/telephony') 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; -- 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/telephony/ixj_pcmcia.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/telephony') 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)) { -- cgit v1.2.3 From 60836eb63b941f407dc2a609f3f0f34fd74ef6c3 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Wed, 15 Oct 2008 22:04:00 -0700 Subject: telephony: remove CVS keywords Remove CVS keywords that weren't updated for a long time from comments. Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/telephony/ixj.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/telephony') diff --git a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c index ec7aeb502d15..41b6530b8f25 100644 --- a/drivers/telephony/ixj.c +++ b/drivers/telephony/ixj.c @@ -42,8 +42,6 @@ ***************************************************************************/ /* - * $Log: ixj.c,v $ - * * Revision 4.8 2003/07/09 19:39:00 Daniele Bellucci * Audit some copy_*_user and minor cleanup. * -- cgit v1.2.3