aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/netwave_cs.c
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2009-10-24 09:53:36 -0400
committerDominik Brodowski <linux@dominikbrodowski.net>2009-11-09 02:30:02 -0500
commit2caff14713d53abba273e6095495788e2720f756 (patch)
treed22eeea544d7a746a8c107322602d0da77450dff /drivers/net/wireless/netwave_cs.c
parent624dd66957e53e15cf40e937b50597c4d41f0e99 (diff)
pcmcia: use dynamic debug infrastructure, deprecate CS_CHECK (wireless)
Convert PCMCIA drivers to use the dynamic debug infrastructure, instead of requiring manual settings of PCMCIA_DEBUG. 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: linux-wireless@vger.kernel.org CC: netdev@vger.kernel.org Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/net/wireless/netwave_cs.c')
-rw-r--r--drivers/net/wireless/netwave_cs.c88
1 files changed, 36 insertions, 52 deletions
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
index 9498b46c99a4..cbd85de0c601 100644
--- a/drivers/net/wireless/netwave_cs.c
+++ b/drivers/net/wireless/netwave_cs.c
@@ -145,23 +145,6 @@ static const unsigned int txConfEUD = 0x10; /* Enable Uni-Data packets */
145static const unsigned int txConfKey = 0x02; /* Scramble data packets */ 145static const unsigned int txConfKey = 0x02; /* Scramble data packets */
146static const unsigned int txConfLoop = 0x01; /* Loopback mode */ 146static const unsigned int txConfLoop = 0x01; /* Loopback mode */
147 147
148/*
149 All the PCMCIA modules use PCMCIA_DEBUG to control debugging. If
150 you do not define PCMCIA_DEBUG at all, all the debug code will be
151 left out. If you compile with PCMCIA_DEBUG=0, the debug code will
152 be present but disabled -- but it can then be enabled for specific
153 modules at load time with a 'pc_debug=#' option to insmod.
154*/
155
156#ifdef PCMCIA_DEBUG
157static int pc_debug = PCMCIA_DEBUG;
158module_param(pc_debug, int, 0);
159#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
160static char *version =
161"netwave_cs.c 0.3.0 Thu Jul 17 14:36:02 1997 (John Markus Bjørndalen)\n";
162#else
163#define DEBUG(n, args...)
164#endif
165 148
166/*====================================================================*/ 149/*====================================================================*/
167 150
@@ -383,7 +366,7 @@ static int netwave_probe(struct pcmcia_device *link)
383 struct net_device *dev; 366 struct net_device *dev;
384 netwave_private *priv; 367 netwave_private *priv;
385 368
386 DEBUG(0, "netwave_attach()\n"); 369 dev_dbg(&link->dev, "netwave_attach()\n");
387 370
388 /* Initialize the struct pcmcia_device structure */ 371 /* Initialize the struct pcmcia_device structure */
389 dev = alloc_etherdev(sizeof(netwave_private)); 372 dev = alloc_etherdev(sizeof(netwave_private));
@@ -438,7 +421,7 @@ static void netwave_detach(struct pcmcia_device *link)
438{ 421{
439 struct net_device *dev = link->priv; 422 struct net_device *dev = link->priv;
440 423
441 DEBUG(0, "netwave_detach(0x%p)\n", link); 424 dev_dbg(&link->dev, "netwave_detach\n");
442 425
443 netwave_release(link); 426 netwave_release(link);
444 427
@@ -725,18 +708,15 @@ static const struct iw_handler_def netwave_handler_def =
725 * 708 *
726 */ 709 */
727 710
728#define CS_CHECK(fn, ret) \
729do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
730
731static int netwave_pcmcia_config(struct pcmcia_device *link) { 711static int netwave_pcmcia_config(struct pcmcia_device *link) {
732 struct net_device *dev = link->priv; 712 struct net_device *dev = link->priv;
733 netwave_private *priv = netdev_priv(dev); 713 netwave_private *priv = netdev_priv(dev);
734 int i, j, last_ret, last_fn; 714 int i, j, ret;
735 win_req_t req; 715 win_req_t req;
736 memreq_t mem; 716 memreq_t mem;
737 u_char __iomem *ramBase = NULL; 717 u_char __iomem *ramBase = NULL;
738 718
739 DEBUG(0, "netwave_pcmcia_config(0x%p)\n", link); 719 dev_dbg(&link->dev, "netwave_pcmcia_config\n");
740 720
741 /* 721 /*
742 * Try allocating IO ports. This tries a few fixed addresses. 722 * Try allocating IO ports. This tries a few fixed addresses.
@@ -749,22 +729,24 @@ static int netwave_pcmcia_config(struct pcmcia_device *link) {
749 if (i == 0) 729 if (i == 0)
750 break; 730 break;
751 } 731 }
752 if (i != 0) { 732 if (i != 0)
753 cs_error(link, RequestIO, i);
754 goto failed; 733 goto failed;
755 }
756 734
757 /* 735 /*
758 * Now allocate an interrupt line. Note that this does not 736 * Now allocate an interrupt line. Note that this does not
759 * actually assign a handler to the interrupt. 737 * actually assign a handler to the interrupt.
760 */ 738 */
761 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 739 ret = pcmcia_request_irq(link, &link->irq);
740 if (ret)
741 goto failed;
762 742
763 /* 743 /*
764 * This actually configures the PCMCIA socket -- setting up 744 * This actually configures the PCMCIA socket -- setting up
765 * the I/O windows and the interrupt mapping. 745 * the I/O windows and the interrupt mapping.
766 */ 746 */
767 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 747 ret = pcmcia_request_configuration(link, &link->conf);
748 if (ret)
749 goto failed;
768 750
769 /* 751 /*
770 * Allocate a 32K memory window. Note that the struct pcmcia_device 752 * Allocate a 32K memory window. Note that the struct pcmcia_device
@@ -772,14 +754,18 @@ static int netwave_pcmcia_config(struct pcmcia_device *link) {
772 * device needs several windows, you'll need to keep track of 754 * device needs several windows, you'll need to keep track of
773 * the handles in your private data structure, dev->priv. 755 * the handles in your private data structure, dev->priv.
774 */ 756 */
775 DEBUG(1, "Setting mem speed of %d\n", mem_speed); 757 dev_dbg(&link->dev, "Setting mem speed of %d\n", mem_speed);
776 758
777 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_CM|WIN_ENABLE; 759 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_CM|WIN_ENABLE;
778 req.Base = 0; req.Size = 0x8000; 760 req.Base = 0; req.Size = 0x8000;
779 req.AccessSpeed = mem_speed; 761 req.AccessSpeed = mem_speed;
780 CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &link->win)); 762 ret = pcmcia_request_window(&link, &req, &link->win);
763 if (ret)
764 goto failed;
781 mem.CardOffset = 0x20000; mem.Page = 0; 765 mem.CardOffset = 0x20000; mem.Page = 0;
782 CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem)); 766 ret = pcmcia_map_mem_page(link->win, &mem);
767 if (ret)
768 goto failed;
783 769
784 /* Store base address of the common window frame */ 770 /* Store base address of the common window frame */
785 ramBase = ioremap(req.Base, 0x8000); 771 ramBase = ioremap(req.Base, 0x8000);
@@ -818,8 +804,6 @@ static int netwave_pcmcia_config(struct pcmcia_device *link) {
818 get_uint16(ramBase + NETWAVE_EREG_ARW+2)); 804 get_uint16(ramBase + NETWAVE_EREG_ARW+2));
819 return 0; 805 return 0;
820 806
821cs_failed:
822 cs_error(link, last_fn, last_ret);
823failed: 807failed:
824 netwave_release(link); 808 netwave_release(link);
825 return -ENODEV; 809 return -ENODEV;
@@ -837,7 +821,7 @@ static void netwave_release(struct pcmcia_device *link)
837 struct net_device *dev = link->priv; 821 struct net_device *dev = link->priv;
838 netwave_private *priv = netdev_priv(dev); 822 netwave_private *priv = netdev_priv(dev);
839 823
840 DEBUG(0, "netwave_release(0x%p)\n", link); 824 dev_dbg(&link->dev, "netwave_release\n");
841 825
842 pcmcia_disable_device(link); 826 pcmcia_disable_device(link);
843 if (link->win) 827 if (link->win)
@@ -892,7 +876,7 @@ static void netwave_reset(struct net_device *dev) {
892 u_char __iomem *ramBase = priv->ramBase; 876 u_char __iomem *ramBase = priv->ramBase;
893 unsigned int iobase = dev->base_addr; 877 unsigned int iobase = dev->base_addr;
894 878
895 DEBUG(0, "netwave_reset: Done with hardware reset\n"); 879 pr_debug("netwave_reset: Done with hardware reset\n");
896 880
897 priv->timeoutCounter = 0; 881 priv->timeoutCounter = 0;
898 882
@@ -988,7 +972,7 @@ static int netwave_hw_xmit(unsigned char* data, int len,
988 972
989 dev->stats.tx_bytes += len; 973 dev->stats.tx_bytes += len;
990 974
991 DEBUG(3, "Transmitting with SPCQ %x SPU %x LIF %x ISPLQ %x\n", 975 pr_debug("Transmitting with SPCQ %x SPU %x LIF %x ISPLQ %x\n",
992 readb(ramBase + NETWAVE_EREG_SPCQ), 976 readb(ramBase + NETWAVE_EREG_SPCQ),
993 readb(ramBase + NETWAVE_EREG_SPU), 977 readb(ramBase + NETWAVE_EREG_SPU),
994 readb(ramBase + NETWAVE_EREG_LIF), 978 readb(ramBase + NETWAVE_EREG_LIF),
@@ -1000,7 +984,7 @@ static int netwave_hw_xmit(unsigned char* data, int len,
1000 MaxData = get_uint16(ramBase + NETWAVE_EREG_TDP+2); 984 MaxData = get_uint16(ramBase + NETWAVE_EREG_TDP+2);
1001 DataOffset = get_uint16(ramBase + NETWAVE_EREG_TDP+4); 985 DataOffset = get_uint16(ramBase + NETWAVE_EREG_TDP+4);
1002 986
1003 DEBUG(3, "TxFreeList %x, MaxData %x, DataOffset %x\n", 987 pr_debug("TxFreeList %x, MaxData %x, DataOffset %x\n",
1004 TxFreeList, MaxData, DataOffset); 988 TxFreeList, MaxData, DataOffset);
1005 989
1006 /* Copy packet to the adapter fragment buffers */ 990 /* Copy packet to the adapter fragment buffers */
@@ -1088,7 +1072,7 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id)
1088 status = inb(iobase + NETWAVE_REG_ASR); 1072 status = inb(iobase + NETWAVE_REG_ASR);
1089 1073
1090 if (!pcmcia_dev_present(link)) { 1074 if (!pcmcia_dev_present(link)) {
1091 DEBUG(1, "netwave_interrupt: Interrupt with status 0x%x " 1075 pr_debug("netwave_interrupt: Interrupt with status 0x%x "
1092 "from removed or suspended card!\n", status); 1076 "from removed or suspended card!\n", status);
1093 break; 1077 break;
1094 } 1078 }
@@ -1132,7 +1116,7 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id)
1132 int txStatus; 1116 int txStatus;
1133 1117
1134 txStatus = readb(ramBase + NETWAVE_EREG_TSER); 1118 txStatus = readb(ramBase + NETWAVE_EREG_TSER);
1135 DEBUG(3, "Transmit done. TSER = %x id %x\n", 1119 pr_debug("Transmit done. TSER = %x id %x\n",
1136 txStatus, readb(ramBase + NETWAVE_EREG_TSER + 1)); 1120 txStatus, readb(ramBase + NETWAVE_EREG_TSER + 1));
1137 1121
1138 if (txStatus & 0x20) { 1122 if (txStatus & 0x20) {
@@ -1156,7 +1140,7 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id)
1156 * TxGU and TxNOAP is set. (Those are the only ones 1140 * TxGU and TxNOAP is set. (Those are the only ones
1157 * to set TxErr). 1141 * to set TxErr).
1158 */ 1142 */
1159 DEBUG(3, "netwave_interrupt: TxDN with error status %x\n", 1143 pr_debug("netwave_interrupt: TxDN with error status %x\n",
1160 txStatus); 1144 txStatus);
1161 1145
1162 /* Clear out TxGU, TxNOAP, TxErr and TxTrys */ 1146 /* Clear out TxGU, TxNOAP, TxErr and TxTrys */
@@ -1164,7 +1148,7 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id)
1164 writeb(0xdf & txStatus, ramBase+NETWAVE_EREG_TSER+4); 1148 writeb(0xdf & txStatus, ramBase+NETWAVE_EREG_TSER+4);
1165 ++dev->stats.tx_errors; 1149 ++dev->stats.tx_errors;
1166 } 1150 }
1167 DEBUG(3, "New status is TSER %x ASR %x\n", 1151 pr_debug("New status is TSER %x ASR %x\n",
1168 readb(ramBase + NETWAVE_EREG_TSER), 1152 readb(ramBase + NETWAVE_EREG_TSER),
1169 inb(iobase + NETWAVE_REG_ASR)); 1153 inb(iobase + NETWAVE_REG_ASR));
1170 1154
@@ -1172,7 +1156,7 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id)
1172 } 1156 }
1173 /* TxBA, this would trigger on all error packets received */ 1157 /* TxBA, this would trigger on all error packets received */
1174 /* if (status & 0x01) { 1158 /* if (status & 0x01) {
1175 DEBUG(4, "Transmit buffers available, %x\n", status); 1159 pr_debug("Transmit buffers available, %x\n", status);
1176 } 1160 }
1177 */ 1161 */
1178 } 1162 }
@@ -1190,7 +1174,7 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id)
1190 */ 1174 */
1191static void netwave_watchdog(struct net_device *dev) { 1175static void netwave_watchdog(struct net_device *dev) {
1192 1176
1193 DEBUG(1, "%s: netwave_watchdog: watchdog timer expired\n", dev->name); 1177 pr_debug("%s: netwave_watchdog: watchdog timer expired\n", dev->name);
1194 netwave_reset(dev); 1178 netwave_reset(dev);
1195 dev->trans_start = jiffies; 1179 dev->trans_start = jiffies;
1196 netif_wake_queue(dev); 1180 netif_wake_queue(dev);
@@ -1211,7 +1195,7 @@ static int netwave_rx(struct net_device *dev)
1211 int i; 1195 int i;
1212 u_char *ptr; 1196 u_char *ptr;
1213 1197
1214 DEBUG(3, "xinw_rx: Receiving ... \n"); 1198 pr_debug("xinw_rx: Receiving ... \n");
1215 1199
1216 /* Receive max 10 packets for now. */ 1200 /* Receive max 10 packets for now. */
1217 for (i = 0; i < 10; i++) { 1201 for (i = 0; i < 10; i++) {
@@ -1237,7 +1221,7 @@ static int netwave_rx(struct net_device *dev)
1237 1221
1238 skb = dev_alloc_skb(rcvLen+5); 1222 skb = dev_alloc_skb(rcvLen+5);
1239 if (skb == NULL) { 1223 if (skb == NULL) {
1240 DEBUG(1, "netwave_rx: Could not allocate an sk_buff of " 1224 pr_debug("netwave_rx: Could not allocate an sk_buff of "
1241 "length %d\n", rcvLen); 1225 "length %d\n", rcvLen);
1242 ++dev->stats.rx_dropped; 1226 ++dev->stats.rx_dropped;
1243 /* Tell the adapter to skip the packet */ 1227 /* Tell the adapter to skip the packet */
@@ -1279,7 +1263,7 @@ static int netwave_rx(struct net_device *dev)
1279 wait_WOC(iobase); 1263 wait_WOC(iobase);
1280 writeb(NETWAVE_CMD_SRP, ramBase + NETWAVE_EREG_CB + 0); 1264 writeb(NETWAVE_CMD_SRP, ramBase + NETWAVE_EREG_CB + 0);
1281 writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 1); 1265 writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 1);
1282 DEBUG(3, "Packet reception ok\n"); 1266 pr_debug("Packet reception ok\n");
1283 } 1267 }
1284 return 0; 1268 return 0;
1285} 1269}
@@ -1288,7 +1272,7 @@ static int netwave_open(struct net_device *dev) {
1288 netwave_private *priv = netdev_priv(dev); 1272 netwave_private *priv = netdev_priv(dev);
1289 struct pcmcia_device *link = priv->p_dev; 1273 struct pcmcia_device *link = priv->p_dev;
1290 1274
1291 DEBUG(1, "netwave_open: starting.\n"); 1275 dev_dbg(&link->dev, "netwave_open: starting.\n");
1292 1276
1293 if (!pcmcia_dev_present(link)) 1277 if (!pcmcia_dev_present(link))
1294 return -ENODEV; 1278 return -ENODEV;
@@ -1305,7 +1289,7 @@ static int netwave_close(struct net_device *dev) {
1305 netwave_private *priv = netdev_priv(dev); 1289 netwave_private *priv = netdev_priv(dev);
1306 struct pcmcia_device *link = priv->p_dev; 1290 struct pcmcia_device *link = priv->p_dev;
1307 1291
1308 DEBUG(1, "netwave_close: finishing.\n"); 1292 dev_dbg(&link->dev, "netwave_close: finishing.\n");
1309 1293
1310 link->open--; 1294 link->open--;
1311 netif_stop_queue(dev); 1295 netif_stop_queue(dev);
@@ -1358,11 +1342,11 @@ static void set_multicast_list(struct net_device *dev)
1358 u_char rcvMode = 0; 1342 u_char rcvMode = 0;
1359 1343
1360#ifdef PCMCIA_DEBUG 1344#ifdef PCMCIA_DEBUG
1361 if (pc_debug > 2) { 1345 {
1362 static int old; 1346 xstatic int old;
1363 if (old != dev->mc_count) { 1347 if (old != dev->mc_count) {
1364 old = dev->mc_count; 1348 old = dev->mc_count;
1365 DEBUG(0, "%s: setting Rx mode to %d addresses.\n", 1349 pr_debug("%s: setting Rx mode to %d addresses.\n",
1366 dev->name, dev->mc_count); 1350 dev->name, dev->mc_count);
1367 } 1351 }
1368 } 1352 }