diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2009-10-24 09:51:05 -0400 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2009-11-09 02:30:00 -0500 |
commit | dd0fab5b940c0b65f26ac5b01485bac1f690ace6 (patch) | |
tree | 5730c0c243949e935ea982efa79ed1cd06cc2297 /drivers/net/pcmcia/com20020_cs.c | |
parent | e773cfe167c320d07b9423bc51fc4ab0221775a4 (diff) |
pcmcia: use dynamic debug infrastructure, deprecate CS_CHECK (net)
Convert PCMCIA drivers to use the dynamic debug infrastructure, instead of
requiring manual settings of PCMCIA_DEBUG. Only some rare debug checks are
now hidden behind "#ifdef DEBUG" or "#if 0".
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: netdev@vger.kernel.org
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/net/pcmcia/com20020_cs.c')
-rw-r--r-- | drivers/net/pcmcia/com20020_cs.c | 55 |
1 files changed, 24 insertions, 31 deletions
diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c index 7b5c77b7bd27..9a2e5006570b 100644 --- a/drivers/net/pcmcia/com20020_cs.c +++ b/drivers/net/pcmcia/com20020_cs.c | |||
@@ -53,11 +53,7 @@ | |||
53 | 53 | ||
54 | #define VERSION "arcnet: COM20020 PCMCIA support loaded.\n" | 54 | #define VERSION "arcnet: COM20020 PCMCIA support loaded.\n" |
55 | 55 | ||
56 | #ifdef PCMCIA_DEBUG | 56 | #ifdef DEBUG |
57 | |||
58 | static int pc_debug = PCMCIA_DEBUG; | ||
59 | module_param(pc_debug, int, 0); | ||
60 | #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) | ||
61 | 57 | ||
62 | static void regdump(struct net_device *dev) | 58 | static void regdump(struct net_device *dev) |
63 | { | 59 | { |
@@ -92,7 +88,6 @@ static void regdump(struct net_device *dev) | |||
92 | 88 | ||
93 | #else | 89 | #else |
94 | 90 | ||
95 | #define DEBUG(n, args...) do { } while (0) | ||
96 | static inline void regdump(struct net_device *dev) { } | 91 | static inline void regdump(struct net_device *dev) { } |
97 | 92 | ||
98 | #endif | 93 | #endif |
@@ -144,7 +139,7 @@ static int com20020_probe(struct pcmcia_device *p_dev) | |||
144 | struct net_device *dev; | 139 | struct net_device *dev; |
145 | struct arcnet_local *lp; | 140 | struct arcnet_local *lp; |
146 | 141 | ||
147 | DEBUG(0, "com20020_attach()\n"); | 142 | dev_dbg(&p_dev->dev, "com20020_attach()\n"); |
148 | 143 | ||
149 | /* Create new network device */ | 144 | /* Create new network device */ |
150 | info = kzalloc(sizeof(struct com20020_dev_t), GFP_KERNEL); | 145 | info = kzalloc(sizeof(struct com20020_dev_t), GFP_KERNEL); |
@@ -198,12 +193,12 @@ static void com20020_detach(struct pcmcia_device *link) | |||
198 | struct com20020_dev_t *info = link->priv; | 193 | struct com20020_dev_t *info = link->priv; |
199 | struct net_device *dev = info->dev; | 194 | struct net_device *dev = info->dev; |
200 | 195 | ||
201 | DEBUG(1,"detach...\n"); | 196 | dev_dbg(&link->dev, "detach...\n"); |
202 | 197 | ||
203 | DEBUG(0, "com20020_detach(0x%p)\n", link); | 198 | dev_dbg(&link->dev, "com20020_detach\n"); |
204 | 199 | ||
205 | if (link->dev_node) { | 200 | if (link->dev_node) { |
206 | DEBUG(1,"unregister...\n"); | 201 | dev_dbg(&link->dev, "unregister...\n"); |
207 | 202 | ||
208 | unregister_netdev(dev); | 203 | unregister_netdev(dev); |
209 | 204 | ||
@@ -218,16 +213,16 @@ static void com20020_detach(struct pcmcia_device *link) | |||
218 | com20020_release(link); | 213 | com20020_release(link); |
219 | 214 | ||
220 | /* Unlink device structure, free bits */ | 215 | /* Unlink device structure, free bits */ |
221 | DEBUG(1,"unlinking...\n"); | 216 | dev_dbg(&link->dev, "unlinking...\n"); |
222 | if (link->priv) | 217 | if (link->priv) |
223 | { | 218 | { |
224 | dev = info->dev; | 219 | dev = info->dev; |
225 | if (dev) | 220 | if (dev) |
226 | { | 221 | { |
227 | DEBUG(1,"kfree...\n"); | 222 | dev_dbg(&link->dev, "kfree...\n"); |
228 | free_netdev(dev); | 223 | free_netdev(dev); |
229 | } | 224 | } |
230 | DEBUG(1,"kfree2...\n"); | 225 | dev_dbg(&link->dev, "kfree2...\n"); |
231 | kfree(info); | 226 | kfree(info); |
232 | } | 227 | } |
233 | 228 | ||
@@ -241,25 +236,22 @@ static void com20020_detach(struct pcmcia_device *link) | |||
241 | 236 | ||
242 | ======================================================================*/ | 237 | ======================================================================*/ |
243 | 238 | ||
244 | #define CS_CHECK(fn, ret) \ | ||
245 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | ||
246 | |||
247 | static int com20020_config(struct pcmcia_device *link) | 239 | static int com20020_config(struct pcmcia_device *link) |
248 | { | 240 | { |
249 | struct arcnet_local *lp; | 241 | struct arcnet_local *lp; |
250 | com20020_dev_t *info; | 242 | com20020_dev_t *info; |
251 | struct net_device *dev; | 243 | struct net_device *dev; |
252 | int i, last_ret, last_fn; | 244 | int i, ret; |
253 | int ioaddr; | 245 | int ioaddr; |
254 | 246 | ||
255 | info = link->priv; | 247 | info = link->priv; |
256 | dev = info->dev; | 248 | dev = info->dev; |
257 | 249 | ||
258 | DEBUG(1,"config...\n"); | 250 | dev_dbg(&link->dev, "config...\n"); |
259 | 251 | ||
260 | DEBUG(0, "com20020_config(0x%p)\n", link); | 252 | dev_dbg(&link->dev, "com20020_config\n"); |
261 | 253 | ||
262 | DEBUG(1,"arcnet: baseport1 is %Xh\n", link->io.BasePort1); | 254 | dev_dbg(&link->dev, "baseport1 is %Xh\n", link->io.BasePort1); |
263 | i = -ENODEV; | 255 | i = -ENODEV; |
264 | if (!link->io.BasePort1) | 256 | if (!link->io.BasePort1) |
265 | { | 257 | { |
@@ -276,26 +268,28 @@ static int com20020_config(struct pcmcia_device *link) | |||
276 | 268 | ||
277 | if (i != 0) | 269 | if (i != 0) |
278 | { | 270 | { |
279 | DEBUG(1,"arcnet: requestIO failed totally!\n"); | 271 | dev_dbg(&link->dev, "requestIO failed totally!\n"); |
280 | goto failed; | 272 | goto failed; |
281 | } | 273 | } |
282 | 274 | ||
283 | ioaddr = dev->base_addr = link->io.BasePort1; | 275 | ioaddr = dev->base_addr = link->io.BasePort1; |
284 | DEBUG(1,"arcnet: got ioaddr %Xh\n", ioaddr); | 276 | dev_dbg(&link->dev, "got ioaddr %Xh\n", ioaddr); |
285 | 277 | ||
286 | DEBUG(1,"arcnet: request IRQ %d (%Xh/%Xh)\n", | 278 | dev_dbg(&link->dev, "request IRQ %d (%Xh/%Xh)\n", |
287 | link->irq.AssignedIRQ, | 279 | link->irq.AssignedIRQ, |
288 | link->irq.IRQInfo1, link->irq.IRQInfo2); | 280 | link->irq.IRQInfo1, link->irq.IRQInfo2); |
289 | i = pcmcia_request_irq(link, &link->irq); | 281 | i = pcmcia_request_irq(link, &link->irq); |
290 | if (i != 0) | 282 | if (i != 0) |
291 | { | 283 | { |
292 | DEBUG(1,"arcnet: requestIRQ failed totally!\n"); | 284 | dev_dbg(&link->dev, "requestIRQ failed totally!\n"); |
293 | goto failed; | 285 | goto failed; |
294 | } | 286 | } |
295 | 287 | ||
296 | dev->irq = link->irq.AssignedIRQ; | 288 | dev->irq = link->irq.AssignedIRQ; |
297 | 289 | ||
298 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); | 290 | ret = pcmcia_request_configuration(link, &link->conf); |
291 | if (ret) | ||
292 | goto failed; | ||
299 | 293 | ||
300 | if (com20020_check(dev)) | 294 | if (com20020_check(dev)) |
301 | { | 295 | { |
@@ -313,21 +307,20 @@ static int com20020_config(struct pcmcia_device *link) | |||
313 | i = com20020_found(dev, 0); /* calls register_netdev */ | 307 | i = com20020_found(dev, 0); /* calls register_netdev */ |
314 | 308 | ||
315 | if (i != 0) { | 309 | if (i != 0) { |
316 | DEBUG(1,KERN_NOTICE "com20020_cs: com20020_found() failed\n"); | 310 | dev_printk(KERN_NOTICE, &link->dev, |
311 | "com20020_cs: com20020_found() failed\n"); | ||
317 | link->dev_node = NULL; | 312 | link->dev_node = NULL; |
318 | goto failed; | 313 | goto failed; |
319 | } | 314 | } |
320 | 315 | ||
321 | strcpy(info->node.dev_name, dev->name); | 316 | strcpy(info->node.dev_name, dev->name); |
322 | 317 | ||
323 | DEBUG(1,KERN_INFO "%s: port %#3lx, irq %d\n", | 318 | dev_dbg(&link->dev,KERN_INFO "%s: port %#3lx, irq %d\n", |
324 | dev->name, dev->base_addr, dev->irq); | 319 | dev->name, dev->base_addr, dev->irq); |
325 | return 0; | 320 | return 0; |
326 | 321 | ||
327 | cs_failed: | ||
328 | cs_error(link, last_fn, last_ret); | ||
329 | failed: | 322 | failed: |
330 | DEBUG(1,"com20020_config failed...\n"); | 323 | dev_dbg(&link->dev, "com20020_config failed...\n"); |
331 | com20020_release(link); | 324 | com20020_release(link); |
332 | return -ENODEV; | 325 | return -ENODEV; |
333 | } /* com20020_config */ | 326 | } /* com20020_config */ |
@@ -342,7 +335,7 @@ failed: | |||
342 | 335 | ||
343 | static void com20020_release(struct pcmcia_device *link) | 336 | static void com20020_release(struct pcmcia_device *link) |
344 | { | 337 | { |
345 | DEBUG(0, "com20020_release(0x%p)\n", link); | 338 | dev_dbg(&link->dev, "com20020_release\n"); |
346 | pcmcia_disable_device(link); | 339 | pcmcia_disable_device(link); |
347 | } | 340 | } |
348 | 341 | ||