aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/pcmcia/fmvj18x_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/fmvj18x_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/fmvj18x_cs.c')
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c109
1 files changed, 38 insertions, 71 deletions
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index 5b73b11411c8..fdec5c333a2a 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -72,13 +72,6 @@ MODULE_LICENSE("GPL");
72/* 0:4KB*2 TX buffer else:8KB*2 TX buffer */ 72/* 0:4KB*2 TX buffer else:8KB*2 TX buffer */
73INT_MODULE_PARM(sram_config, 0); 73INT_MODULE_PARM(sram_config, 0);
74 74
75#ifdef PCMCIA_DEBUG
76INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG);
77#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
78static char *version = DRV_NAME ".c " DRV_VERSION " 2002/03/23";
79#else
80#define DEBUG(n, args...)
81#endif
82 75
83/*====================================================================*/ 76/*====================================================================*/
84/* 77/*
@@ -245,7 +238,7 @@ static int fmvj18x_probe(struct pcmcia_device *link)
245 local_info_t *lp; 238 local_info_t *lp;
246 struct net_device *dev; 239 struct net_device *dev;
247 240
248 DEBUG(0, "fmvj18x_attach()\n"); 241 dev_dbg(&link->dev, "fmvj18x_attach()\n");
249 242
250 /* Make up a FMVJ18x specific data structure */ 243 /* Make up a FMVJ18x specific data structure */
251 dev = alloc_etherdev(sizeof(local_info_t)); 244 dev = alloc_etherdev(sizeof(local_info_t));
@@ -285,7 +278,7 @@ static void fmvj18x_detach(struct pcmcia_device *link)
285{ 278{
286 struct net_device *dev = link->priv; 279 struct net_device *dev = link->priv;
287 280
288 DEBUG(0, "fmvj18x_detach(0x%p)\n", link); 281 dev_dbg(&link->dev, "fmvj18x_detach\n");
289 282
290 if (link->dev_node) 283 if (link->dev_node)
291 unregister_netdev(dev); 284 unregister_netdev(dev);
@@ -297,9 +290,6 @@ static void fmvj18x_detach(struct pcmcia_device *link)
297 290
298/*====================================================================*/ 291/*====================================================================*/
299 292
300#define CS_CHECK(fn, ret) \
301do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
302
303static int mfc_try_io_port(struct pcmcia_device *link) 293static int mfc_try_io_port(struct pcmcia_device *link)
304{ 294{
305 int i, ret; 295 int i, ret;
@@ -354,7 +344,7 @@ static int fmvj18x_config(struct pcmcia_device *link)
354{ 344{
355 struct net_device *dev = link->priv; 345 struct net_device *dev = link->priv;
356 local_info_t *lp = netdev_priv(dev); 346 local_info_t *lp = netdev_priv(dev);
357 int i, last_fn = RequestIO, last_ret = 0, ret; 347 int i, ret;
358 unsigned int ioaddr; 348 unsigned int ioaddr;
359 cardtype_t cardtype; 349 cardtype_t cardtype;
360 char *card_name = "unknown"; 350 char *card_name = "unknown";
@@ -362,16 +352,16 @@ static int fmvj18x_config(struct pcmcia_device *link)
362 size_t len; 352 size_t len;
363 u_char buggybuf[32]; 353 u_char buggybuf[32];
364 354
365 DEBUG(0, "fmvj18x_config(0x%p)\n", link); 355 dev_dbg(&link->dev, "fmvj18x_config\n");
366 356
367 len = pcmcia_get_tuple(link, CISTPL_FUNCE, &buf); 357 len = pcmcia_get_tuple(link, CISTPL_FUNCE, &buf);
368 kfree(buf); 358 kfree(buf);
369 359
370 if (len) { 360 if (len) {
371 /* Yes, I have CISTPL_FUNCE. Let's check CISTPL_MANFID */ 361 /* Yes, I have CISTPL_FUNCE. Let's check CISTPL_MANFID */
372 last_ret = pcmcia_loop_config(link, fmvj18x_ioprobe, NULL); 362 ret = pcmcia_loop_config(link, fmvj18x_ioprobe, NULL);
373 if (last_ret != 0) 363 if (ret != 0)
374 goto cs_failed; 364 goto failed;
375 365
376 switch (link->manf_id) { 366 switch (link->manf_id) {
377 case MANFID_TDK: 367 case MANFID_TDK:
@@ -440,15 +430,22 @@ static int fmvj18x_config(struct pcmcia_device *link)
440 link->irq.Attributes = 430 link->irq.Attributes =
441 IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED|IRQ_HANDLE_PRESENT; 431 IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED|IRQ_HANDLE_PRESENT;
442 ret = mfc_try_io_port(link); 432 ret = mfc_try_io_port(link);
443 if (ret != 0) goto cs_failed; 433 if (ret != 0) goto failed;
444 } else if (cardtype == UNGERMANN) { 434 } else if (cardtype == UNGERMANN) {
445 ret = ungermann_try_io_port(link); 435 ret = ungermann_try_io_port(link);
446 if (ret != 0) goto cs_failed; 436 if (ret != 0) goto failed;
447 } else { 437 } else {
448 CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); 438 ret = pcmcia_request_io(link, &link->io);
439 if (ret)
440 goto failed;
449 } 441 }
450 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 442 ret = pcmcia_request_irq(link, &link->irq);
451 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 443 if (ret)
444 goto failed;
445 ret = pcmcia_request_configuration(link, &link->conf);
446 if (ret)
447 goto failed;
448
452 dev->irq = link->irq.AssignedIRQ; 449 dev->irq = link->irq.AssignedIRQ;
453 dev->base_addr = link->io.BasePort1; 450 dev->base_addr = link->io.BasePort1;
454 451
@@ -553,9 +550,6 @@ static int fmvj18x_config(struct pcmcia_device *link)
553 550
554 return 0; 551 return 0;
555 552
556cs_failed:
557 /* All Card Services errors end up here */
558 cs_error(link, last_fn, last_ret);
559failed: 553failed:
560 fmvj18x_release(link); 554 fmvj18x_release(link);
561 return -ENODEV; 555 return -ENODEV;
@@ -574,10 +568,8 @@ static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id)
574 req.Base = 0; req.Size = 0; 568 req.Base = 0; req.Size = 0;
575 req.AccessSpeed = 0; 569 req.AccessSpeed = 0;
576 i = pcmcia_request_window(&link, &req, &link->win); 570 i = pcmcia_request_window(&link, &req, &link->win);
577 if (i != 0) { 571 if (i != 0)
578 cs_error(link, RequestWindow, i);
579 return -1; 572 return -1;
580 }
581 573
582 base = ioremap(req.Base, req.Size); 574 base = ioremap(req.Base, req.Size);
583 mem.Page = 0; 575 mem.Page = 0;
@@ -608,8 +600,6 @@ static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id)
608 600
609 iounmap(base); 601 iounmap(base);
610 j = pcmcia_release_window(link->win); 602 j = pcmcia_release_window(link->win);
611 if (j != 0)
612 cs_error(link, ReleaseWindow, j);
613 return (i != 0x200) ? 0 : -1; 603 return (i != 0x200) ? 0 : -1;
614 604
615} /* fmvj18x_get_hwinfo */ 605} /* fmvj18x_get_hwinfo */
@@ -629,10 +619,8 @@ static int fmvj18x_setup_mfc(struct pcmcia_device *link)
629 req.Base = 0; req.Size = 0; 619 req.Base = 0; req.Size = 0;
630 req.AccessSpeed = 0; 620 req.AccessSpeed = 0;
631 i = pcmcia_request_window(&link, &req, &link->win); 621 i = pcmcia_request_window(&link, &req, &link->win);
632 if (i != 0) { 622 if (i != 0)
633 cs_error(link, RequestWindow, i);
634 return -1; 623 return -1;
635 }
636 624
637 lp->base = ioremap(req.Base, req.Size); 625 lp->base = ioremap(req.Base, req.Size);
638 if (lp->base == NULL) { 626 if (lp->base == NULL) {
@@ -646,7 +634,6 @@ static int fmvj18x_setup_mfc(struct pcmcia_device *link)
646 if (i != 0) { 634 if (i != 0) {
647 iounmap(lp->base); 635 iounmap(lp->base);
648 lp->base = NULL; 636 lp->base = NULL;
649 cs_error(link, MapMemPage, i);
650 return -1; 637 return -1;
651 } 638 }
652 639
@@ -673,15 +660,13 @@ static void fmvj18x_release(struct pcmcia_device *link)
673 u_char __iomem *tmp; 660 u_char __iomem *tmp;
674 int j; 661 int j;
675 662
676 DEBUG(0, "fmvj18x_release(0x%p)\n", link); 663 dev_dbg(&link->dev, "fmvj18x_release\n");
677 664
678 if (lp->base != NULL) { 665 if (lp->base != NULL) {
679 tmp = lp->base; 666 tmp = lp->base;
680 lp->base = NULL; /* set NULL before iounmap */ 667 lp->base = NULL; /* set NULL before iounmap */
681 iounmap(tmp); 668 iounmap(tmp);
682 j = pcmcia_release_window(link->win); 669 j = pcmcia_release_window(link->win);
683 if (j != 0)
684 cs_error(link, ReleaseWindow, j);
685 } 670 }
686 671
687 pcmcia_disable_device(link); 672 pcmcia_disable_device(link);
@@ -790,8 +775,8 @@ static irqreturn_t fjn_interrupt(int dummy, void *dev_id)
790 outb(tx_stat, ioaddr + TX_STATUS); 775 outb(tx_stat, ioaddr + TX_STATUS);
791 outb(rx_stat, ioaddr + RX_STATUS); 776 outb(rx_stat, ioaddr + RX_STATUS);
792 777
793 DEBUG(4, "%s: interrupt, rx_status %02x.\n", dev->name, rx_stat); 778 pr_debug("%s: interrupt, rx_status %02x.\n", dev->name, rx_stat);
794 DEBUG(4, " tx_status %02x.\n", tx_stat); 779 pr_debug(" tx_status %02x.\n", tx_stat);
795 780
796 if (rx_stat || (inb(ioaddr + RX_MODE) & F_BUF_EMP) == 0) { 781 if (rx_stat || (inb(ioaddr + RX_MODE) & F_BUF_EMP) == 0) {
797 /* there is packet(s) in rx buffer */ 782 /* there is packet(s) in rx buffer */
@@ -811,8 +796,8 @@ static irqreturn_t fjn_interrupt(int dummy, void *dev_id)
811 } 796 }
812 netif_wake_queue(dev); 797 netif_wake_queue(dev);
813 } 798 }
814 DEBUG(4, "%s: exiting interrupt,\n", dev->name); 799 pr_debug("%s: exiting interrupt,\n", dev->name);
815 DEBUG(4, " tx_status %02x, rx_status %02x.\n", tx_stat, rx_stat); 800 pr_debug(" tx_status %02x, rx_status %02x.\n", tx_stat, rx_stat);
816 801
817 outb(D_TX_INTR, ioaddr + TX_INTR); 802 outb(D_TX_INTR, ioaddr + TX_INTR);
818 outb(D_RX_INTR, ioaddr + RX_INTR); 803 outb(D_RX_INTR, ioaddr + RX_INTR);
@@ -884,7 +869,7 @@ static netdev_tx_t fjn_start_xmit(struct sk_buff *skb,
884 return NETDEV_TX_BUSY; 869 return NETDEV_TX_BUSY;
885 } 870 }
886 871
887 DEBUG(4, "%s: Transmitting a packet of length %lu.\n", 872 pr_debug("%s: Transmitting a packet of length %lu.\n",
888 dev->name, (unsigned long)skb->len); 873 dev->name, (unsigned long)skb->len);
889 dev->stats.tx_bytes += skb->len; 874 dev->stats.tx_bytes += skb->len;
890 875
@@ -939,7 +924,7 @@ static void fjn_reset(struct net_device *dev)
939 unsigned int ioaddr = dev->base_addr; 924 unsigned int ioaddr = dev->base_addr;
940 int i; 925 int i;
941 926
942 DEBUG(4, "fjn_reset(%s) called.\n",dev->name); 927 pr_debug("fjn_reset(%s) called.\n",dev->name);
943 928
944 /* Reset controller */ 929 /* Reset controller */
945 if( sram_config == 0 ) 930 if( sram_config == 0 )
@@ -1017,13 +1002,13 @@ static void fjn_rx(struct net_device *dev)
1017 unsigned int ioaddr = dev->base_addr; 1002 unsigned int ioaddr = dev->base_addr;
1018 int boguscount = 10; /* 5 -> 10: by agy 19940922 */ 1003 int boguscount = 10; /* 5 -> 10: by agy 19940922 */
1019 1004
1020 DEBUG(4, "%s: in rx_packet(), rx_status %02x.\n", 1005 pr_debug("%s: in rx_packet(), rx_status %02x.\n",
1021 dev->name, inb(ioaddr + RX_STATUS)); 1006 dev->name, inb(ioaddr + RX_STATUS));
1022 1007
1023 while ((inb(ioaddr + RX_MODE) & F_BUF_EMP) == 0) { 1008 while ((inb(ioaddr + RX_MODE) & F_BUF_EMP) == 0) {
1024 u_short status = inw(ioaddr + DATAPORT); 1009 u_short status = inw(ioaddr + DATAPORT);
1025 1010
1026 DEBUG(4, "%s: Rxing packet mode %02x status %04x.\n", 1011 pr_debug("%s: Rxing packet mode %02x status %04x.\n",
1027 dev->name, inb(ioaddr + RX_MODE), status); 1012 dev->name, inb(ioaddr + RX_MODE), status);
1028#ifndef final_version 1013#ifndef final_version
1029 if (status == 0) { 1014 if (status == 0) {
@@ -1063,16 +1048,14 @@ static void fjn_rx(struct net_device *dev)
1063 (pkt_len + 1) >> 1); 1048 (pkt_len + 1) >> 1);
1064 skb->protocol = eth_type_trans(skb, dev); 1049 skb->protocol = eth_type_trans(skb, dev);
1065 1050
1066#ifdef PCMCIA_DEBUG 1051 {
1067 if (pc_debug > 5) {
1068 int i; 1052 int i;
1069 printk(KERN_DEBUG "%s: Rxed packet of length %d: ", 1053 pr_debug("%s: Rxed packet of length %d: ",
1070 dev->name, pkt_len); 1054 dev->name, pkt_len);
1071 for (i = 0; i < 14; i++) 1055 for (i = 0; i < 14; i++)
1072 printk(" %02x", skb->data[i]); 1056 pr_debug(" %02x", skb->data[i]);
1073 printk(".\n"); 1057 pr_debug(".\n");
1074 } 1058 }
1075#endif
1076 1059
1077 netif_rx(skb); 1060 netif_rx(skb);
1078 dev->stats.rx_packets++; 1061 dev->stats.rx_packets++;
@@ -1096,7 +1079,7 @@ static void fjn_rx(struct net_device *dev)
1096 } 1079 }
1097 1080
1098 if (i > 0) 1081 if (i > 0)
1099 DEBUG(5, "%s: Exint Rx packet with mode %02x after " 1082 pr_debug("%s: Exint Rx packet with mode %02x after "
1100 "%d ticks.\n", dev->name, inb(ioaddr + RX_MODE), i); 1083 "%d ticks.\n", dev->name, inb(ioaddr + RX_MODE), i);
1101 } 1084 }
1102*/ 1085*/
@@ -1114,24 +1097,8 @@ static void netdev_get_drvinfo(struct net_device *dev,
1114 sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr); 1097 sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr);
1115} 1098}
1116 1099
1117#ifdef PCMCIA_DEBUG
1118static u32 netdev_get_msglevel(struct net_device *dev)
1119{
1120 return pc_debug;
1121}
1122
1123static void netdev_set_msglevel(struct net_device *dev, u32 level)
1124{
1125 pc_debug = level;
1126}
1127#endif /* PCMCIA_DEBUG */
1128
1129static const struct ethtool_ops netdev_ethtool_ops = { 1100static const struct ethtool_ops netdev_ethtool_ops = {
1130 .get_drvinfo = netdev_get_drvinfo, 1101 .get_drvinfo = netdev_get_drvinfo,
1131#ifdef PCMCIA_DEBUG
1132 .get_msglevel = netdev_get_msglevel,
1133 .set_msglevel = netdev_set_msglevel,
1134#endif /* PCMCIA_DEBUG */
1135}; 1102};
1136 1103
1137static int fjn_config(struct net_device *dev, struct ifmap *map){ 1104static int fjn_config(struct net_device *dev, struct ifmap *map){
@@ -1143,7 +1110,7 @@ static int fjn_open(struct net_device *dev)
1143 struct local_info_t *lp = netdev_priv(dev); 1110 struct local_info_t *lp = netdev_priv(dev);
1144 struct pcmcia_device *link = lp->p_dev; 1111 struct pcmcia_device *link = lp->p_dev;
1145 1112
1146 DEBUG(4, "fjn_open('%s').\n", dev->name); 1113 pr_debug("fjn_open('%s').\n", dev->name);
1147 1114
1148 if (!pcmcia_dev_present(link)) 1115 if (!pcmcia_dev_present(link))
1149 return -ENODEV; 1116 return -ENODEV;
@@ -1169,7 +1136,7 @@ static int fjn_close(struct net_device *dev)
1169 struct pcmcia_device *link = lp->p_dev; 1136 struct pcmcia_device *link = lp->p_dev;
1170 unsigned int ioaddr = dev->base_addr; 1137 unsigned int ioaddr = dev->base_addr;
1171 1138
1172 DEBUG(4, "fjn_close('%s').\n", dev->name); 1139 pr_debug("fjn_close('%s').\n", dev->name);
1173 1140
1174 lp->open_time = 0; 1141 lp->open_time = 0;
1175 netif_stop_queue(dev); 1142 netif_stop_queue(dev);