Skip to content

Commit

Permalink
drivers/net: eliminate irq handler impossible checks, needless casts
Browse files Browse the repository at this point in the history
- 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>
  • Loading branch information
Jeff Garzik committed Oct 6, 2006
1 parent 86d91ba commit c31f28e
Show file tree
Hide file tree
Showing 37 changed files with 39 additions and 199 deletions.
7 changes: 1 addition & 6 deletions drivers/net/3c509.c
Original file line number Diff line number Diff line change
Expand Up @@ -912,16 +912,11 @@ el3_start_xmit(struct sk_buff *skb, struct net_device *dev)
static irqreturn_t
el3_interrupt(int irq, void *dev_id)
{
struct net_device *dev = (struct net_device *)dev_id;
struct net_device *dev = dev_id;
struct el3_private *lp;
int ioaddr, status;
int i = max_interrupt_work;

if (dev == NULL) {
printk ("el3_interrupt(): irq %d for unknown device.\n", irq);
return IRQ_NONE;
}

lp = netdev_priv(dev);
spin_lock(&lp->lock);

Expand Down
7 changes: 2 additions & 5 deletions drivers/net/3c523.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,14 +902,11 @@ static void *alloc_rfa(struct net_device *dev, void *ptr)
static irqreturn_t
elmc_interrupt(int irq, void *dev_id)
{
struct net_device *dev = (struct net_device *) dev_id;
struct net_device *dev = dev_id;
unsigned short stat;
struct priv *p;

if (dev == NULL) {
printk(KERN_ERR "elmc-interrupt: irq %d for unknown device.\n", irq);
return IRQ_NONE;
} else if (!netif_running(dev)) {
if (!netif_running(dev)) {
/* The 3c523 has this habit of generating interrupts during the
reset. I'm not sure if the ni52 has this same problem, but it's
really annoying if we haven't finished initializing it. I was
Expand Down
5 changes: 0 additions & 5 deletions drivers/net/3c527.c
Original file line number Diff line number Diff line change
Expand Up @@ -1324,11 +1324,6 @@ static irqreturn_t mc32_interrupt(int irq, void *dev_id)
int rx_event = 0;
int tx_event = 0;

if (dev == NULL) {
printk(KERN_WARNING "%s: irq %d for unknown device.\n", cardname, irq);
return IRQ_NONE;
}

ioaddr = dev->base_addr;
lp = netdev_priv(dev);

Expand Down
8 changes: 1 addition & 7 deletions drivers/net/8390.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,14 +406,8 @@ irqreturn_t ei_interrupt(int irq, void *dev_id)
int interrupts, nr_serviced = 0;
struct ei_device *ei_local;

if (dev == NULL)
{
printk ("net_interrupt(): irq %d for unknown device.\n", irq);
return IRQ_NONE;
}

e8390_base = dev->base_addr;
ei_local = (struct ei_device *) netdev_priv(dev);
ei_local = netdev_priv(dev);

/*
* Protect the irq test too.
Expand Down
6 changes: 1 addition & 5 deletions drivers/net/atp.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,17 +598,13 @@ static int atp_send_packet(struct sk_buff *skb, struct net_device *dev)
Handle the network interface interrupts. */
static irqreturn_t atp_interrupt(int irq, void *dev_instance)
{
struct net_device *dev = (struct net_device *)dev_instance;
struct net_device *dev = dev_instance;
struct net_local *lp;
long ioaddr;
static int num_tx_since_rx;
int boguscount = max_interrupt_work;
int handled = 0;

if (dev == NULL) {
printk(KERN_ERR "ATP_interrupt(): irq %d for unknown device.\n", irq);
return IRQ_NONE;
}
ioaddr = dev->base_addr;
lp = netdev_priv(dev);

Expand Down
6 changes: 0 additions & 6 deletions drivers/net/de600.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,6 @@ static irqreturn_t de600_interrupt(int irq, void *dev_id)
int retrig = 0;
int boguscount = 0;

/* This might just as well be deleted now, no crummy drivers present :-) */
if ((dev == NULL) || (DE600_IRQ != irq)) {
printk(KERN_ERR "%s: bogus interrupt %d\n", dev?dev->name:"DE-600", irq);
return IRQ_NONE;
}

spin_lock(&de600_lock);

select_nic();
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/declance.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,15 +696,15 @@ static void lance_tx(struct net_device *dev)

static irqreturn_t lance_dma_merr_int(const int irq, void *dev_id)
{
struct net_device *dev = (struct net_device *) dev_id;
struct net_device *dev = dev_id;

printk("%s: DMA error\n", dev->name);
return IRQ_HANDLED;
}

static irqreturn_t lance_interrupt(const int irq, void *dev_id)
{
struct net_device *dev = (struct net_device *) dev_id;
struct net_device *dev = dev_id;
struct lance_private *lp = netdev_priv(dev);
volatile struct lance_regs *ll = lp->ll;
int csr0;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/dgrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -897,8 +897,8 @@ static int dgrs_ioctl(struct net_device *devN, struct ifreq *ifr, int cmd)

static irqreturn_t dgrs_intr(int irq, void *dev_id)
{
struct net_device *dev0 = (struct net_device *) dev_id;
DGRS_PRIV *priv0 = (DGRS_PRIV *) dev0->priv;
struct net_device *dev0 = dev_id;
DGRS_PRIV *priv0 = dev0->priv;
I596_CB *cbp;
int cmd;
int i;
Expand Down
8 changes: 1 addition & 7 deletions drivers/net/eepro.c
Original file line number Diff line number Diff line change
Expand Up @@ -1198,17 +1198,11 @@ static int eepro_send_packet(struct sk_buff *skb, struct net_device *dev)
static irqreturn_t
eepro_interrupt(int irq, void *dev_id)
{
struct net_device *dev = (struct net_device *)dev_id;
/* (struct net_device *)(irq2dev_map[irq]);*/
struct net_device *dev = dev_id;
struct eepro_local *lp;
int ioaddr, status, boguscount = 20;
int handled = 0;

if (dev == NULL) {
printk (KERN_ERR "eepro_interrupt(): irq %d for unknown device.\\n", irq);
return IRQ_NONE;
}

lp = netdev_priv(dev);

spin_lock(&lp->lock);
Expand Down
7 changes: 0 additions & 7 deletions drivers/net/eexpress.c
Original file line number Diff line number Diff line change
Expand Up @@ -796,13 +796,6 @@ static irqreturn_t eexp_irq(int irq, void *dev_info)
unsigned short ioaddr,status,ack_cmd;
unsigned short old_read_ptr, old_write_ptr;

if (dev==NULL)
{
printk(KERN_WARNING "eexpress: irq %d for unknown device\n",
irq);
return IRQ_NONE;
}

lp = netdev_priv(dev);
ioaddr = dev->base_addr;

Expand Down
10 changes: 2 additions & 8 deletions drivers/net/irda/ali-ircc.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,19 +662,13 @@ static int ali_ircc_read_dongle_id (int i, chipio_t *info)
*/
static irqreturn_t ali_ircc_interrupt(int irq, void *dev_id)
{
struct net_device *dev = (struct net_device *) dev_id;
struct net_device *dev = dev_id;
struct ali_ircc_cb *self;
int ret;

IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__);

if (!dev) {
IRDA_WARNING("%s: irq %d for unknown device.\n",
ALI_IRCC_DRIVER_NAME, irq);
return IRQ_NONE;
}

self = (struct ali_ircc_cb *) dev->priv;
self = dev->priv;

spin_lock(&self->lock);

Expand Down
11 changes: 1 addition & 10 deletions drivers/net/irda/donauboe.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,12 +657,6 @@ toshoboe_makemttpacket (struct toshoboe_cb *self, void *buf, int mtt)
return xbofs;
}

static int toshoboe_invalid_dev(int irq)
{
printk (KERN_WARNING DRIVER_NAME ": irq %d for unknown device.\n", irq);
return 1;
}

#ifdef USE_PROBE
/***********************************************************************/
/* Probe code */
Expand Down Expand Up @@ -711,12 +705,9 @@ stuff_byte (__u8 byte, __u8 * buf)
static irqreturn_t
toshoboe_probeinterrupt (int irq, void *dev_id)
{
struct toshoboe_cb *self = (struct toshoboe_cb *) dev_id;
struct toshoboe_cb *self = dev_id;
__u8 irqstat;

if (self == NULL && toshoboe_invalid_dev(irq))
return IRQ_NONE;

irqstat = INB (OBOE_ISR);

/* was it us */
Expand Down
8 changes: 2 additions & 6 deletions drivers/net/irda/irport.c
Original file line number Diff line number Diff line change
Expand Up @@ -766,18 +766,14 @@ static inline void irport_receive(struct irport_cb *self)
*/
static irqreturn_t irport_interrupt(int irq, void *dev_id)
{
struct net_device *dev = (struct net_device *) dev_id;
struct net_device *dev = dev_id;
struct irport_cb *self;
int boguscount = 0;
int iobase;
int iir, lsr;
int handled = 0;

if (!dev) {
IRDA_WARNING("%s() irq %d for unknown device.\n", __FUNCTION__, irq);
return IRQ_NONE;
}
self = (struct irport_cb *) dev->priv;
self = dev->priv;

spin_lock(&self->lock);

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/irda/irport.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct irport_cb {
/* For piggyback drivers */
void *priv;
void (*change_speed)(void *priv, __u32 speed);
int (*interrupt)(int irq, void *dev_id);
irqreturn_t (*interrupt)(int irq, void *dev_id);
};

#endif /* IRPORT_H */
9 changes: 2 additions & 7 deletions drivers/net/irda/nsc-ircc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2068,17 +2068,12 @@ static void nsc_ircc_fir_interrupt(struct nsc_ircc_cb *self, int iobase,
*/
static irqreturn_t nsc_ircc_interrupt(int irq, void *dev_id)
{
struct net_device *dev = (struct net_device *) dev_id;
struct net_device *dev = dev_id;
struct nsc_ircc_cb *self;
__u8 bsr, eir;
int iobase;

if (!dev) {
IRDA_WARNING("%s: irq %d for unknown device.\n",
driver_name, irq);
return IRQ_NONE;
}
self = (struct nsc_ircc_cb *) dev->priv;
self = dev->priv;

spin_lock(&self->lock);

Expand Down
9 changes: 2 additions & 7 deletions drivers/net/irda/w83977af_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1113,17 +1113,12 @@ static __u8 w83977af_fir_interrupt(struct w83977af_ir *self, int isr)
*/
static irqreturn_t w83977af_interrupt(int irq, void *dev_id)
{
struct net_device *dev = (struct net_device *) dev_id;
struct net_device *dev = dev_id;
struct w83977af_ir *self;
__u8 set, icr, isr;
int iobase;

if (!dev) {
printk(KERN_WARNING "%s: irq %d for unknown device.\n",
driver_name, irq);
return IRQ_NONE;
}
self = (struct w83977af_ir *) dev->priv;
self = dev->priv;

iobase = self->io.fir_base;

Expand Down
5 changes: 0 additions & 5 deletions drivers/net/lance.c
Original file line number Diff line number Diff line change
Expand Up @@ -1019,11 +1019,6 @@ static irqreturn_t lance_interrupt(int irq, void *dev_id)
int csr0, ioaddr, boguscnt=10;
int must_restart;

if (dev == NULL) {
printk ("lance_interrupt(): irq %d for unknown device.\n", irq);
return IRQ_NONE;
}

ioaddr = dev->base_addr;
lp = dev->priv;

Expand Down
8 changes: 1 addition & 7 deletions drivers/net/pcmcia/axnet_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1201,14 +1201,8 @@ static irqreturn_t ax_interrupt(int irq, void *dev_id)
struct ei_device *ei_local;
int handled = 0;

if (dev == NULL)
{
printk ("net_interrupt(): irq %d for unknown device.\n", irq);
return IRQ_NONE;
}

e8390_base = dev->base_addr;
ei_local = (struct ei_device *) netdev_priv(dev);
ei_local = netdev_priv(dev);

/*
* Protect the irq test too.
Expand Down
7 changes: 0 additions & 7 deletions drivers/net/pcnet32.c
Original file line number Diff line number Diff line change
Expand Up @@ -2569,13 +2569,6 @@ pcnet32_interrupt(int irq, void *dev_id)
u16 csr0;
int boguscnt = max_interrupt_work;

if (!dev) {
if (pcnet32_debug & NETIF_MSG_INTR)
printk(KERN_DEBUG "%s(): irq %d for unknown device\n",
__FUNCTION__, irq);
return IRQ_NONE;
}

ioaddr = dev->base_addr;
lp = dev->priv;

Expand Down
5 changes: 0 additions & 5 deletions drivers/net/plip.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,11 +909,6 @@ plip_interrupt(int irq, void *dev_id)
struct plip_local *rcv;
unsigned char c0;

if (dev == NULL) {
printk(KERN_DEBUG "plip_interrupt: irq %d for unknown device.\n", irq);
return;
}

nl = netdev_priv(dev);
rcv = &nl->rcv_data;

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/saa9730.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ static int lan_saa9730_rx(struct net_device *dev)

static irqreturn_t lan_saa9730_interrupt(const int irq, void *dev_id)
{
struct net_device *dev = (struct net_device *) dev_id;
struct net_device *dev = dev_id;
struct lan_saa9730_private *lp = netdev_priv(dev);

if (lan_saa9730_debug > 5)
Expand Down
8 changes: 1 addition & 7 deletions drivers/net/sb1000.c
Original file line number Diff line number Diff line change
Expand Up @@ -1084,19 +1084,13 @@ static irqreturn_t sb1000_interrupt(int irq, void *dev_id)
char *name;
unsigned char st;
int ioaddr[2];
struct net_device *dev = (struct net_device *) dev_id;
struct net_device *dev = dev_id;
struct sb1000_private *lp = netdev_priv(dev);

const unsigned char Command0[6] = {0x80, 0x2c, 0x00, 0x00, 0x00, 0x00};
const unsigned char Command1[6] = {0x80, 0x2e, 0x00, 0x00, 0x00, 0x00};
const int MaxRxErrorCount = 6;

if (dev == NULL) {
printk(KERN_ERR "sb1000_interrupt(): irq %d for unknown device.\n",
irq);
return IRQ_NONE;
}

ioaddr[0] = dev->base_addr;
/* mem_start holds the second I/O address */
ioaddr[1] = dev->mem_start;
Expand Down
7 changes: 1 addition & 6 deletions drivers/net/skfp/skfddi.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,15 +616,10 @@ static int skfp_close(struct net_device *dev)

irqreturn_t skfp_interrupt(int irq, void *dev_id)
{
struct net_device *dev = (struct net_device *) dev_id;
struct net_device *dev = dev_id;
struct s_smc *smc; /* private board structure pointer */
skfddi_priv *bp;

if (dev == NULL) {
printk("%s: irq %d for unknown device\n", dev->name, irq);
return IRQ_NONE;
}

smc = netdev_priv(dev);
bp = &smc->os;

Expand Down
7 changes: 1 addition & 6 deletions drivers/net/sonic.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,10 @@ static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev)
*/
static irqreturn_t sonic_interrupt(int irq, void *dev_id)
{
struct net_device *dev = (struct net_device *) dev_id;
struct net_device *dev = dev_id;
struct sonic_local *lp = netdev_priv(dev);
int status;

if (dev == NULL) {
printk(KERN_ERR "sonic_interrupt: irq %d for unknown device.\n", irq);
return IRQ_NONE;
}

if (!(status = SONIC_READ(SONIC_ISR) & SONIC_IMR_DEFAULT))
return IRQ_NONE;

Expand Down
Loading

0 comments on commit c31f28e

Please sign in to comment.