aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/pcmcia/3c574_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/3c574_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/3c574_cs.c')
-rw-r--r--drivers/net/pcmcia/3c574_cs.c66
1 files changed, 29 insertions, 37 deletions
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index 6449290c62ff..dbef5d9cc9db 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -118,14 +118,6 @@ INT_MODULE_PARM(full_duplex, 0);
118/* Autodetect link polarity reversal? */ 118/* Autodetect link polarity reversal? */
119INT_MODULE_PARM(auto_polarity, 1); 119INT_MODULE_PARM(auto_polarity, 1);
120 120
121#ifdef PCMCIA_DEBUG
122INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG);
123#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
124static char *version =
125"3c574_cs.c 1.65ac1 2003/04/07 Donald Becker/David Hinds, becker@scyld.com.\n";
126#else
127#define DEBUG(n, args...)
128#endif
129 121
130/*====================================================================*/ 122/*====================================================================*/
131 123
@@ -278,7 +270,7 @@ static int tc574_probe(struct pcmcia_device *link)
278 struct el3_private *lp; 270 struct el3_private *lp;
279 struct net_device *dev; 271 struct net_device *dev;
280 272
281 DEBUG(0, "3c574_attach()\n"); 273 dev_dbg(&link->dev, "3c574_attach()\n");
282 274
283 /* Create the PC card device object. */ 275 /* Create the PC card device object. */
284 dev = alloc_etherdev(sizeof(struct el3_private)); 276 dev = alloc_etherdev(sizeof(struct el3_private));
@@ -319,7 +311,7 @@ static void tc574_detach(struct pcmcia_device *link)
319{ 311{
320 struct net_device *dev = link->priv; 312 struct net_device *dev = link->priv;
321 313
322 DEBUG(0, "3c574_detach(0x%p)\n", link); 314 dev_dbg(&link->dev, "3c574_detach()\n");
323 315
324 if (link->dev_node) 316 if (link->dev_node)
325 unregister_netdev(dev); 317 unregister_netdev(dev);
@@ -335,16 +327,13 @@ static void tc574_detach(struct pcmcia_device *link)
335 ethernet device available to the system. 327 ethernet device available to the system.
336*/ 328*/
337 329
338#define CS_CHECK(fn, ret) \
339 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
340
341static const char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"}; 330static const char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"};
342 331
343static int tc574_config(struct pcmcia_device *link) 332static int tc574_config(struct pcmcia_device *link)
344{ 333{
345 struct net_device *dev = link->priv; 334 struct net_device *dev = link->priv;
346 struct el3_private *lp = netdev_priv(dev); 335 struct el3_private *lp = netdev_priv(dev);
347 int last_fn, last_ret, i, j; 336 int ret, i, j;
348 unsigned int ioaddr; 337 unsigned int ioaddr;
349 __be16 *phys_addr; 338 __be16 *phys_addr;
350 char *cardname; 339 char *cardname;
@@ -354,7 +343,7 @@ static int tc574_config(struct pcmcia_device *link)
354 343
355 phys_addr = (__be16 *)dev->dev_addr; 344 phys_addr = (__be16 *)dev->dev_addr;
356 345
357 DEBUG(0, "3c574_config(0x%p)\n", link); 346 dev_dbg(&link->dev, "3c574_config()\n");
358 347
359 link->io.IOAddrLines = 16; 348 link->io.IOAddrLines = 16;
360 for (i = j = 0; j < 0x400; j += 0x20) { 349 for (i = j = 0; j < 0x400; j += 0x20) {
@@ -363,12 +352,16 @@ static int tc574_config(struct pcmcia_device *link)
363 if (i == 0) 352 if (i == 0)
364 break; 353 break;
365 } 354 }
366 if (i != 0) { 355 if (i != 0)
367 cs_error(link, RequestIO, i); 356 goto failed;
357
358 ret = pcmcia_request_irq(link, &link->irq);
359 if (ret)
360 goto failed;
361
362 ret = pcmcia_request_configuration(link, &link->conf);
363 if (ret)
368 goto failed; 364 goto failed;
369 }
370 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
371 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
372 365
373 dev->irq = link->irq.AssignedIRQ; 366 dev->irq = link->irq.AssignedIRQ;
374 dev->base_addr = link->io.BasePort1; 367 dev->base_addr = link->io.BasePort1;
@@ -433,7 +426,8 @@ static int tc574_config(struct pcmcia_device *link)
433 mii_status = mdio_read(ioaddr, phy & 0x1f, 1); 426 mii_status = mdio_read(ioaddr, phy & 0x1f, 1);
434 if (mii_status != 0xffff) { 427 if (mii_status != 0xffff) {
435 lp->phys = phy & 0x1f; 428 lp->phys = phy & 0x1f;
436 DEBUG(0, " MII transceiver at index %d, status %x.\n", 429 dev_dbg(&link->dev, " MII transceiver at "
430 "index %d, status %x.\n",
437 phy, mii_status); 431 phy, mii_status);
438 if ((mii_status & 0x0040) == 0) 432 if ((mii_status & 0x0040) == 0)
439 mii_preamble_required = 1; 433 mii_preamble_required = 1;
@@ -476,8 +470,6 @@ static int tc574_config(struct pcmcia_device *link)
476 470
477 return 0; 471 return 0;
478 472
479cs_failed:
480 cs_error(link, last_fn, last_ret);
481failed: 473failed:
482 tc574_release(link); 474 tc574_release(link);
483 return -ENODEV; 475 return -ENODEV;
@@ -736,7 +728,7 @@ static int el3_open(struct net_device *dev)
736 lp->media.expires = jiffies + HZ; 728 lp->media.expires = jiffies + HZ;
737 add_timer(&lp->media); 729 add_timer(&lp->media);
738 730
739 DEBUG(2, "%s: opened, status %4.4x.\n", 731 dev_dbg(&link->dev, "%s: opened, status %4.4x.\n",
740 dev->name, inw(dev->base_addr + EL3_STATUS)); 732 dev->name, inw(dev->base_addr + EL3_STATUS));
741 733
742 return 0; 734 return 0;
@@ -770,7 +762,7 @@ static void pop_tx_status(struct net_device *dev)
770 if (tx_status & 0x30) 762 if (tx_status & 0x30)
771 tc574_wait_for_completion(dev, TxReset); 763 tc574_wait_for_completion(dev, TxReset);
772 if (tx_status & 0x38) { 764 if (tx_status & 0x38) {
773 DEBUG(1, "%s: transmit error: status 0x%02x\n", 765 pr_debug("%s: transmit error: status 0x%02x\n",
774 dev->name, tx_status); 766 dev->name, tx_status);
775 outw(TxEnable, ioaddr + EL3_CMD); 767 outw(TxEnable, ioaddr + EL3_CMD);
776 dev->stats.tx_aborted_errors++; 768 dev->stats.tx_aborted_errors++;
@@ -786,7 +778,7 @@ static netdev_tx_t el3_start_xmit(struct sk_buff *skb,
786 struct el3_private *lp = netdev_priv(dev); 778 struct el3_private *lp = netdev_priv(dev);
787 unsigned long flags; 779 unsigned long flags;
788 780
789 DEBUG(3, "%s: el3_start_xmit(length = %ld) called, " 781 pr_debug("%s: el3_start_xmit(length = %ld) called, "
790 "status %4.4x.\n", dev->name, (long)skb->len, 782 "status %4.4x.\n", dev->name, (long)skb->len,
791 inw(ioaddr + EL3_STATUS)); 783 inw(ioaddr + EL3_STATUS));
792 784
@@ -825,7 +817,7 @@ static irqreturn_t el3_interrupt(int irq, void *dev_id)
825 return IRQ_NONE; 817 return IRQ_NONE;
826 ioaddr = dev->base_addr; 818 ioaddr = dev->base_addr;
827 819
828 DEBUG(3, "%s: interrupt, status %4.4x.\n", 820 pr_debug("%s: interrupt, status %4.4x.\n",
829 dev->name, inw(ioaddr + EL3_STATUS)); 821 dev->name, inw(ioaddr + EL3_STATUS));
830 822
831 spin_lock(&lp->window_lock); 823 spin_lock(&lp->window_lock);
@@ -834,7 +826,7 @@ static irqreturn_t el3_interrupt(int irq, void *dev_id)
834 (IntLatch | RxComplete | RxEarly | StatsFull)) { 826 (IntLatch | RxComplete | RxEarly | StatsFull)) {
835 if (!netif_device_present(dev) || 827 if (!netif_device_present(dev) ||
836 ((status & 0xe000) != 0x2000)) { 828 ((status & 0xe000) != 0x2000)) {
837 DEBUG(1, "%s: Interrupt from dead card\n", dev->name); 829 pr_debug("%s: Interrupt from dead card\n", dev->name);
838 break; 830 break;
839 } 831 }
840 832
@@ -844,7 +836,7 @@ static irqreturn_t el3_interrupt(int irq, void *dev_id)
844 work_budget = el3_rx(dev, work_budget); 836 work_budget = el3_rx(dev, work_budget);
845 837
846 if (status & TxAvailable) { 838 if (status & TxAvailable) {
847 DEBUG(3, " TX room bit was handled.\n"); 839 pr_debug(" TX room bit was handled.\n");
848 /* There's room in the FIFO for a full-sized packet. */ 840 /* There's room in the FIFO for a full-sized packet. */
849 outw(AckIntr | TxAvailable, ioaddr + EL3_CMD); 841 outw(AckIntr | TxAvailable, ioaddr + EL3_CMD);
850 netif_wake_queue(dev); 842 netif_wake_queue(dev);
@@ -884,7 +876,7 @@ static irqreturn_t el3_interrupt(int irq, void *dev_id)
884 } 876 }
885 877
886 if (--work_budget < 0) { 878 if (--work_budget < 0) {
887 DEBUG(0, "%s: Too much work in interrupt, " 879 pr_debug("%s: Too much work in interrupt, "
888 "status %4.4x.\n", dev->name, status); 880 "status %4.4x.\n", dev->name, status);
889 /* Clear all interrupts */ 881 /* Clear all interrupts */
890 outw(AckIntr | 0xFF, ioaddr + EL3_CMD); 882 outw(AckIntr | 0xFF, ioaddr + EL3_CMD);
@@ -894,7 +886,7 @@ static irqreturn_t el3_interrupt(int irq, void *dev_id)
894 outw(AckIntr | IntReq | IntLatch, ioaddr + EL3_CMD); 886 outw(AckIntr | IntReq | IntLatch, ioaddr + EL3_CMD);
895 } 887 }
896 888
897 DEBUG(3, "%s: exiting interrupt, status %4.4x.\n", 889 pr_debug("%s: exiting interrupt, status %4.4x.\n",
898 dev->name, inw(ioaddr + EL3_STATUS)); 890 dev->name, inw(ioaddr + EL3_STATUS));
899 891
900 spin_unlock(&lp->window_lock); 892 spin_unlock(&lp->window_lock);
@@ -1001,7 +993,7 @@ static void update_stats(struct net_device *dev)
1001 unsigned int ioaddr = dev->base_addr; 993 unsigned int ioaddr = dev->base_addr;
1002 u8 rx, tx, up; 994 u8 rx, tx, up;
1003 995
1004 DEBUG(2, "%s: updating the statistics.\n", dev->name); 996 pr_debug("%s: updating the statistics.\n", dev->name);
1005 997
1006 if (inw(ioaddr+EL3_STATUS) == 0xffff) /* No card. */ 998 if (inw(ioaddr+EL3_STATUS) == 0xffff) /* No card. */
1007 return; 999 return;
@@ -1037,7 +1029,7 @@ static int el3_rx(struct net_device *dev, int worklimit)
1037 unsigned int ioaddr = dev->base_addr; 1029 unsigned int ioaddr = dev->base_addr;
1038 short rx_status; 1030 short rx_status;
1039 1031
1040 DEBUG(3, "%s: in rx_packet(), status %4.4x, rx_status %4.4x.\n", 1032 pr_debug("%s: in rx_packet(), status %4.4x, rx_status %4.4x.\n",
1041 dev->name, inw(ioaddr+EL3_STATUS), inw(ioaddr+RxStatus)); 1033 dev->name, inw(ioaddr+EL3_STATUS), inw(ioaddr+RxStatus));
1042 while (!((rx_status = inw(ioaddr + RxStatus)) & 0x8000) && 1034 while (!((rx_status = inw(ioaddr + RxStatus)) & 0x8000) &&
1043 worklimit > 0) { 1035 worklimit > 0) {
@@ -1059,7 +1051,7 @@ static int el3_rx(struct net_device *dev, int worklimit)
1059 1051
1060 skb = dev_alloc_skb(pkt_len+5); 1052 skb = dev_alloc_skb(pkt_len+5);
1061 1053
1062 DEBUG(3, " Receiving packet size %d status %4.4x.\n", 1054 pr_debug(" Receiving packet size %d status %4.4x.\n",
1063 pkt_len, rx_status); 1055 pkt_len, rx_status);
1064 if (skb != NULL) { 1056 if (skb != NULL) {
1065 skb_reserve(skb, 2); 1057 skb_reserve(skb, 2);
@@ -1070,7 +1062,7 @@ static int el3_rx(struct net_device *dev, int worklimit)
1070 dev->stats.rx_packets++; 1062 dev->stats.rx_packets++;
1071 dev->stats.rx_bytes += pkt_len; 1063 dev->stats.rx_bytes += pkt_len;
1072 } else { 1064 } else {
1073 DEBUG(1, "%s: couldn't allocate a sk_buff of" 1065 pr_debug("%s: couldn't allocate a sk_buff of"
1074 " size %d.\n", dev->name, pkt_len); 1066 " size %d.\n", dev->name, pkt_len);
1075 dev->stats.rx_dropped++; 1067 dev->stats.rx_dropped++;
1076 } 1068 }
@@ -1099,7 +1091,7 @@ static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1099 struct mii_ioctl_data *data = if_mii(rq); 1091 struct mii_ioctl_data *data = if_mii(rq);
1100 int phy = lp->phys & 0x1f; 1092 int phy = lp->phys & 0x1f;
1101 1093
1102 DEBUG(2, "%s: In ioct(%-.6s, %#4.4x) %4.4x %4.4x %4.4x %4.4x.\n", 1094 pr_debug("%s: In ioct(%-.6s, %#4.4x) %4.4x %4.4x %4.4x %4.4x.\n",
1103 dev->name, rq->ifr_ifrn.ifrn_name, cmd, 1095 dev->name, rq->ifr_ifrn.ifrn_name, cmd,
1104 data->phy_id, data->reg_num, data->val_in, data->val_out); 1096 data->phy_id, data->reg_num, data->val_in, data->val_out);
1105 1097
@@ -1176,7 +1168,7 @@ static int el3_close(struct net_device *dev)
1176 struct el3_private *lp = netdev_priv(dev); 1168 struct el3_private *lp = netdev_priv(dev);
1177 struct pcmcia_device *link = lp->p_dev; 1169 struct pcmcia_device *link = lp->p_dev;
1178 1170
1179 DEBUG(2, "%s: shutting down ethercard.\n", dev->name); 1171 dev_dbg(&link->dev, "%s: shutting down ethercard.\n", dev->name);
1180 1172
1181 if (pcmcia_dev_present(link)) { 1173 if (pcmcia_dev_present(link)) {
1182 unsigned long flags; 1174 unsigned long flags;