Skip to content

Commit 9b44de2

Browse files
author
Dominik Brodowski
committed
pcmcia: use dynamic debug infrastructure, deprecate CS_CHECK (misc drivers)
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-mtd@lists.infradead.org CC: linux-usb@vger.kernel.org Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
1 parent 7c5af6f commit 9b44de2

4 files changed

Lines changed: 41 additions & 92 deletions

File tree

‎drivers/mtd/maps/pcmciamtd.c‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,8 @@ static caddr_t remap_window(struct map_info *map, unsigned long to)
119119
dev->offset, mrq.CardOffset);
120120
mrq.Page = 0;
121121
ret = pcmcia_map_mem_page(win, &mrq);
122-
if (ret != 0) {
123-
cs_error(dev->p_dev, MapMemPage, ret);
122+
if (ret != 0)
124123
return NULL;
125-
}
126124
dev->offset = mrq.CardOffset;
127125
}
128126
return dev->win_base + (to & (dev->win_size-1));
@@ -327,8 +325,6 @@ static void pcmciamtd_set_vpp(struct map_info *map, int on)
327325

328326
DEBUG(2, "dev = %p on = %d vpp = %d\n", dev, on, dev->vpp);
329327
ret = pcmcia_modify_configuration(link, &mod);
330-
if (ret != 0)
331-
cs_error(link, ModifyConfiguration, ret);
332328
}
333329

334330

@@ -490,16 +486,12 @@ static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *link,
490486
* MTD device available to the system.
491487
*/
492488

