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/pcnet_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/pcnet_cs.c')
-rw-r--r-- | drivers/net/pcmcia/pcnet_cs.c | 67 |
1 files changed, 25 insertions, 42 deletions
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index bd3447f04902..80ab9de1c4df 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c | |||
@@ -71,15 +71,6 @@ | |||
71 | 71 | ||
72 | static const char *if_names[] = { "auto", "10baseT", "10base2"}; | 72 | static const char *if_names[] = { "auto", "10baseT", "10base2"}; |
73 | 73 | ||
74 | #ifdef PCMCIA_DEBUG | ||
75 | static int pc_debug = PCMCIA_DEBUG; | ||
76 | module_param(pc_debug, int, 0); | ||
77 | #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) | ||
78 | static char *version = | ||
79 | "pcnet_cs.c 1.153 2003/11/09 18:53:09 (David Hinds)"; | ||
80 | #else | ||
81 | #define DEBUG(n, args...) | ||
82 | #endif | ||
83 | 74 | ||
84 | /*====================================================================*/ | 75 | /*====================================================================*/ |
85 | 76 | ||
@@ -265,7 +256,7 @@ static int pcnet_probe(struct pcmcia_device *link) | |||
265 | pcnet_dev_t *info; | 256 | pcnet_dev_t *info; |
266 | struct net_device *dev; | 257 | struct net_device *dev; |
267 | 258 | ||
268 | DEBUG(0, "pcnet_attach()\n"); | 259 | dev_dbg(&link->dev, "pcnet_attach()\n"); |
269 | 260 | ||
270 | /* Create new ethernet device */ | 261 | /* Create new ethernet device */ |
271 | dev = __alloc_ei_netdev(sizeof(pcnet_dev_t)); | 262 | dev = __alloc_ei_netdev(sizeof(pcnet_dev_t)); |
@@ -297,7 +288,7 @@ static void pcnet_detach(struct pcmcia_device *link) | |||
297 | { | 288 | { |
298 | struct net_device *dev = link->priv; | 289 | struct net_device *dev = link->priv; |
299 | 290 | ||
300 | DEBUG(0, "pcnet_detach(0x%p)\n", link); | 291 | dev_dbg(&link->dev, "pcnet_detach\n"); |
301 | 292 | ||
302 | if (link->dev_node) | 293 | if (link->dev_node) |
303 | unregister_netdev(dev); | 294 | unregister_netdev(dev); |
@@ -327,10 +318,8 @@ static hw_info_t *get_hwinfo(struct pcmcia_device *link) | |||
327 | req.Base = 0; req.Size = 0; | 318 | req.Base = 0; req.Size = 0; |
328 | req.AccessSpeed = 0; | 319 | req.AccessSpeed = 0; |
329 | i = pcmcia_request_window(&link, &req, &link->win); | 320 | i = pcmcia_request_window(&link, &req, &link->win); |
330 | if (i != 0) { | 321 | if (i != 0) |
331 | cs_error(link, RequestWindow, i); | ||
332 | return NULL; | 322 | return NULL; |
333 | } | ||
334 | 323 | ||
335 | virt = ioremap(req.Base, req.Size); | 324 | virt = ioremap(req.Base, req.Size); |
336 | mem.Page = 0; | 325 | mem.Page = 0; |
@@ -349,8 +338,6 @@ static hw_info_t *get_hwinfo(struct pcmcia_device *link) | |||
349 | 338 | ||
350 | iounmap(virt); | 339 | iounmap(virt); |
351 | j = pcmcia_release_window(link->win); | 340 | j = pcmcia_release_window(link->win); |
352 | if (j != 0) | ||
353 | cs_error(link, ReleaseWindow, j); | ||
354 | return (i < NR_INFO) ? hw_info+i : NULL; | 341 | return (i < NR_INFO) ? hw_info+i : NULL; |
355 | } /* get_hwinfo */ | 342 | } /* get_hwinfo */ |
356 | 343 | ||
@@ -495,9 +482,6 @@ static hw_info_t *get_hwired(struct pcmcia_device *link) | |||
495 | 482 | ||
496 | ======================================================================*/ | 483 | ======================================================================*/ |
497 | 484 | ||
498 | #define CS_CHECK(fn, ret) \ | ||
499 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | ||
500 | |||
501 | static int try_io_port(struct pcmcia_device *link) | 485 | static int try_io_port(struct pcmcia_device *link) |
502 | { | 486 | { |
503 | int j, ret; | 487 | int j, ret; |
@@ -567,19 +551,19 @@ static int pcnet_config(struct pcmcia_device *link) | |||
567 | { | 551 | { |
568 | struct net_device *dev = link->priv; | 552 | struct net_device *dev = link->priv; |
569 | pcnet_dev_t *info = PRIV(dev); | 553 | pcnet_dev_t *info = PRIV(dev); |
570 | int last_ret, last_fn, start_pg, stop_pg, cm_offset; | 554 | int ret, start_pg, stop_pg, cm_offset; |
571 | int has_shmem = 0; | 555 | int has_shmem = 0; |
572 | hw_info_t *local_hw_info; | 556 | hw_info_t *local_hw_info; |
573 | 557 | ||
574 | DEBUG(0, "pcnet_config(0x%p)\n", link); | 558 | dev_dbg(&link->dev, "pcnet_config\n"); |
575 | 559 | ||
576 | last_ret = pcmcia_loop_config(link, pcnet_confcheck, &has_shmem); | 560 | ret = pcmcia_loop_config(link, pcnet_confcheck, &has_shmem); |
577 | if (last_ret) { | 561 | if (ret) |
578 | cs_error(link, RequestIO, last_ret); | ||
579 | goto failed; | 562 | goto failed; |
580 | } | ||
581 | 563 | ||
582 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); | 564 | ret = pcmcia_request_irq(link, &link->irq); |
565 | if (ret) | ||
566 | goto failed; | ||
583 | 567 | ||
584 | if (link->io.NumPorts2 == 8) { | 568 | if (link->io.NumPorts2 == 8) { |
585 | link->conf.Attributes |= CONF_ENABLE_SPKR; | 569 | link->conf.Attributes |= CONF_ENABLE_SPKR; |
@@ -589,7 +573,9 @@ static int pcnet_config(struct pcmcia_device *link) | |||
589 | (link->card_id == PRODID_IBM_HOME_AND_AWAY)) | 573 | (link->card_id == PRODID_IBM_HOME_AND_AWAY)) |
590 | link->conf.ConfigIndex |= 0x10; | 574 | link->conf.ConfigIndex |= 0x10; |
591 | 575 | ||
592 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); | 576 | ret = pcmcia_request_configuration(link, &link->conf); |
577 | if (ret) | ||
578 | goto failed; | ||
593 | dev->irq = link->irq.AssignedIRQ; | 579 | dev->irq = link->irq.AssignedIRQ; |
594 | dev->base_addr = link->io.BasePort1; | 580 | dev->base_addr = link->io.BasePort1; |
595 | if (info->flags & HAS_MISC_REG) { | 581 | if (info->flags & HAS_MISC_REG) { |
@@ -687,8 +673,6 @@ static int pcnet_config(struct pcmcia_device *link) | |||
687 | printk(" hw_addr %pM\n", dev->dev_addr); | 673 | printk(" hw_addr %pM\n", dev->dev_addr); |
688 | return 0; | 674 | return 0; |
689 | 675 | ||
690 | cs_failed: | ||
691 | cs_error(link, last_fn, last_ret); | ||
692 | failed: | 676 | failed: |
693 | pcnet_release(link); | 677 | pcnet_release(link); |
694 | return -ENODEV; | 678 | return -ENODEV; |
@@ -706,7 +690,7 @@ static void pcnet_release(struct pcmcia_device *link) | |||
706 | { | 690 | { |
707 | pcnet_dev_t *info = PRIV(link->priv); | 691 | pcnet_dev_t *info = PRIV(link->priv); |
708 | 692 | ||
709 | DEBUG(0, "pcnet_release(0x%p)\n", link); | 693 | dev_dbg(&link->dev, "pcnet_release\n"); |
710 | 694 | ||
711 | if (info->flags & USE_SHMEM) | 695 | if (info->flags & USE_SHMEM) |
712 | iounmap(info->base); | 696 | iounmap(info->base); |
@@ -960,7 +944,7 @@ static void mii_phy_probe(struct net_device *dev) | |||
960 | phyid = tmp << 16; | 944 | phyid = tmp << 16; |
961 | phyid |= mdio_read(mii_addr, i, MII_PHYID_REG2); | 945 | phyid |= mdio_read(mii_addr, i, MII_PHYID_REG2); |
962 | phyid &= MII_PHYID_REV_MASK; | 946 | phyid &= MII_PHYID_REV_MASK; |
963 | DEBUG(0, "%s: MII at %d is 0x%08x\n", dev->name, i, phyid); | 947 | pr_debug("%s: MII at %d is 0x%08x\n", dev->name, i, phyid); |
964 | if (phyid == AM79C9XX_HOME_PHY) { | 948 | if (phyid == AM79C9XX_HOME_PHY) { |
965 | info->pna_phy = i; | 949 | info->pna_phy = i; |
966 | } else if (phyid != AM79C9XX_ETH_PHY) { | 950 | } else if (phyid != AM79C9XX_ETH_PHY) { |
@@ -976,7 +960,7 @@ static int pcnet_open(struct net_device *dev) | |||
976 | struct pcmcia_device *link = info->p_dev; | 960 | struct pcmcia_device *link = info->p_dev; |
977 | unsigned int nic_base = dev->base_addr; | 961 | unsigned int nic_base = dev->base_addr; |
978 | 962 | ||
979 | DEBUG(2, "pcnet_open('%s')\n", dev->name); | 963 | dev_dbg(&link->dev, "pcnet_open('%s')\n", dev->name); |
980 | 964 | ||
981 | if (!pcmcia_dev_present(link)) | 965 | if (!pcmcia_dev_present(link)) |
982 | return -ENODEV; | 966 | return -ENODEV; |
@@ -1008,7 +992,7 @@ static int pcnet_close(struct net_device *dev) | |||
1008 | pcnet_dev_t *info = PRIV(dev); | 992 | pcnet_dev_t *info = PRIV(dev); |
1009 | struct pcmcia_device *link = info->p_dev; | 993 | struct pcmcia_device *link = info->p_dev; |
1010 | 994 | ||
1011 | DEBUG(2, "pcnet_close('%s')\n", dev->name); | 995 | dev_dbg(&link->dev, "pcnet_close('%s')\n", dev->name); |
1012 | 996 | ||
1013 | ei_close(dev); | 997 | ei_close(dev); |
1014 | free_irq(dev->irq, dev); | 998 | free_irq(dev->irq, dev); |
@@ -1251,10 +1235,8 @@ static void dma_block_input(struct net_device *dev, int count, | |||
1251 | int xfer_count = count; | 1235 | int xfer_count = count; |
1252 | char *buf = skb->data; | 1236 | char *buf = skb->data; |
1253 | 1237 | ||
1254 | #ifdef PCMCIA_DEBUG | ||
1255 | if ((ei_debug > 4) && (count != 4)) | 1238 | if ((ei_debug > 4) && (count != 4)) |
1256 | printk(KERN_DEBUG "%s: [bi=%d]\n", dev->name, count+4); | 1239 | pr_debug("%s: [bi=%d]\n", dev->name, count+4); |
1257 | #endif | ||
1258 | if (ei_status.dmaing) { | 1240 | if (ei_status.dmaing) { |
1259 | printk(KERN_NOTICE "%s: DMAing conflict in dma_block_input." | 1241 | printk(KERN_NOTICE "%s: DMAing conflict in dma_block_input." |
1260 | "[DMAstat:%1x][irqlock:%1x]\n", | 1242 | "[DMAstat:%1x][irqlock:%1x]\n", |
@@ -1495,7 +1477,7 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg, | |||
1495 | pcnet_dev_t *info = PRIV(dev); | 1477 | pcnet_dev_t *info = PRIV(dev); |
1496 | win_req_t req; | 1478 | win_req_t req; |
1497 | memreq_t mem; | 1479 | memreq_t mem; |
1498 | int i, window_size, offset, last_ret, last_fn; | 1480 | int i, window_size, offset, ret; |
1499 | 1481 | ||
1500 | window_size = (stop_pg - start_pg) << 8; | 1482 | window_size = (stop_pg - start_pg) << 8; |
1501 | if (window_size > 32 * 1024) | 1483 | if (window_size > 32 * 1024) |
@@ -1509,13 +1491,17 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg, | |||
1509 | req.Attributes |= WIN_USE_WAIT; | 1491 | req.Attributes |= WIN_USE_WAIT; |
1510 | req.Base = 0; req.Size = window_size; | 1492 | req.Base = 0; req.Size = window_size; |
1511 | req.AccessSpeed = mem_speed; | 1493 | req.AccessSpeed = mem_speed; |
1512 | CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &link->win)); | 1494 | ret = pcmcia_request_window(&link, &req, &link->win); |
1495 | if (ret) | ||
1496 | goto failed; | ||
1513 | 1497 | ||
1514 | mem.CardOffset = (start_pg << 8) + cm_offset; | 1498 | mem.CardOffset = (start_pg << 8) + cm_offset; |
1515 | offset = mem.CardOffset % window_size; | 1499 | offset = mem.CardOffset % window_size; |
1516 | mem.CardOffset -= offset; | 1500 | mem.CardOffset -= offset; |
1517 | mem.Page = 0; | 1501 | mem.Page = 0; |
1518 | CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem)); | 1502 | ret = pcmcia_map_mem_page(link->win, &mem); |
1503 | if (ret) | ||
1504 | goto failed; | ||
1519 | 1505 | ||
1520 | /* Try scribbling on the buffer */ | 1506 | /* Try scribbling on the buffer */ |
1521 | info->base = ioremap(req.Base, window_size); | 1507 | info->base = ioremap(req.Base, window_size); |
@@ -1549,8 +1535,6 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg, | |||
1549 | info->flags |= USE_SHMEM; | 1535 | info->flags |= USE_SHMEM; |
1550 | return 0; | 1536 | return 0; |
1551 | 1537 | ||
1552 | cs_failed: | ||
1553 | cs_error(link, last_fn, last_ret); | ||
1554 | failed: | 1538 | failed: |
1555 | return 1; | 1539 | return 1; |
1556 | } | 1540 | } |
@@ -1788,7 +1772,6 @@ static int __init init_pcnet_cs(void) | |||
1788 | 1772 | ||
1789 | static void __exit exit_pcnet_cs(void) | 1773 | static void __exit exit_pcnet_cs(void) |
1790 | { | 1774 | { |
1791 | DEBUG(0, "pcnet_cs: unloading\n"); | ||
1792 | pcmcia_unregister_driver(&pcnet_driver); | 1775 | pcmcia_unregister_driver(&pcnet_driver); |
1793 | } | 1776 | } |
1794 | 1777 | ||