Skip to content

Commit

Permalink
pcmcia: use dynamic debug infrastructure, deprecate CS_CHECK (wireless)
Browse files Browse the repository at this point in the history
Convert PCMCIA drivers to use the dynamic debug infrastructure, instead of
requiring manual settings of PCMCIA_DEBUG.

Also, remove all usages of the CS_CHECK macro and replace them with proper
Linux style calling and return value checking. The extra error reporting may
be dropped, as the PCMCIA core already complains about any (non-driver-author)
errors.

CC: linux-wireless@vger.kernel.org
CC: netdev@vger.kernel.org
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
  • Loading branch information
Dominik Brodowski committed Nov 9, 2009
1 parent 624dd66 commit 2caff14
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 241 deletions.
48 changes: 16 additions & 32 deletions drivers/net/wireless/airo_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,6 @@

#include "airo.h"

/*
All the PCMCIA modules use PCMCIA_DEBUG to control debugging. If
you do not define PCMCIA_DEBUG at all, all the debug code will be
left out. If you compile with PCMCIA_DEBUG=0, the debug code will
be present but disabled -- but it can then be enabled for specific
modules at load time with a 'pc_debug=#' option to insmod.
*/
#ifdef PCMCIA_DEBUG
static int pc_debug = PCMCIA_DEBUG;
module_param(pc_debug, int, 0);
static char *version = "$Revision: 1.2 $";
#define DEBUG(n, args...) if (pc_debug > (n)) printk(KERN_DEBUG args);
#else
#define DEBUG(n, args...)
#endif

/*====================================================================*/