493-
#define CS_CHECK(fn, ret) \
494-
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
495-
496489
static int pcmciamtd_config(struct pcmcia_device *link)
497490
{
498491
struct pcmciamtd_dev *dev = link->priv;
499492
struct mtd_info *mtd = NULL;
500493
cs_status_t status;
501494
win_req_t req;
502-
int last_ret = 0, last_fn = 0;
503495
int ret;
504496
int i;
505497
static char *probes[] = { "jedec_probe", "cfi_probe" };
@@ -586,7 +578,6 @@ static int pcmciamtd_config(struct pcmcia_device *link)
586578
DEBUG(2, "Setting Configuration");
587579
ret = pcmcia_request_configuration(link, &link->conf);
588580
if (ret != 0) {
589-
cs_error(link, RequestConfiguration, ret);
590581
if (dev->win_base) {
591582
iounmap(dev->win_base);
592583
dev->win_base = NULL;
@@ -661,8 +652,7 @@ static int pcmciamtd_config(struct pcmcia_device *link)
661652
link->dev_node = &dev->node;
662653
return 0;
663654

664-
cs_failed:
665-
cs_error(link, last_fn, last_ret);
655+
failed:
666656
err("CS Error, exiting");
667657
pcmciamtd_release(link);
668658
return -ENODEV;

‎drivers/parport/parport_cs.c‎

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,6 @@ MODULE_LICENSE("Dual MPL/GPL");
6767

6868
INT_MODULE_PARM(epp_mode, 1);
6969

70-
#ifdef PCMCIA_DEBUG
71-
INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG);
72-
#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
73-
static char *version =
74-
"parport_cs.c 1.29 2002/10/11 06:57:41 (David Hinds)";
75-
#else
76-
#define DEBUG(n, args...)
77-
#endif
7870

7971
/*====================================================================*/
8072

@@ -103,7 +95,7 @@ static int parport_probe(struct pcmcia_device *link)
10395
{
10496
parport_info_t *info;
10597

106-
DEBUG(0, "parport_attach()\n");
98+
dev_dbg(&link->dev, "parport_attach()\n");
10799

108100
/* Create new parport device */
109101
info = kzalloc(sizeof(*info), GFP_KERNEL);
@@ -132,7 +124,7 @@ static int parport_probe(struct pcmcia_device *link)
132124

133125
static void parport_detach(struct pcmcia_device *link)
134126
{
135-
DEBUG(0, "parport_detach(0x%p)\n", link);
127+
dev_dbg(&link->dev, "parport_detach\n");
136128

137129
parport_cs_release(link);
138130

@@ -147,9 +139,6 @@ static void parport_detach(struct pcmcia_device *link)
147139
148140
======================================================================*/
149141

150-
#define CS_CHECK(fn, ret) \
151-
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
152-
153142
static int parport_config_check(struct pcmcia_device *p_dev,
154143
cistpl_cftable_entry_t *cfg,
155144
cistpl_cftable_entry_t *dflt,
@@ -178,18 +167,20 @@ static int parport_config(struct pcmcia_device *link)
178167
{
179168
parport_info_t *info = link->priv;
180169
struct parport *p;
181-
int last_ret, last_fn;
170+
int ret;
182171

183-
DEBUG(0, "parport_config(0x%p)\n", link);
172+
dev_dbg(&link->dev, "parport_config\n");
184173

185-
last_ret = pcmcia_loop_config(link, parport_config_check, NULL);
186-
if (last_ret) {
187-
cs_error(link, RequestIO, last_ret);
174+
ret = pcmcia_loop_config(link, parport_config_check, NULL);
175+
if (ret)
188176
goto failed;
189-
}
190177

191-
CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
192-
CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
178+
ret = pcmcia_request_irq(link, &link->irq);
179+
if (ret)
180+
goto failed;
181+
ret = pcmcia_request_configuration(link, &link->conf);
182+
if (ret)
183+
goto failed;
193184

194185
p = parport_pc_probe_port(link->io.BasePort1, link->io.BasePort2,
195186
link->irq.AssignedIRQ, PARPORT_DMA_NONE,
@@ -213,8 +204,6 @@ static int parport_config(struct pcmcia_device *link)
213204

214205
return 0;
215206

216-
cs_failed:
217-
cs_error(link, last_fn, last_ret);
218207
failed:
219208
parport_cs_release(link);
220209
return -ENODEV;
@@ -232,7 +221,7 @@ static void parport_cs_release(struct pcmcia_device *link)
232221
{
233222
parport_info_t *info = link->priv;
234223

235-
DEBUG(0, "parport_release(0x%p)\n", link);
224+
dev_dbg(&link->dev, "parport_release\n");
236225

237226
if (info->ndev) {
238227
struct parport *p = info->port;

‎drivers/telephony/ixj_pcmcia.c‎

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@
1919
* PCMCIA service support for Quicknet cards
2020
*/
2121

22-
#ifdef PCMCIA_DEBUG
23-
static int pc_debug = PCMCIA_DEBUG;
24-
module_param(pc_debug, int, 0644);
25-
#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
26-
#else
27-
#define DEBUG(n, args...)
28-
#endif
2922

3023
typedef struct ixj_info_t {
3124
int ndev;
@@ -39,7 +32,7 @@ static void ixj_cs_release(struct pcmcia_device * link);
3932

4033
static int ixj_probe(struct pcmcia_device *p_dev)
4134
{
42-
DEBUG(0, "ixj_attach()\n");
35+
dev_dbg(&p_dev->dev, "ixj_attach()\n");
4336
/* Create new ixj device */
4437
p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
4538
p_dev->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
@@ -55,33 +48,30 @@ static int ixj_probe(struct pcmcia_device *p_dev)
5548

5649
static void ixj_detach(struct pcmcia_device *link)
5750
{
58-
DEBUG(0, "ixj_detach(0x%p)\n", link);
51+
dev_dbg(&link->dev, "ixj_detach\n");
5952

6053
ixj_cs_release(link);
6154

6255
kfree(link->priv);
6356
}
6457

65-
#define CS_CHECK(fn, ret) \
66-
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
67-
6858
static void ixj_get_serial(struct pcmcia_device * link, IXJ * j)
6959
{
7060
char *str;
7161
int i, place;
72-
DEBUG(0, "ixj_get_serial(0x%p)\n", link);
62+
dev_dbg(&link->dev, "ixj_get_serial\n");
7363

7464
str = link->prod_id[0];
7565
if (!str)
76-
goto cs_failed;
66+
goto failed;
7767
printk("%s", str);
7868
str = link->prod_id[1];
7969
if (!str)
80-
goto cs_failed;
70+
goto failed;
8171
printk(" %s", str);
8272
str = link->prod_id[2];
8373
if (!str)
84-
goto cs_failed;
74+
goto failed;
8575
place = 1;
8676
for (i = strlen(str) - 1; i >= 0; i--) {
8777
switch (str[i]) {
@@ -118,9 +108,9 @@ static void ixj_get_serial(struct pcmcia_device * link, IXJ * j)
118108
}
119109
str = link->prod_id[3];
120110
if (!str)
121-
goto cs_failed;
111+
goto failed;
122112
printk(" version %s\n", str);
123-
cs_failed:
113+
failed:
124114
return;
125115
}
126116

@@ -151,13 +141,13 @@ static int ixj_config(struct pcmcia_device * link)
151141
cistpl_cftable_entry_t dflt = { 0 };
152142

153143
info = link->priv;
154-
DEBUG(0, "ixj_config(0x%p)\n", link);
144+
dev_dbg(&link->dev, "ixj_config\n");
155145

156146
if (pcmcia_loop_config(link, ixj_config_check, &dflt))
157-
goto cs_failed;
147+
goto failed;
158148

159149
if (pcmcia_request_configuration(link, &link->conf))
160-
goto cs_failed;
150+
goto failed;
161151

162152
/*
163153
* Register the card with the core.
@@ -170,15 +160,15 @@ static int ixj_config(struct pcmcia_device * link)
170160
ixj_get_serial(link, j);
171161
return 0;
172162

173-
cs_failed:
163+
failed:
174164
ixj_cs_release(link);
175165
return -ENODEV;
176166
}
177167

178168
static void ixj_cs_release(struct pcmcia_device *link)
179169
{
180170
ixj_info_t *info = link->priv;
181-
DEBUG(0, "ixj_cs_release(0x%p)\n", link);
171+
dev_dbg(&link->dev, "ixj_cs_release\n");
182172
info->ndev = 0;
183173
pcmcia_disable_device(link);
184174
}

‎drivers/usb/host/sl811_cs.c‎

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,8 @@ MODULE_LICENSE("GPL");
3737
/* MACROS */
3838
/*====================================================================*/
3939

40-
#if defined(DEBUG) || defined(PCMCIA_DEBUG)
41-
42-
static int pc_debug = 0;
43-
module_param(pc_debug, int, 0644);
44-
45-
#define DBG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG "sl811_cs: " args)
46-
47-
#else
48-
#define DBG(n, args...) do{}while(0)
49-
#endif /* no debugging */
50-
5140
#define INFO(args...) printk(KERN_INFO "sl811_cs: " args)
5241

53-
#define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0444)
54-
55-
#define CS_CHECK(fn, ret) \
56-
do { \
57-
last_fn = (fn); \
58-
if ((last_ret = (ret)) != 0) \
59-
goto cs_failed; \
60-
} while (0)
61-
6242
/*====================================================================*/
6343
/* VARIABLES */
6444
/*====================================================================*/
@@ -76,7 +56,7 @@ static void sl811_cs_release(struct pcmcia_device * link);
7656

7757
static void release_platform_dev(struct device * dev)
7858
{
79-
DBG(0, "sl811_cs platform_dev release\n");
59+
dev_dbg(dev, "sl811_cs platform_dev release\n");
8060
dev->parent = NULL;
8161
}
8262

@@ -140,7 +120,7 @@ static int sl811_hc_init(struct device *parent, resource_size_t base_addr,
140120

141121
static void sl811_cs_detach(struct pcmcia_device *link)
142122
{
143-
DBG(0, "sl811_cs_detach(0x%p)\n", link);
123+
dev_dbg(&link->dev, "sl811_cs_detach\n");
144124

145125
sl811_cs_release(link);
146126

@@ -150,7 +130,7 @@ static void sl811_cs_detach(struct pcmcia_device *link)
150130

151131
static void sl811_cs_release(struct pcmcia_device * link)
152132
{
153-
DBG(0, "sl811_cs_release(0x%p)\n", link);
133+
dev_dbg(&link->dev, "sl811_cs_release\n");
154134

155135
pcmcia_disable_device(link);
156136
platform_device_unregister(&platform_dev);
@@ -207,24 +187,26 @@ static int sl811_cs_config(struct pcmcia_device *link)
207187
{
208188
struct device *parent = &handle_to_dev(link);
209189
local_info_t *dev = link->priv;
210-
int last_fn, last_ret;
190+
int ret;
211191

212-
DBG(0, "sl811_cs_config(0x%p)\n", link);
192+
dev_dbg(&link->dev, "sl811_cs_config\n");
213193

214194
if (pcmcia_loop_config(link, sl811_cs_config_check, NULL))
215195
goto failed;
216196

217197
/* require an IRQ and two registers */
218198
if (!link->io.NumPorts1 || link->io.NumPorts1 < 2)
219199
goto failed;
220-
if (link->conf.Attributes & CONF_ENABLE_IRQ)
221-
CS_CHECK(RequestIRQ,
222-
pcmcia_request_irq(link, &link->irq));
223-
else
200+
if (link->conf.Attributes & CONF_ENABLE_IRQ) {
201+
ret = pcmcia_request_irq(link, &link->irq);
202+
if (ret)
203+
goto failed;
204+
} else
224205
goto failed;
225206

226-
CS_CHECK(RequestConfiguration,
227-
pcmcia_request_configuration(link, &link->conf));
207+
ret = pcmcia_request_configuration(link, &link->conf);
208+
if (ret)
209+
goto failed;
228210

229211
sprintf(dev->node.dev_name, driver_name);
230212
dev->node.major = dev->node.minor = 0;
@@ -241,8 +223,6 @@ static int sl811_cs_config(struct pcmcia_device *link)
241223

242224
if (sl811_hc_init(parent, link->io.BasePort1, link->irq.AssignedIRQ)
243225
< 0) {
244-
cs_failed:
245-
cs_error(link, last_fn, last_ret);
246226
failed:
247227
printk(KERN_WARNING "sl811_cs_config failed\n");
248228
sl811_cs_release(link);

0 commit comments

Comments
 (0)