Skip to content

Commit

Permalink
pcmcia: use dynamic debug infrastructure, deprecate CS_CHECK (isdn)
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: Karsten Keil <isdn@linux-pingi.de>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
  • Loading branch information
Dominik Brodowski committed Nov 9, 2009
1 parent cbf624f commit e773cfe
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 126 deletions.
2 changes: 0 additions & 2 deletions drivers/isdn/hardware/avm/avm_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ static int avmcs_config(struct pcmcia_device *link)
*/
i = pcmcia_request_irq(link, &link->irq);
if (i != 0) {
cs_error(link, RequestIRQ, i);
/* undo */
pcmcia_disable_device(link);
break;
Expand All @@ -209,7 +208,6 @@ static int avmcs_config(struct pcmcia_device *link)
*/
i = pcmcia_request_configuration(link, &link->conf);
if (i != 0) {
cs_error(link, RequestConfiguration, i);
pcmcia_disable_device(link);
break;
}
Expand Down
26 changes: 4 additions & 22 deletions drivers/isdn/hisax/avma1_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,6 @@ MODULE_DESCRIPTION("ISDN4Linux: PCMCIA client driver for AVM A1/Fritz!PCMCIA car
MODULE_AUTHOR("Carsten Paeth");
MODULE_LICENSE("GPL");

/*
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);
#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args);
static char *version =
"avma1_cs.c 1.00 1998/01/23 10:00:00 (Carsten Paeth)";
#else
#define DEBUG(n, args...)
#endif

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

Expand Down Expand Up @@ -119,7 +103,7 @@ static int avma1cs_probe(struct pcmcia_device *p_dev)
{
local_info_t *local;

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

/* Allocate space for private device-specific data */
local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
Expand Down Expand Up @@ -161,7 +145,7 @@ static int avma1cs_probe(struct pcmcia_device *p_dev)

static void avma1cs_detach(struct pcmcia_device *link)
{
DEBUG(0, "avma1cs_detach(0x%p)\n", link);
dev_dbg(&link->dev, "avma1cs_detach(0x%p)\n", link);
avma1cs_release(link);
kfree(link->priv);
} /* avma1cs_detach */
Expand Down Expand Up @@ -203,7 +187,7 @@ static int avma1cs_config(struct pcmcia_device *link)

dev = link->priv;

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

devname[0] = 0;
if (link->prod_id[1])
Expand All @@ -218,7 +202,6 @@ static int avma1cs_config(struct pcmcia_device *link)
*/
i = pcmcia_request_irq(link, &link->irq);
if (i != 0) {
cs_error(link, RequestIRQ, i);
/* undo */
pcmcia_disable_device(link);
break;
Expand All @@ -229,7 +212,6 @@ static int avma1cs_config(struct pcmcia_device *link)
*/
i = pcmcia_request_configuration(link, &link->conf);
if (i != 0) {
cs_error(link, RequestConfiguration, i);
pcmcia_disable_device(link);
break;
}
Expand Down Expand Up @@ -281,7 +263,7 @@ static void avma1cs_release(struct pcmcia_device *link)
{
local_info_t *local = link->priv;

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

/* now unregister function with hisax */
HiSax_closecard(local->node.minor);
Expand Down
45 changes: 11 additions & 34 deletions drivers/isdn/hisax/elsa_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,6 @@ MODULE_DESCRIPTION("ISDN4Linux: PCMCIA client driver for Elsa PCM cards");
MODULE_AUTHOR("Klaus Lichtenwalder");
MODULE_LICENSE("Dual MPL/GPL");

/*
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);
#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args);
static char *version =
"elsa_cs.c $Revision: 1.2.2.4 $ $Date: 2004/01/25 15:07:06 $ (K.Lichtenwalder)";
#else
#define DEBUG(n, args...)
#endif

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

Expand Down Expand Up @@ -142,7 +125,7 @@ static int elsa_cs_probe(struct pcmcia_device *link)
{
local_info_t *local;

DEBUG(0, "elsa_cs_attach()\n");
dev_dbg(&link->dev, "elsa_cs_attach()\n");

/* Allocate space for private device-specific data */
local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
Expand Down Expand Up @@ -188,7 +171,7 @@ static void elsa_cs_detach(struct pcmcia_device *link)
{
local_info_t *info = link->priv;

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

info->busy = 1;
elsa_cs_release(link);
Expand Down Expand Up @@ -231,30 +214,25 @@ static int elsa_cs_configcheck(struct pcmcia_device *p_dev,
static int elsa_cs_config(struct pcmcia_device *link)
{
local_info_t *dev;
int i, last_fn;
int i;
IsdnCard_t icard;

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

i = pcmcia_loop_config(link, elsa_cs_configcheck, NULL);
if (i != 0) {
last_fn = RequestIO;
goto cs_failed;
}
if (i != 0)
goto failed;

i = pcmcia_request_irq(link, &link->irq);
if (i != 0) {
link->irq.AssignedIRQ = 0;
last_fn = RequestIRQ;
goto cs_failed;
goto failed;
}

i = pcmcia_request_configuration(link, &link->conf);
if (i != 0) {
last_fn = RequestConfiguration;
goto cs_failed;
}
if (i != 0)
goto failed;

/* At this point, the dev_node_t structure(s) should be
initialized and arranged in a linked list at link->dev. *//* */
Expand Down Expand Up @@ -290,8 +268,7 @@ static int elsa_cs_config(struct pcmcia_device *link)
((local_info_t*)link->priv)->cardnr = i;

return 0;
cs_failed:
cs_error(link, last_fn, i);
failed:
elsa_cs_release(link);
return -ENODEV;
} /* elsa_cs_config */
Expand All @@ -308,7 +285,7 @@ static void elsa_cs_release(struct pcmcia_device *link)
{
local_info_t *local = link->priv;

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

if (local) {
if (local->cardnr >= 0) {
Expand Down
59 changes: 21 additions & 38 deletions drivers/isdn/hisax/sedlbauer_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,6 @@ MODULE_DESCRIPTION("ISDN4Linux: PCMCIA client driver for Sedlbauer cards");
MODULE_AUTHOR("Marcus Niemann");
MODULE_LICENSE("Dual MPL/GPL");

/*
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);
#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args);
static char *version =
"sedlbauer_cs.c 1.1a 2001/01/28 15:04:04 (M.Niemann)";
#else
#define DEBUG(n, args...)
#endif


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

Expand Down Expand Up @@ -151,7 +133,7 @@ static int sedlbauer_probe(struct pcmcia_device *link)
{
local_info_t *local;

DEBUG(0, "sedlbauer_attach()\n");
dev_dbg(&link->dev, "sedlbauer_attach()\n");

/* Allocate space for private device-specific data */
local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
Expand Down Expand Up @@ -198,7 +180,7 @@ static int sedlbauer_probe(struct pcmcia_device *link)

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

((local_info_t *)link->priv)->stop = 1;
sedlbauer_release(link);
Expand All @@ -214,9 +196,6 @@ static void sedlbauer_detach(struct pcmcia_device *link)
device available to the system.
======================================================================*/
#define CS_CHECK(fn, ret) \
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)

static int sedlbauer_config_check(struct pcmcia_device *p_dev,
cistpl_cftable_entry_t *cfg,
cistpl_cftable_entry_t *dflt,
Expand Down Expand Up @@ -309,10 +288,10 @@ static int sedlbauer_config(struct pcmcia_device *link)
{
local_info_t *dev = link->priv;
win_req_t *req;
int last_fn, last_ret;
int ret;
IsdnCard_t icard;

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

req = kzalloc(sizeof(win_req_t), GFP_KERNEL);
if (!req)
Expand All @@ -330,24 +309,29 @@ 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, req);
if (last_ret)
ret = pcmcia_loop_config(link, sedlbauer_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;

/*
At this point, the dev_node_t structure(s) need to be
Expand Down Expand Up @@ -380,19 +364,18 @@ static int sedlbauer_config(struct pcmcia_device *link)
icard.protocol = protocol;
icard.typ = ISDN_CTYPE_SEDLBAUER_PCMCIA;

last_ret = hisax_init_pcmcia(link, &(((local_info_t*)link->priv)->stop), &icard);
if (last_ret < 0) {
printk(KERN_ERR "sedlbauer_cs: failed to initialize SEDLBAUER PCMCIA %d at i/o %#x\n",
last_ret, link->io.BasePort1);
ret = hisax_init_pcmcia(link,
&(((local_info_t *)link->priv)->stop), &icard);
if (ret < 0) {
printk(KERN_ERR "sedlbauer_cs: failed to initialize SEDLBAUER PCMCIA %d at i/o %#x\n",
ret, link->io.BasePort1);
sedlbauer_release(link);
return -ENODEV;
} else
((local_info_t*)link->priv)->cardnr = last_ret;
((local_info_t *)link->priv)->cardnr = ret;

return 0;

cs_failed:
cs_error(link, last_fn, last_ret);
failed:
sedlbauer_release(link);
return -ENODEV;
Expand All @@ -410,7 +393,7 @@ static int sedlbauer_config(struct pcmcia_device *link)
static void sedlbauer_release(struct pcmcia_device *link)
{
local_info_t *local = link->priv;
DEBUG(0, "sedlbauer_release(0x%p)\n", link);
dev_dbg(&link->dev, "sedlbauer_release(0x%p)\n", link);

if (local) {
if (local->cardnr >= 0) {
Expand Down
Loading

0 comments on commit e773cfe

Please sign in to comment.