Expand Down Expand Up @@ -145,7 +130,7 @@ static int airo_probe(struct pcmcia_device *p_dev)
{
local_info_t *local;

DEBUG(0, "airo_attach()\n");
dev_dbg(&p_dev->dev, "airo_attach()\n");

/* Interrupt setup */
p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
Expand Down Expand Up @@ -184,7 +169,7 @@ static int airo_probe(struct pcmcia_device *p_dev)

static void airo_detach(struct pcmcia_device *link)
{
DEBUG(0, "airo_detach(0x%p)\n", link);
dev_dbg(&link->dev, "airo_detach\n");

airo_release(link);

Expand All @@ -204,9 +189,6 @@ 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)

static int airo_cs_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
Expand Down Expand Up @@ -291,11 +273,11 @@ static int airo_config(struct pcmcia_device *link)
{
local_info_t *dev;
win_req_t *req;
int last_fn, last_ret;
int ret;

dev = link->priv;

DEBUG(0, "airo_config(0x%p)\n", link);
dev_dbg(&link->dev, "airo_config\n");

req = kzalloc(sizeof(win_req_t), GFP_KERNEL);
if (!req)
Expand All @@ -315,30 +297,34 @@ 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, req);
if (last_ret)
ret = pcmcia_loop_config(link, airo_cs_config_check, req);
if (ret)
goto failed;

/*
Allocate an interrupt line. Note that this does not assign a
handler to the interrupt, unless the 'Handler' member of the
irq structure is initialized.
*/
if (link->conf.Attributes & CONF_ENABLE_IRQ)
CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
if (link->conf.Attributes & CONF_ENABLE_IRQ) {
ret = pcmcia_request_irq(link, &link->irq);
if (ret)
goto failed;
}

/*
This actually configures the PCMCIA socket -- setting up
the I/O windows and the interrupt mapping, and putting the
card and host interface into "Memory and IO" mode.
*/
CS_CHECK(RequestConfiguration,
pcmcia_request_configuration(link, &link->conf));
ret = pcmcia_request_configuration(link, &link->conf);
if (ret)
goto failed;
((local_info_t *)link->priv)->eth_dev =
init_airo_card(link->irq.AssignedIRQ,
link->io.BasePort1, 1, &handle_to_dev(link));
if (!((local_info_t *)link->priv)->eth_dev)
goto cs_failed;
goto failed;

/*
At this point, the dev_node_t structure(s) need to be
Expand Down Expand Up @@ -368,8 +354,6 @@ static int airo_config(struct pcmcia_device *link)
kfree(req);
return 0;

cs_failed:
cs_error(link, last_fn, last_ret);
failed:
airo_release(link);
kfree(req);
Expand All @@ -386,7 +370,7 @@ static int airo_config(struct pcmcia_device *link)

static void airo_release(struct pcmcia_device *link)
{
DEBUG(0, "airo_release(0x%p)\n", link);
dev_dbg(&link->dev, "airo_release\n");
pcmcia_disable_device(link);
}

Expand Down
46 changes: 15 additions & 31 deletions drivers/net/wireless/atmel_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,6 @@

#include "atmel.h"

/*
All the PCMCIA modules use PCMCIA_DEBUG to control debugging. If
you do not define PCMCIA_DEBUG at all, all the debug code will be
left out. If you compile with PCMCIA_DEBUG=0, the debug code will
be present but disabled -- but it can then be enabled for specific
modules at load time with a 'pc_debug=#' option to insmod.
*/

#ifdef PCMCIA_DEBUG
static int pc_debug = PCMCIA_DEBUG;
module_param(pc_debug, int, 0);
static char *version = "$Revision: 1.2 $";
#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args);
#else
#define DEBUG(n, args...)
#endif

/*====================================================================*/

Expand Down Expand Up @@ -155,7 +139,7 @@ static int atmel_probe(struct pcmcia_device *p_dev)
{
local_info_t *local;

DEBUG(0, "atmel_attach()\n");
dev_dbg(&p_dev->dev, "atmel_attach()\n");

/* Interrupt setup */
p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
Expand Down Expand Up @@ -194,7 +178,7 @@ static int atmel_probe(struct pcmcia_device *p_dev)

static void atmel_detach(struct pcmcia_device *link)
{
DEBUG(0, "atmel_detach(0x%p)\n", link);
dev_dbg(&link->dev, "atmel_detach\n");

atmel_release(link);

Expand All @@ -209,9 +193,6 @@ static void atmel_detach(struct pcmcia_device *link)
======================================================================*/

#define CS_CHECK(fn, ret) \
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)

/* Call-back function to interrogate PCMCIA-specific information
about the current existance of the card */
static int card_present(void *arg)
Expand Down Expand Up @@ -275,13 +256,13 @@ static int atmel_config_check(struct pcmcia_device *p_dev,
static int atmel_config(struct pcmcia_device *link)
{
local_info_t *dev;
int last_fn, last_ret;
int ret;
struct pcmcia_device_id *did;

dev = link->priv;
did = dev_get_drvdata(&handle_to_dev(link));

DEBUG(0, "atmel_config(0x%p)\n", link);
dev_dbg(&link->dev, "atmel_config\n");

/*
In this loop, we scan the CIS for configuration table entries,
Expand All @@ -303,20 +284,25 @@ static int atmel_config(struct pcmcia_device *link)
handler to the interrupt, unless the 'Handler' member of the
irq structure is initialized.
*/
if (link->conf.Attributes & CONF_ENABLE_IRQ)
CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
if (link->conf.Attributes & CONF_ENABLE_IRQ) {
ret = pcmcia_request_irq(link, &link->irq);
if (ret)
goto failed;
}

/*
This actually configures the PCMCIA socket -- setting up
the I/O windows and the interrupt mapping, and putting the
card and host interface into "Memory and IO" mode.
*/
CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
ret = pcmcia_request_configuration(link, &link->conf);
if (ret)
goto failed;

if (link->irq.AssignedIRQ == 0) {
printk(KERN_ALERT
"atmel: cannot assign IRQ: check that CONFIG_ISA is set in kernel config.");
goto cs_failed;
goto failed;
}

((local_info_t*)link->priv)->eth_dev =
Expand All @@ -327,7 +313,7 @@ static int atmel_config(struct pcmcia_device *link)
card_present,
link);
if (!((local_info_t*)link->priv)->eth_dev)
goto cs_failed;
goto failed;


/*
Expand All @@ -340,8 +326,6 @@ static int atmel_config(struct pcmcia_device *link)

return 0;

cs_failed:
cs_error(link, last_fn, last_ret);
failed:
atmel_release(link);
return -ENODEV;
Expand All @@ -359,7 +343,7 @@ static void atmel_release(struct pcmcia_device *link)
{
struct net_device *dev = ((local_info_t*)link->priv)->eth_dev;

DEBUG(0, "atmel_release(0x%p)\n", link);
dev_dbg(&link->dev, "atmel_release\n");

if (dev)
stop_atmel_card(dev);
Expand Down
23 changes: 8 additions & 15 deletions drivers/net/wireless/hostap/hostap_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,6 @@ static void prism2_detach(struct pcmcia_device *link)
}


#define CS_CHECK(fn, ret) \
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 */

Expand Down Expand Up @@ -605,7 +601,6 @@ static int prism2_config(struct pcmcia_device *link)
struct hostap_interface *iface;
local_info_t *local;
int ret = 1;
int last_fn, last_ret;
struct hostap_cs_priv *hw_priv;

PDEBUG(DEBUG_FLOW, "prism2_config()\n");
Expand All @@ -617,13 +612,12 @@ static int prism2_config(struct pcmcia_device *link)
}

/* Look for an appropriate configuration table entry in the CIS */
last_ret = pcmcia_loop_config(link, prism2_config_check, NULL);
if (last_ret) {
ret = pcmcia_loop_config(link, prism2_config_check, NULL);
if (ret) {
if (!ignore_cis_vcc)
printk(KERN_ERR "GetNextTuple(): No matching "
"CIS configuration. Maybe you need the "
"ignore_cis_vcc=1 parameter.\n");
cs_error(link, RequestIO, last_ret);
goto failed;
}

Expand Down Expand Up @@ -652,17 +646,19 @@ static int prism2_config(struct pcmcia_device *link)
link->irq.IRQInfo1 = IRQ_LEVEL_ID;
link->irq.Handler = prism2_interrupt;
link->irq.Instance = dev;
CS_CHECK(RequestIRQ,
pcmcia_request_irq(link, &link->irq));
ret = pcmcia_request_irq(link, &link->irq);
if (ret)
goto failed;
}

/*
* This actually configures the PCMCIA socket -- setting up
* the I/O windows and the interrupt mapping, and putting the
* card and host interface into "Memory and IO" mode.
*/
CS_CHECK(RequestConfiguration,
pcmcia_request_configuration(link, &link->conf));
ret = pcmcia_request_configuration(link, &link->conf);
if (ret)
goto failed;

dev->irq = link->irq.AssignedIRQ;
dev->base_addr = link->io.BasePort1;
Expand Down Expand Up @@ -695,9 +691,6 @@ static int prism2_config(struct pcmcia_device *link)
}
return ret;

cs_failed:
cs_error(link, last_fn, last_ret);

failed:
kfree(hw_priv);
prism2_release((u_long)link);
Expand Down
Loading

0 comments on commit 2caff14

Please sign in to comment.