aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/pcmcia/3c589_cs.c
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2009-10-24 09:51:05 -0400
committerDominik Brodowski <linux@dominikbrodowski.net>2009-11-09 02:30:00 -0500
commitdd0fab5b940c0b65f26ac5b01485bac1f690ace6 (patch)
tree5730c0c243949e935ea982efa79ed1cd06cc2297 /drivers/net/pcmcia/3c589_cs.c
parente773cfe167c320d07b9423bc51fc4ab0221775a4 (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/3c589_cs.c')
-rw-r--r--drivers/net/pcmcia/3c589_cs.c75
1 files changed, 25 insertions, 50 deletions
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index fc6123ea6fa7..6eac62b7143c 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -130,14 +130,6 @@ MODULE_LICENSE("GPL");
130/* Special hook for setting if_port when module is loaded */ 130/* Special hook for setting if_port when module is loaded */
131INT_MODULE_PARM(if_port, 0); 131INT_MODULE_PARM(if_port, 0);
132 132
133#ifdef PCMCIA_DEBUG
134INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG);
135#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
136static char *version =
137DRV_NAME ".c " DRV_VERSION " 2001/10/13 00:08:50 (David Hinds)";
138#else
139#define DEBUG(n, args...)
140#endif
141 133
142/*====================================================================*/ 134/*====================================================================*/
143 135
@@ -189,7 +181,7 @@ static int tc589_probe(struct pcmcia_device *link)
189 struct el3_private *lp; 181 struct el3_private *lp;
190 struct net_device *dev; 182 struct net_device *dev;
191 183
192 DEBUG(0, "3c589_attach()\n"); 184 dev_dbg(&link->dev, "3c589_attach()\n");
193 185
194 /* Create new ethernet device */ 186 /* Create new ethernet device */
195 dev = alloc_etherdev(sizeof(struct el3_private)); 187 dev = alloc_etherdev(sizeof(struct el3_private));
@@ -231,7 +223,7 @@ static void tc589_detach(struct pcmcia_device *link)
231{ 223{
232 struct net_device *dev = link->priv; 224 struct net_device *dev = link->priv;
233 225
234 DEBUG(0, "3c589_detach(0x%p)\n", link); 226 dev_dbg(&link->dev, "3c589_detach\n");
235 227
236 if (link->dev_node) 228 if (link->dev_node)
237 unregister_netdev(dev); 229 unregister_netdev(dev);
@@ -249,21 +241,18 @@ static void tc589_detach(struct pcmcia_device *link)
249 241
250======================================================================*/ 242======================================================================*/
251 243
252#define CS_CHECK(fn, ret) \
253do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
254
255static int tc589_config(struct pcmcia_device *link) 244static int tc589_config(struct pcmcia_device *link)
256{ 245{
257 struct net_device *dev = link->priv; 246 struct net_device *dev = link->priv;
258 struct el3_private *lp = netdev_priv(dev); 247 struct el3_private *lp = netdev_priv(dev);
259 __be16 *phys_addr; 248 __be16 *phys_addr;
260 int last_fn, last_ret, i, j, multi = 0, fifo; 249 int ret, i, j, multi = 0, fifo;
261 unsigned int ioaddr; 250 unsigned int ioaddr;
262 char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"}; 251 char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"};
263 u8 *buf; 252 u8 *buf;
264 size_t len; 253 size_t len;
265 254
266 DEBUG(0, "3c589_config(0x%p)\n", link); 255 dev_dbg(&link->dev, "3c589_config\n");
267 256
268 phys_addr = (__be16 *)dev->dev_addr; 257 phys_addr = (__be16 *)dev->dev_addr;
269 /* Is this a 3c562? */ 258 /* Is this a 3c562? */
@@ -281,12 +270,16 @@ static int tc589_config(struct pcmcia_device *link)
281 if (i == 0) 270 if (i == 0)
282 break; 271 break;
283 } 272 }
284 if (i != 0) { 273 if (i != 0)
285 cs_error(link, RequestIO, i);
286 goto failed; 274 goto failed;
287 } 275
288 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 276 ret = pcmcia_request_irq(link, &link->irq);
289 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 277 if (ret)
278 goto failed;
279
280 ret = pcmcia_request_configuration(link, &link->conf);
281 if (ret)
282 goto failed;
290 283
291 dev->irq = link->irq.AssignedIRQ; 284 dev->irq = link->irq.AssignedIRQ;
292 dev->base_addr = link->io.BasePort1; 285 dev->base_addr = link->io.BasePort1;
@@ -342,8 +335,6 @@ static int tc589_config(struct pcmcia_device *link)
342 if_names[dev->if_port]); 335 if_names[dev->if_port]);
343 return 0; 336 return 0;
344 337
345cs_failed:
346 cs_error(link, last_fn, last_ret);
347failed: 338failed:
348 tc589_release(link); 339 tc589_release(link);
349 return -ENODEV; 340 return -ENODEV;
@@ -506,24 +497,8 @@ static void netdev_get_drvinfo(struct net_device *dev,
506 sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr); 497 sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr);
507} 498}
508 499
509#ifdef PCMCIA_DEBUG
510static u32 netdev_get_msglevel(struct net_device *dev)
511{
512 return pc_debug;
513}
514
515static void netdev_set_msglevel(struct net_device *dev, u32 level)
516{
517 pc_debug = level;
518}
519#endif /* PCMCIA_DEBUG */
520
521static const struct ethtool_ops netdev_ethtool_ops = { 500static const struct ethtool_ops netdev_ethtool_ops = {
522 .get_drvinfo = netdev_get_drvinfo, 501 .get_drvinfo = netdev_get_drvinfo,
523#ifdef PCMCIA_DEBUG
524 .get_msglevel = netdev_get_msglevel,
525 .set_msglevel = netdev_set_msglevel,
526#endif /* PCMCIA_DEBUG */
527}; 502};
528 503
529static int el3_config(struct net_device *dev, struct ifmap *map) 504static int el3_config(struct net_device *dev, struct ifmap *map)
@@ -558,7 +533,7 @@ static int el3_open(struct net_device *dev)
558 lp->media.expires = jiffies + HZ; 533 lp->media.expires = jiffies + HZ;
559 add_timer(&lp->media); 534 add_timer(&lp->media);
560 535
561 DEBUG(1, "%s: opened, status %4.4x.\n", 536 dev_dbg(&link->dev, "%s: opened, status %4.4x.\n",
562 dev->name, inw(dev->base_addr + EL3_STATUS)); 537 dev->name, inw(dev->base_addr + EL3_STATUS));
563 538
564 return 0; 539 return 0;
@@ -591,7 +566,7 @@ static void pop_tx_status(struct net_device *dev)
591 if (tx_status & 0x30) 566 if (tx_status & 0x30)
592 tc589_wait_for_completion(dev, TxReset); 567 tc589_wait_for_completion(dev, TxReset);
593 if (tx_status & 0x38) { 568 if (tx_status & 0x38) {
594 DEBUG(1, "%s: transmit error: status 0x%02x\n", 569 pr_debug("%s: transmit error: status 0x%02x\n",
595 dev->name, tx_status); 570 dev->name, tx_status);
596 outw(TxEnable, ioaddr + EL3_CMD); 571 outw(TxEnable, ioaddr + EL3_CMD);
597 dev->stats.tx_aborted_errors++; 572 dev->stats.tx_aborted_errors++;
@@ -607,7 +582,7 @@ static netdev_tx_t el3_start_xmit(struct sk_buff *skb,
607 struct el3_private *priv = netdev_priv(dev); 582 struct el3_private *priv = netdev_priv(dev);
608 unsigned long flags; 583 unsigned long flags;
609 584
610 DEBUG(3, "%s: el3_start_xmit(length = %ld) called, " 585 pr_debug("%s: el3_start_xmit(length = %ld) called, "
611 "status %4.4x.\n", dev->name, (long)skb->len, 586 "status %4.4x.\n", dev->name, (long)skb->len,
612 inw(ioaddr + EL3_STATUS)); 587 inw(ioaddr + EL3_STATUS));
613 588
@@ -649,14 +624,14 @@ static irqreturn_t el3_interrupt(int irq, void *dev_id)
649 624
650 ioaddr = dev->base_addr; 625 ioaddr = dev->base_addr;
651 626
652 DEBUG(3, "%s: interrupt, status %4.4x.\n", 627 pr_debug("%s: interrupt, status %4.4x.\n",
653 dev->name, inw(ioaddr + EL3_STATUS)); 628 dev->name, inw(ioaddr + EL3_STATUS));
654 629
655 spin_lock(&lp->lock); 630 spin_lock(&lp->lock);
656 while ((status = inw(ioaddr + EL3_STATUS)) & 631 while ((status = inw(ioaddr + EL3_STATUS)) &
657 (IntLatch | RxComplete | StatsFull)) { 632 (IntLatch | RxComplete | StatsFull)) {
658 if ((status & 0xe000) != 0x2000) { 633 if ((status & 0xe000) != 0x2000) {
659 DEBUG(1, "%s: interrupt from dead card\n", dev->name); 634 pr_debug("%s: interrupt from dead card\n", dev->name);
660 handled = 0; 635 handled = 0;
661 break; 636 break;
662 } 637 }
@@ -665,7 +640,7 @@ static irqreturn_t el3_interrupt(int irq, void *dev_id)
665 el3_rx(dev); 640 el3_rx(dev);
666 641
667 if (status & TxAvailable) { 642 if (status & TxAvailable) {
668 DEBUG(3, " TX room bit was handled.\n"); 643 pr_debug(" TX room bit was handled.\n");
669 /* There's room in the FIFO for a full-sized packet. */ 644 /* There's room in the FIFO for a full-sized packet. */
670 outw(AckIntr | TxAvailable, ioaddr + EL3_CMD); 645 outw(AckIntr | TxAvailable, ioaddr + EL3_CMD);
671 netif_wake_queue(dev); 646 netif_wake_queue(dev);
@@ -717,7 +692,7 @@ static irqreturn_t el3_interrupt(int irq, void *dev_id)
717 692
718 lp->last_irq = jiffies; 693 lp->last_irq = jiffies;
719 spin_unlock(&lp->lock); 694 spin_unlock(&lp->lock);
720 DEBUG(3, "%s: exiting interrupt, status %4.4x.\n", 695 pr_debug("%s: exiting interrupt, status %4.4x.\n",
721 dev->name, inw(ioaddr + EL3_STATUS)); 696 dev->name, inw(ioaddr + EL3_STATUS));
722 return IRQ_RETVAL(handled); 697 return IRQ_RETVAL(handled);
723} 698}
@@ -828,7 +803,7 @@ static void update_stats(struct net_device *dev)
828{ 803{
829 unsigned int ioaddr = dev->base_addr; 804 unsigned int ioaddr = dev->base_addr;
830 805
831 DEBUG(2, "%s: updating the statistics.\n", dev->name); 806 pr_debug("%s: updating the statistics.\n", dev->name);
832 /* Turn off statistics updates while reading. */ 807 /* Turn off statistics updates while reading. */
833 outw(StatsDisable, ioaddr + EL3_CMD); 808 outw(StatsDisable, ioaddr + EL3_CMD);
834 /* Switch to the stats window, and read everything. */ 809 /* Switch to the stats window, and read everything. */
@@ -856,7 +831,7 @@ static int el3_rx(struct net_device *dev)
856 int worklimit = 32; 831 int worklimit = 32;
857 short rx_status; 832 short rx_status;
858 833
859 DEBUG(3, "%s: in rx_packet(), status %4.4x, rx_status %4.4x.\n", 834 pr_debug("%s: in rx_packet(), status %4.4x, rx_status %4.4x.\n",
860 dev->name, inw(ioaddr+EL3_STATUS), inw(ioaddr+RX_STATUS)); 835 dev->name, inw(ioaddr+EL3_STATUS), inw(ioaddr+RX_STATUS));
861 while (!((rx_status = inw(ioaddr + RX_STATUS)) & 0x8000) && 836 while (!((rx_status = inw(ioaddr + RX_STATUS)) & 0x8000) &&
862 worklimit > 0) { 837 worklimit > 0) {
@@ -878,7 +853,7 @@ static int el3_rx(struct net_device *dev)
878 853
879 skb = dev_alloc_skb(pkt_len+5); 854 skb = dev_alloc_skb(pkt_len+5);
880 855
881 DEBUG(3, " Receiving packet size %d status %4.4x.\n", 856 pr_debug(" Receiving packet size %d status %4.4x.\n",
882 pkt_len, rx_status); 857 pkt_len, rx_status);
883 if (skb != NULL) { 858 if (skb != NULL) {
884 skb_reserve(skb, 2); 859 skb_reserve(skb, 2);
@@ -889,7 +864,7 @@ static int el3_rx(struct net_device *dev)
889 dev->stats.rx_packets++; 864 dev->stats.rx_packets++;
890 dev->stats.rx_bytes += pkt_len; 865 dev->stats.rx_bytes += pkt_len;
891 } else { 866 } else {
892 DEBUG(1, "%s: couldn't allocate a sk_buff of" 867 pr_debug("%s: couldn't allocate a sk_buff of"
893 " size %d.\n", dev->name, pkt_len); 868 " size %d.\n", dev->name, pkt_len);
894 dev->stats.rx_dropped++; 869 dev->stats.rx_dropped++;
895 } 870 }
@@ -930,7 +905,7 @@ static int el3_close(struct net_device *dev)
930 struct pcmcia_device *link = lp->p_dev; 905 struct pcmcia_device *link = lp->p_dev;
931 unsigned int ioaddr = dev->base_addr; 906 unsigned int ioaddr = dev->base_addr;
932 907
933 DEBUG(1, "%s: shutting down ethercard.\n", dev->name); 908 dev_dbg(&link->dev, "%s: shutting down ethercard.\n", dev->name);
934 909
935 if (pcmcia_dev_present(link)) { 910 if (pcmcia_dev_present(link)) {
936 /* Turn off statistics ASAP. We update dev->stats below. */ 911 /* Turn off statistics ASAP. We update dev->stats below. */