Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers/net: eliminate irq handler impossible checks, needless casts

- Eliminate check for irq handler 'dev_id==NULL' where the
condition never occurs.

- Eliminate needless casts to/from void*

Signed-off-by: Jeff Garzik <jeff@garzik.org>

+39 -199
+1 -6
drivers/net/3c509.c
··· 912 912 static irqreturn_t 913 913 el3_interrupt(int irq, void *dev_id) 914 914 { 915 - struct net_device *dev = (struct net_device *)dev_id; 915 + struct net_device *dev = dev_id; 916 916 struct el3_private *lp; 917 917 int ioaddr, status; 918 918 int i = max_interrupt_work; 919 - 920 - if (dev == NULL) { 921 - printk ("el3_interrupt(): irq %d for unknown device.\n", irq); 922 - return IRQ_NONE; 923 - } 924 919 925 920 lp = netdev_priv(dev); 926 921 spin_lock(&lp->lock);
+2 -5
drivers/net/3c523.c
··· 902 902 static irqreturn_t 903 903 elmc_interrupt(int irq, void *dev_id) 904 904 { 905 - struct net_device *dev = (struct net_device *) dev_id; 905 + struct net_device *dev = dev_id; 906 906 unsigned short stat; 907 907 struct priv *p; 908 908 909 - if (dev == NULL) { 910 - printk(KERN_ERR "elmc-interrupt: irq %d for unknown device.\n", irq); 911 - return IRQ_NONE; 912 - } else if (!netif_running(dev)) { 909 + if (!netif_running(dev)) { 913 910 /* The 3c523 has this habit of generating interrupts during the 914 911 reset. I'm not sure if the ni52 has this same problem, but it's 915 912 really annoying if we haven't finished initializing it. I was
-5
drivers/net/3c527.c
··· 1324 1324 int rx_event = 0; 1325 1325 int tx_event = 0; 1326 1326 1327 - if (dev == NULL) { 1328 - printk(KERN_WARNING "%s: irq %d for unknown device.\n", cardname, irq); 1329 - return IRQ_NONE; 1330 - } 1331 - 1332 1327 ioaddr = dev->base_addr; 1333 1328 lp = netdev_priv(dev); 1334 1329
+1 -7
drivers/net/8390.c
··· 406 406 int interrupts, nr_serviced = 0; 407 407 struct ei_device *ei_local; 408 408 409 - if (dev == NULL) 410 - { 411 - printk ("net_interrupt(): irq %d for unknown device.\n", irq); 412 - return IRQ_NONE; 413 - } 414 - 415 409 e8390_base = dev->base_addr; 416 - ei_local = (struct ei_device *) netdev_priv(dev); 410 + ei_local = netdev_priv(dev); 417 411 418 412 /* 419 413 * Protect the irq test too.
+1 -5
drivers/net/atp.c
··· 598 598 Handle the network interface interrupts. */ 599 599 static irqreturn_t atp_interrupt(int irq, void *dev_instance) 600 600 { 601 - struct net_device *dev = (struct net_device *)dev_instance; 601 + struct net_device *dev = dev_instance; 602 602 struct net_local *lp; 603 603 long ioaddr; 604 604 static int num_tx_since_rx; 605 605 int boguscount = max_interrupt_work; 606 606 int handled = 0; 607 607 608 - if (dev == NULL) { 609 - printk(KERN_ERR "ATP_interrupt(): irq %d for unknown device.\n", irq); 610 - return IRQ_NONE; 611 - } 612 608 ioaddr = dev->base_addr; 613 609 lp = netdev_priv(dev); 614 610
-6
drivers/net/de600.c
··· 265 265 int retrig = 0; 266 266 int boguscount = 0; 267 267 268 - /* This might just as well be deleted now, no crummy drivers present :-) */ 269 - if ((dev == NULL) || (DE600_IRQ != irq)) { 270 - printk(KERN_ERR "%s: bogus interrupt %d\n", dev?dev->name:"DE-600", irq); 271 - return IRQ_NONE; 272 - } 273 - 274 268 spin_lock(&de600_lock); 275 269 276 270 select_nic();
+2 -2
drivers/net/declance.c
··· 696 696 697 697 static irqreturn_t lance_dma_merr_int(const int irq, void *dev_id) 698 698 { 699 - struct net_device *dev = (struct net_device *) dev_id; 699 + struct net_device *dev = dev_id; 700 700 701 701 printk("%s: DMA error\n", dev->name); 702 702 return IRQ_HANDLED; ··· 704 704 705 705 static irqreturn_t lance_interrupt(const int irq, void *dev_id) 706 706 { 707 - struct net_device *dev = (struct net_device *) dev_id; 707 + struct net_device *dev = dev_id; 708 708 struct lance_private *lp = netdev_priv(dev); 709 709 volatile struct lance_regs *ll = lp->ll; 710 710 int csr0;
+2 -2
drivers/net/dgrs.c
··· 897 897 898 898 static irqreturn_t dgrs_intr(int irq, void *dev_id) 899 899 { 900 - struct net_device *dev0 = (struct net_device *) dev_id; 901 - DGRS_PRIV *priv0 = (DGRS_PRIV *) dev0->priv; 900 + struct net_device *dev0 = dev_id; 901 + DGRS_PRIV *priv0 = dev0->priv; 902 902 I596_CB *cbp; 903 903 int cmd; 904 904 int i;
+1 -7
drivers/net/eepro.c
··· 1198 1198 static irqreturn_t 1199 1199 eepro_interrupt(int irq, void *dev_id) 1200 1200 { 1201 - struct net_device *dev = (struct net_device *)dev_id; 1202 - /* (struct net_device *)(irq2dev_map[irq]);*/ 1201 + struct net_device *dev = dev_id; 1203 1202 struct eepro_local *lp; 1204 1203 int ioaddr, status, boguscount = 20; 1205 1204 int handled = 0; 1206 - 1207 - if (dev == NULL) { 1208 - printk (KERN_ERR "eepro_interrupt(): irq %d for unknown device.\\n", irq); 1209 - return IRQ_NONE; 1210 - } 1211 1205 1212 1206 lp = netdev_priv(dev); 1213 1207
-7
drivers/net/eexpress.c
··· 796 796 unsigned short ioaddr,status,ack_cmd; 797 797 unsigned short old_read_ptr, old_write_ptr; 798 798 799 - if (dev==NULL) 800 - { 801 - printk(KERN_WARNING "eexpress: irq %d for unknown device\n", 802 - irq); 803 - return IRQ_NONE; 804 - } 805 - 806 799 lp = netdev_priv(dev); 807 800 ioaddr = dev->base_addr; 808 801
+2 -8
drivers/net/irda/ali-ircc.c
··· 662 662 */ 663 663 static irqreturn_t ali_ircc_interrupt(int irq, void *dev_id) 664 664 { 665 - struct net_device *dev = (struct net_device *) dev_id; 665 + struct net_device *dev = dev_id; 666 666 struct ali_ircc_cb *self; 667 667 int ret; 668 668 669 669 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__); 670 670 671 - if (!dev) { 672 - IRDA_WARNING("%s: irq %d for unknown device.\n", 673 - ALI_IRCC_DRIVER_NAME, irq); 674 - return IRQ_NONE; 675 - } 676 - 677 - self = (struct ali_ircc_cb *) dev->priv; 671 + self = dev->priv; 678 672 679 673 spin_lock(&self->lock); 680 674
+1 -10
drivers/net/irda/donauboe.c
··· 657 657 return xbofs; 658 658 } 659 659 660 - static int toshoboe_invalid_dev(int irq) 661 - { 662 - printk (KERN_WARNING DRIVER_NAME ": irq %d for unknown device.\n", irq); 663 - return 1; 664 - } 665 - 666 660 #ifdef USE_PROBE 667 661 /***********************************************************************/ 668 662 /* Probe code */ ··· 705 711 static irqreturn_t 706 712 toshoboe_probeinterrupt (int irq, void *dev_id) 707 713 { 708 - struct toshoboe_cb *self = (struct toshoboe_cb *) dev_id; 714 + struct toshoboe_cb *self = dev_id; 709 715 __u8 irqstat; 710 - 711 - if (self == NULL && toshoboe_invalid_dev(irq)) 712 - return IRQ_NONE; 713 716 714 717 irqstat = INB (OBOE_ISR); 715 718
+2 -6
drivers/net/irda/irport.c
··· 766 766 */ 767 767 static irqreturn_t irport_interrupt(int irq, void *dev_id) 768 768 { 769 - struct net_device *dev = (struct net_device *) dev_id; 769 + struct net_device *dev = dev_id; 770 770 struct irport_cb *self; 771 771 int boguscount = 0; 772 772 int iobase; 773 773 int iir, lsr; 774 774 int handled = 0; 775 775 776 - if (!dev) { 777 - IRDA_WARNING("%s() irq %d for unknown device.\n", __FUNCTION__, irq); 778 - return IRQ_NONE; 779 - } 780 - self = (struct irport_cb *) dev->priv; 776 + self = dev->priv; 781 777 782 778 spin_lock(&self->lock); 783 779
+1 -1
drivers/net/irda/irport.h
··· 74 74 /* For piggyback drivers */ 75 75 void *priv; 76 76 void (*change_speed)(void *priv, __u32 speed); 77 - int (*interrupt)(int irq, void *dev_id); 77 + irqreturn_t (*interrupt)(int irq, void *dev_id); 78 78 }; 79 79 80 80 #endif /* IRPORT_H */
+2 -7
drivers/net/irda/nsc-ircc.c
··· 2068 2068 */ 2069 2069 static irqreturn_t nsc_ircc_interrupt(int irq, void *dev_id) 2070 2070 { 2071 - struct net_device *dev = (struct net_device *) dev_id; 2071 + struct net_device *dev = dev_id; 2072 2072 struct nsc_ircc_cb *self; 2073 2073 __u8 bsr, eir; 2074 2074 int iobase; 2075 2075 2076 - if (!dev) { 2077 - IRDA_WARNING("%s: irq %d for unknown device.\n", 2078 - driver_name, irq); 2079 - return IRQ_NONE; 2080 - } 2081 - self = (struct nsc_ircc_cb *) dev->priv; 2076 + self = dev->priv; 2082 2077 2083 2078 spin_lock(&self->lock); 2084 2079
+2 -7
drivers/net/irda/w83977af_ir.c
··· 1113 1113 */ 1114 1114 static irqreturn_t w83977af_interrupt(int irq, void *dev_id) 1115 1115 { 1116 - struct net_device *dev = (struct net_device *) dev_id; 1116 + struct net_device *dev = dev_id; 1117 1117 struct w83977af_ir *self; 1118 1118 __u8 set, icr, isr; 1119 1119 int iobase; 1120 1120 1121 - if (!dev) { 1122 - printk(KERN_WARNING "%s: irq %d for unknown device.\n", 1123 - driver_name, irq); 1124 - return IRQ_NONE; 1125 - } 1126 - self = (struct w83977af_ir *) dev->priv; 1121 + self = dev->priv; 1127 1122 1128 1123 iobase = self->io.fir_base; 1129 1124
-5
drivers/net/lance.c
··· 1019 1019 int csr0, ioaddr, boguscnt=10; 1020 1020 int must_restart; 1021 1021 1022 - if (dev == NULL) { 1023 - printk ("lance_interrupt(): irq %d for unknown device.\n", irq); 1024 - return IRQ_NONE; 1025 - } 1026 - 1027 1022 ioaddr = dev->base_addr; 1028 1023 lp = dev->priv; 1029 1024
+1 -7
drivers/net/pcmcia/axnet_cs.c
··· 1201 1201 struct ei_device *ei_local; 1202 1202 int handled = 0; 1203 1203 1204 - if (dev == NULL) 1205 - { 1206 - printk ("net_interrupt(): irq %d for unknown device.\n", irq); 1207 - return IRQ_NONE; 1208 - } 1209 - 1210 1204 e8390_base = dev->base_addr; 1211 - ei_local = (struct ei_device *) netdev_priv(dev); 1205 + ei_local = netdev_priv(dev); 1212 1206 1213 1207 /* 1214 1208 * Protect the irq test too.
-7
drivers/net/pcnet32.c
··· 2569 2569 u16 csr0; 2570 2570 int boguscnt = max_interrupt_work; 2571 2571 2572 - if (!dev) { 2573 - if (pcnet32_debug & NETIF_MSG_INTR) 2574 - printk(KERN_DEBUG "%s(): irq %d for unknown device\n", 2575 - __FUNCTION__, irq); 2576 - return IRQ_NONE; 2577 - } 2578 - 2579 2572 ioaddr = dev->base_addr; 2580 2573 lp = dev->priv; 2581 2574
-5
drivers/net/plip.c
··· 909 909 struct plip_local *rcv; 910 910 unsigned char c0; 911 911 912 - if (dev == NULL) { 913 - printk(KERN_DEBUG "plip_interrupt: irq %d for unknown device.\n", irq); 914 - return; 915 - } 916 - 917 912 nl = netdev_priv(dev); 918 913 rcv = &nl->rcv_data; 919 914
+1 -1
drivers/net/saa9730.c
··· 747 747 748 748 static irqreturn_t lan_saa9730_interrupt(const int irq, void *dev_id) 749 749 { 750 - struct net_device *dev = (struct net_device *) dev_id; 750 + struct net_device *dev = dev_id; 751 751 struct lan_saa9730_private *lp = netdev_priv(dev); 752 752 753 753 if (lan_saa9730_debug > 5)
+1 -7
drivers/net/sb1000.c
··· 1084 1084 char *name; 1085 1085 unsigned char st; 1086 1086 int ioaddr[2]; 1087 - struct net_device *dev = (struct net_device *) dev_id; 1087 + struct net_device *dev = dev_id; 1088 1088 struct sb1000_private *lp = netdev_priv(dev); 1089 1089 1090 1090 const unsigned char Command0[6] = {0x80, 0x2c, 0x00, 0x00, 0x00, 0x00}; 1091 1091 const unsigned char Command1[6] = {0x80, 0x2e, 0x00, 0x00, 0x00, 0x00}; 1092 1092 const int MaxRxErrorCount = 6; 1093 - 1094 - if (dev == NULL) { 1095 - printk(KERN_ERR "sb1000_interrupt(): irq %d for unknown device.\n", 1096 - irq); 1097 - return IRQ_NONE; 1098 - } 1099 1093 1100 1094 ioaddr[0] = dev->base_addr; 1101 1095 /* mem_start holds the second I/O address */
+1 -6
drivers/net/skfp/skfddi.c
··· 616 616 617 617 irqreturn_t skfp_interrupt(int irq, void *dev_id) 618 618 { 619 - struct net_device *dev = (struct net_device *) dev_id; 619 + struct net_device *dev = dev_id; 620 620 struct s_smc *smc; /* private board structure pointer */ 621 621 skfddi_priv *bp; 622 - 623 - if (dev == NULL) { 624 - printk("%s: irq %d for unknown device\n", dev->name, irq); 625 - return IRQ_NONE; 626 - } 627 622 628 623 smc = netdev_priv(dev); 629 624 bp = &smc->os;
+1 -6
drivers/net/sonic.c
··· 295 295 */ 296 296 static irqreturn_t sonic_interrupt(int irq, void *dev_id) 297 297 { 298 - struct net_device *dev = (struct net_device *) dev_id; 298 + struct net_device *dev = dev_id; 299 299 struct sonic_local *lp = netdev_priv(dev); 300 300 int status; 301 - 302 - if (dev == NULL) { 303 - printk(KERN_ERR "sonic_interrupt: irq %d for unknown device.\n", irq); 304 - return IRQ_NONE; 305 - } 306 301 307 302 if (!(status = SONIC_READ(SONIC_ISR) & SONIC_IMR_DEFAULT)) 308 303 return IRQ_NONE;
+2 -2
drivers/net/sunhme.c
··· 2095 2095 2096 2096 static irqreturn_t happy_meal_interrupt(int irq, void *dev_id) 2097 2097 { 2098 - struct net_device *dev = (struct net_device *) dev_id; 2099 - struct happy_meal *hp = dev->priv; 2098 + struct net_device *dev = dev_id; 2099 + struct happy_meal *hp = netdev_priv(dev); 2100 2100 u32 happy_status = hme_read32(hp, hp->gregs + GREG_STAT); 2101 2101 2102 2102 HMD(("happy_meal_interrupt: status=%08x ", happy_status));
+1 -1
drivers/net/sunlance.c
··· 822 822 823 823 static irqreturn_t lance_interrupt(int irq, void *dev_id) 824 824 { 825 - struct net_device *dev = (struct net_device *)dev_id; 825 + struct net_device *dev = dev_id; 826 826 struct lance_private *lp = netdev_priv(dev); 827 827 int csr0; 828 828
+1 -1
drivers/net/sunqe.c
··· 468 468 */ 469 469 static irqreturn_t qec_interrupt(int irq, void *dev_id) 470 470 { 471 - struct sunqec *qecp = (struct sunqec *) dev_id; 471 + struct sunqec *qecp = dev_id; 472 472 u32 qec_status; 473 473 int channel = 0; 474 474
-7
drivers/net/tokenring/smctr.c
··· 1990 1990 __u8 isb_type, isb_subtype; 1991 1991 __u16 isb_index; 1992 1992 1993 - if(dev == NULL) 1994 - { 1995 - printk(KERN_CRIT "%s: irq %d for unknown device.\n", dev->name, irq); 1996 - return IRQ_NONE; 1997 - } 1998 - 1999 1993 ioaddr = dev->base_addr; 2000 1994 tp = netdev_priv(dev); 2001 - 2002 1995 2003 1996 if(tp->status == NOT_INITIALIZED) 2004 1997 return IRQ_NONE;
-5
drivers/net/tokenring/tms380tr.c
··· 751 751 unsigned short irq_type; 752 752 int handled = 0; 753 753 754 - if(dev == NULL) { 755 - printk(KERN_INFO "%s: irq %d for unknown device.\n", dev->name, irq); 756 - return IRQ_NONE; 757 - } 758 - 759 754 tp = netdev_priv(dev); 760 755 761 756 irq_type = SIFREADW(SIFSTS);
+1 -5
drivers/net/tulip/de4x5.c
··· 1540 1540 static irqreturn_t 1541 1541 de4x5_interrupt(int irq, void *dev_id) 1542 1542 { 1543 - struct net_device *dev = (struct net_device *)dev_id; 1543 + struct net_device *dev = dev_id; 1544 1544 struct de4x5_private *lp; 1545 1545 s32 imr, omr, sts, limit; 1546 1546 u_long iobase; 1547 1547 unsigned int handled = 0; 1548 1548 1549 - if (dev == NULL) { 1550 - printk ("de4x5_interrupt(): irq %d for unknown device.\n", irq); 1551 - return IRQ_NONE; 1552 - } 1553 1549 lp = netdev_priv(dev); 1554 1550 spin_lock(&lp->lock); 1555 1551 iobase = dev->base_addr;
+2 -2
drivers/net/wan/cycx_main.c
··· 303 303 */ 304 304 static irqreturn_t cycx_isr(int irq, void *dev_id) 305 305 { 306 - struct cycx_device *card = (struct cycx_device *)dev_id; 306 + struct cycx_device *card = dev_id; 307 307 308 - if (!card || card->wandev.state == WAN_UNCONFIGURED) 308 + if (card->wandev.state == WAN_UNCONFIGURED) 309 309 goto out; 310 310 311 311 if (card->in_isr) {
+1 -7
drivers/net/wan/sdla.c
··· 875 875 876 876 dev = dev_id; 877 877 878 - if (dev == NULL) 879 - { 880 - printk(KERN_WARNING "sdla_isr(): irq %d for unknown device.\n", irq); 881 - return IRQ_NONE; 882 - } 883 - 884 - flp = dev->priv; 878 + flp = netdev_priv(dev); 885 879 886 880 if (!flp->initialized) 887 881 {
+1 -1
drivers/net/wireless/orinoco.c
··· 1954 1954 1955 1955 irqreturn_t orinoco_interrupt(int irq, void *dev_id) 1956 1956 { 1957 - struct net_device *dev = (struct net_device *)dev_id; 1957 + struct net_device *dev = dev_id; 1958 1958 struct orinoco_private *priv = netdev_priv(dev); 1959 1959 hermes_t *hw = &priv->hw; 1960 1960 int count = MAX_IRQLOOPS_PER_IRQ;
+1 -10
drivers/net/wireless/wavelan_cs.c
··· 4119 4119 wavelan_interrupt(int irq, 4120 4120 void * dev_id) 4121 4121 { 4122 - struct net_device * dev; 4122 + struct net_device * dev = dev_id; 4123 4123 net_local * lp; 4124 4124 kio_addr_t base; 4125 4125 int status0; 4126 4126 u_int tx_status; 4127 - 4128 - if ((dev = dev_id) == NULL) 4129 - { 4130 - #ifdef DEBUG_INTERRUPT_ERROR 4131 - printk(KERN_WARNING "wavelan_interrupt(): irq %d for unknown device.\n", 4132 - irq); 4133 - #endif 4134 - return IRQ_NONE; 4135 - } 4136 4127 4137 4128 #ifdef DEBUG_INTERRUPT_TRACE 4138 4129 printk(KERN_DEBUG "%s: ->wavelan_interrupt()\n", dev->name);
+4 -11
drivers/net/wireless/wl3501_cs.c
··· 1155 1155 */ 1156 1156 static irqreturn_t wl3501_interrupt(int irq, void *dev_id) 1157 1157 { 1158 - struct net_device *dev = (struct net_device *)dev_id; 1158 + struct net_device *dev = dev_id; 1159 1159 struct wl3501_card *this; 1160 - int handled = 1; 1161 1160 1162 - if (!dev) 1163 - goto unknown; 1164 - this = dev->priv; 1161 + this = netdev_priv(dev); 1165 1162 spin_lock(&this->lock); 1166 1163 wl3501_ack_interrupt(this); 1167 1164 wl3501_block_interrupt(this); 1168 1165 wl3501_rx_interrupt(dev); 1169 1166 wl3501_unblock_interrupt(this); 1170 1167 spin_unlock(&this->lock); 1171 - out: 1172 - return IRQ_RETVAL(handled); 1173 - unknown: 1174 - handled = 0; 1175 - printk(KERN_ERR "%s: irq %d for unknown device.\n", __FUNCTION__, irq); 1176 - goto out; 1168 + 1169 + return IRQ_HANDLED; 1177 1170 } 1178 1171 1179 1172 static int wl3501_reset_board(struct wl3501_card *this)
-7
drivers/net/yellowfin.c
··· 896 896 int boguscnt = max_interrupt_work; 897 897 unsigned int handled = 0; 898 898 899 - #ifndef final_version /* Can never occur. */ 900 - if (dev == NULL) { 901 - printk (KERN_ERR "yellowfin_interrupt(): irq %d for unknown device.\n", irq); 902 - return IRQ_NONE; 903 - } 904 - #endif 905 - 906 899 yp = netdev_priv(dev); 907 900 ioaddr = yp->base; 908 901
-5
drivers/net/znet.c
··· 610 610 int boguscnt = 20; 611 611 int handled = 0; 612 612 613 - if (dev == NULL) { 614 - printk(KERN_WARNING "znet_interrupt(): IRQ %d for unknown device.\n", irq); 615 - return IRQ_NONE; 616 - } 617 - 618 613 spin_lock (&znet->lock); 619 614 620 615 ioaddr = dev->base_addr;