Skip to content

Commit

Permalink
Various drivers' irq handlers: kill dead code, needless casts
Browse files Browse the repository at this point in the history
- Eliminate casts to/from void*

- Eliminate checks for conditions that never occur.  These typically
  fall into two classes:

	1) Checking for 'dev_id == NULL', then it is never called with
	NULL as an argument.

	2) Checking for invalid irq number, when the only caller (the
	system) guarantees the irq handler is called with the proper
	'irq' number argument.

Signed-off-by: Jeff Garzik <[email protected]>
  • Loading branch information
Jeff Garzik committed Oct 6, 2006
1 parent c31f28e commit c7bec5a
Show file tree
Hide file tree
Showing 35 changed files with 59 additions and 98 deletions.
7 changes: 1 addition & 6 deletions drivers/atm/ambassador.c
Original file line number Diff line number Diff line change
Expand Up @@ -862,15 +862,10 @@ static inline void interrupts_off (amb_dev * dev) {
/********** interrupt handling **********/

static irqreturn_t interrupt_handler(int irq, void *dev_id) {
amb_dev * dev = (amb_dev *) dev_id;
amb_dev * dev = dev_id;

PRINTD (DBG_IRQ|DBG_FLOW, "interrupt_handler: %p", dev_id);

if (!dev_id) {
PRINTD (DBG_IRQ|DBG_ERR, "irq with NULL dev_id: %d", irq);
return IRQ_NONE;
}

{
u32 interrupt = rd_plain (dev, offsetof(amb_mem, interrupt));

Expand Down
9 changes: 0 additions & 9 deletions drivers/atm/horizon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1389,15 +1389,6 @@ static irqreturn_t interrupt_handler(int irq, void *dev_id) {

PRINTD (DBG_FLOW, "interrupt_handler: %p", dev_id);

if (!dev_id) {
PRINTD (DBG_IRQ|DBG_ERR, "irq with NULL dev_id: %d", irq);
return IRQ_NONE;
}
if (irq != dev->irq) {
PRINTD (DBG_IRQ|DBG_ERR, "irq mismatch: %d", irq);
return IRQ_NONE;
}

// definitely for us
irq_ok = 0;
while ((int_source = rd_regl (dev, INT_SOURCE_REG_OFF)
Expand Down
4 changes: 1 addition & 3 deletions drivers/atm/lanai.c
Original file line number Diff line number Diff line change
Expand Up @@ -1892,11 +1892,9 @@ static inline void lanai_int_1(struct lanai_dev *lanai, u32 reason)

static irqreturn_t lanai_int(int irq, void *devid)
{
struct lanai_dev *lanai = (struct lanai_dev *) devid;
struct lanai_dev *lanai = devid;
u32 reason;

(void) irq; /* unused variables */

#ifdef USE_POWERDOWN
/*
* If we're powered down we shouldn't be generating any interrupts -
Expand Down
14 changes: 7 additions & 7 deletions drivers/block/DAC960.c
Original file line number Diff line number Diff line change
Expand Up @@ -5254,7 +5254,7 @@ static void DAC960_V2_ProcessCompletedCommand(DAC960_Command_T *Command)
static irqreturn_t DAC960_GEM_InterruptHandler(int IRQ_Channel,
void *DeviceIdentifier)
{
DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
DAC960_Controller_T *Controller = DeviceIdentifier;
void __iomem *ControllerBaseAddress = Controller->BaseAddress;
DAC960_V2_StatusMailbox_T *NextStatusMailbox;
unsigned long flags;
Expand Down Expand Up @@ -5295,7 +5295,7 @@ static irqreturn_t DAC960_GEM_InterruptHandler(int IRQ_Channel,
static irqreturn_t DAC960_BA_InterruptHandler(int IRQ_Channel,
void *DeviceIdentifier)
{
DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
DAC960_Controller_T *Controller = DeviceIdentifier;
void __iomem *ControllerBaseAddress = Controller->BaseAddress;
DAC960_V2_StatusMailbox_T *NextStatusMailbox;
unsigned long flags;
Expand Down Expand Up @@ -5337,7 +5337,7 @@ static irqreturn_t DAC960_BA_InterruptHandler(int IRQ_Channel,
static irqreturn_t DAC960_LP_InterruptHandler(int IRQ_Channel,
void *DeviceIdentifier)
{
DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
DAC960_Controller_T *Controller = DeviceIdentifier;
void __iomem *ControllerBaseAddress = Controller->BaseAddress;
DAC960_V2_StatusMailbox_T *NextStatusMailbox;
unsigned long flags;
Expand Down Expand Up @@ -5379,7 +5379,7 @@ static irqreturn_t DAC960_LP_InterruptHandler(int IRQ_Channel,
static irqreturn_t DAC960_LA_InterruptHandler(int IRQ_Channel,
void *DeviceIdentifier)
{
DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
DAC960_Controller_T *Controller = DeviceIdentifier;
void __iomem *ControllerBaseAddress = Controller->BaseAddress;
DAC960_V1_StatusMailbox_T *NextStatusMailbox;
unsigned long flags;
Expand Down Expand Up @@ -5417,7 +5417,7 @@ static irqreturn_t DAC960_LA_InterruptHandler(int IRQ_Channel,
static irqreturn_t DAC960_PG_InterruptHandler(int IRQ_Channel,
void *DeviceIdentifier)
{
DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
DAC960_Controller_T *Controller = DeviceIdentifier;
void __iomem *ControllerBaseAddress = Controller->BaseAddress;
DAC960_V1_StatusMailbox_T *NextStatusMailbox;
unsigned long flags;
Expand Down Expand Up @@ -5455,7 +5455,7 @@ static irqreturn_t DAC960_PG_InterruptHandler(int IRQ_Channel,
static irqreturn_t DAC960_PD_InterruptHandler(int IRQ_Channel,
void *DeviceIdentifier)
{
DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
DAC960_Controller_T *Controller = DeviceIdentifier;
void __iomem *ControllerBaseAddress = Controller->BaseAddress;
unsigned long flags;

Expand Down Expand Up @@ -5493,7 +5493,7 @@ static irqreturn_t DAC960_PD_InterruptHandler(int IRQ_Channel,
static irqreturn_t DAC960_P_InterruptHandler(int IRQ_Channel,
void *DeviceIdentifier)
{
DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
DAC960_Controller_T *Controller = DeviceIdentifier;
void __iomem *ControllerBaseAddress = Controller->BaseAddress;
unsigned long flags;

Expand Down
4 changes: 0 additions & 4 deletions drivers/cdrom/mcdx.c
Original file line number Diff line number Diff line change
Expand Up @@ -850,10 +850,6 @@ static irqreturn_t mcdx_intr(int irq, void *dev_id)
struct s_drive_stuff *stuffp = dev_id;
unsigned char b;

if (stuffp == NULL) {
xwarn("mcdx: no device for intr %d\n", irq);
return IRQ_NONE;
}
#ifdef AK2
if (!stuffp->busy && stuffp->pending)
stuffp->int_err = 1;
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/rio/func.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void RIOHostReset(unsigned int, struct DpRam __iomem *, unsigned int);

/* riointr.c */
void RIOTxEnable(char *);
void RIOServiceHost(struct rio_info *, struct Host *, int);
void RIOServiceHost(struct rio_info *, struct Host *);
int riotproc(struct rio_info *, struct ttystatics *, int, int);

/* rioparam.c */
Expand Down
4 changes: 2 additions & 2 deletions drivers/char/rio/rio_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ static irqreturn_t rio_interrupt(int irq, void *ptr)
struct Host *HostP;
func_enter();

HostP = (struct Host *) ptr; /* &p->RIOHosts[(long)ptr]; */
HostP = ptr; /* &p->RIOHosts[(long)ptr]; */
rio_dprintk(RIO_DEBUG_IFLOW, "rio: enter rio_interrupt (%d/%d)\n", irq, HostP->Ivec);

/* AAargh! The order in which to do these things is essential and
Expand Down Expand Up @@ -402,7 +402,7 @@ static irqreturn_t rio_interrupt(int irq, void *ptr)
return IRQ_HANDLED;
}

RIOServiceHost(p, HostP, irq);
RIOServiceHost(p, HostP);

rio_dprintk(RIO_DEBUG_IFLOW, "riointr() doing host %p type %d\n", ptr, HostP->Type);

Expand Down
2 changes: 1 addition & 1 deletion drivers/char/rio/riointr.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static int RupIntr;
static int RxIntr;
static int TxIntr;

void RIOServiceHost(struct rio_info *p, struct Host *HostP, int From)
void RIOServiceHost(struct rio_info *p, struct Host *HostP)
{
rio_spin_lock(&HostP->HostLock);
if ((HostP->Flags & RUN_STATE) != RC_RUNNING) {
Expand Down
7 changes: 3 additions & 4 deletions drivers/char/riscom8.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,11 +559,10 @@ static irqreturn_t rc_interrupt(int irq, void * dev_id)
int handled = 0;

bp = IRQ_to_board[irq];
if (!bp || !(bp->flags & RC_BOARD_ACTIVE)) {

if (!(bp->flags & RC_BOARD_ACTIVE))
return IRQ_NONE;
}


while ((++loop < 16) && ((status = ~(rc_in(bp, RC_BSR))) &
(RC_BSR_TOUT | RC_BSR_TINT |
RC_BSR_MINT | RC_BSR_RINT))) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/specialix.c
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ static irqreturn_t sx_interrupt(int irq, void *dev_id)
spin_lock_irqsave(&bp->lock, flags);

dprintk (SX_DEBUG_FLOW, "enter %s port %d room: %ld\n", __FUNCTION__, port_No(sx_get_port(bp, "INT")), SERIAL_XMIT_SIZE - sx_get_port(bp, "ITN")->xmit_cnt - 1);
if (!bp || !(bp->flags & SX_BOARD_ACTIVE)) {
if (!(bp->flags & SX_BOARD_ACTIVE)) {
dprintk (SX_DEBUG_IRQ, "sx: False interrupt. irq %d.\n", irq);
spin_unlock_irqrestore(&bp->lock, flags);
func_exit();
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/zoran_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@ zoran_irq (int irq,
struct zoran *zr;
unsigned long flags;

zr = (struct zoran *) dev_id;
zr = dev_id;
count = 0;

if (zr->testing) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/pcmcia/at91_cf.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static int at91_cf_ss_init(struct pcmcia_socket *s)

static irqreturn_t at91_cf_irq(int irq, void *_cf)
{
struct at91_cf_socket *cf = (struct at91_cf_socket *) _cf;
struct at91_cf_socket *cf = _cf;

if (irq == cf->board->det_pin) {
unsigned present = at91_cf_present(cf);
Expand Down
7 changes: 3 additions & 4 deletions drivers/pcmcia/hd64465_ss.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ static int hs_set_mem_map(struct pcmcia_socket *s, struct pccard_mem_map *mem)
*/
static int hs_irq_demux(int irq, void *dev)
{
hs_socket_t *sp = (hs_socket_t *)dev;
hs_socket_t *sp = dev;
u_int cscr;

DPRINTK("hs_irq_demux(irq=%d)\n", irq);
Expand All @@ -673,11 +673,10 @@ static int hs_irq_demux(int irq, void *dev)

static irqreturn_t hs_interrupt(int irq, void *dev)
{
hs_socket_t *sp = (hs_socket_t *)dev;
hs_socket_t *sp = dev;
u_int events = 0;
u_int cscr;



cscr = hs_in(sp, CSCR);

DPRINTK("hs_interrupt, cscr=%04x\n", cscr);
Expand Down
8 changes: 4 additions & 4 deletions drivers/scsi/NCR53c406a.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ enum Phase {
};

/* Static function prototypes */
static void NCR53c406a_intr(int, void *);
static void NCR53c406a_intr(void *);
static irqreturn_t do_NCR53c406a_intr(int, void *);
static void chip_init(void);
static void calc_port_addr(void);
Expand Down Expand Up @@ -685,7 +685,7 @@ static void wait_intr(void)
return;
}

NCR53c406a_intr(0, NULL, NULL);
NCR53c406a_intr(NULL);
}
#endif

Expand Down Expand Up @@ -767,12 +767,12 @@ static irqreturn_t do_NCR53c406a_intr(int unused, void *dev_id)
struct Scsi_Host *dev = dev_id;

spin_lock_irqsave(dev->host_lock, flags);
NCR53c406a_intr(0, dev_id);
NCR53c406a_intr(dev_id);
spin_unlock_irqrestore(dev->host_lock, flags);
return IRQ_HANDLED;
}

static void NCR53c406a_intr(int unused, void *dev_id)
static void NCR53c406a_intr(void *dev_id)
{
DEB(unsigned char fifo_size;
)
Expand Down
7 changes: 1 addition & 6 deletions drivers/scsi/aha152x.c
Original file line number Diff line number Diff line change
Expand Up @@ -759,12 +759,7 @@ static inline Scsi_Cmnd *remove_SC(Scsi_Cmnd **SC, Scsi_Cmnd *SCp)

static irqreturn_t swintr(int irqno, void *dev_id)
{
struct Scsi_Host *shpnt = (struct Scsi_Host *)dev_id;

if (!shpnt) {
printk(KERN_ERR "aha152x: catched software interrupt %d for unknown controller.\n", irqno);
return IRQ_NONE;
}
struct Scsi_Host *shpnt = dev_id;

HOSTDATA(shpnt)->swint++;

Expand Down
12 changes: 6 additions & 6 deletions drivers/scsi/aic7xxx_old.c
Original file line number Diff line number Diff line change
Expand Up @@ -6345,12 +6345,12 @@ aic7xxx_handle_command_completion_intr(struct aic7xxx_host *p)
* SCSI controller interrupt handler.
*-F*************************************************************************/
static void
aic7xxx_isr(int irq, void *dev_id)
aic7xxx_isr(void *dev_id)
{
struct aic7xxx_host *p;
unsigned char intstat;

p = (struct aic7xxx_host *)dev_id;
p = dev_id;

/*
* Just a few sanity checks. Make sure that we have an int pending.
Expand Down Expand Up @@ -6489,7 +6489,7 @@ do_aic7xxx_isr(int irq, void *dev_id)
p->flags |= AHC_IN_ISR;
do
{
aic7xxx_isr(irq, dev_id);
aic7xxx_isr(dev_id);
} while ( (aic_inb(p, INTSTAT) & INT_PEND) );
aic7xxx_done_cmds_complete(p);
aic7xxx_run_waiting_queues(p);
Expand Down Expand Up @@ -10377,7 +10377,7 @@ static int __aic7xxx_bus_device_reset(struct scsi_cmnd *cmd)

hscb = scb->hscb;

aic7xxx_isr(p->irq, (void *)p);
aic7xxx_isr(p);
aic7xxx_done_cmds_complete(p);
/* If the command was already complete or just completed, then we didn't
* do a reset, return FAILED */
Expand Down Expand Up @@ -10608,7 +10608,7 @@ static int __aic7xxx_abort(struct scsi_cmnd *cmd)
else
return FAILED;

aic7xxx_isr(p->irq, (void *)p);
aic7xxx_isr(p);
aic7xxx_done_cmds_complete(p);
/* If the command was already complete or just completed, then we didn't
* do a reset, return FAILED */
Expand Down Expand Up @@ -10863,7 +10863,7 @@ static int aic7xxx_reset(struct scsi_cmnd *cmd)

while((aic_inb(p, INTSTAT) & INT_PEND) && !(p->flags & AHC_IN_ISR))
{
aic7xxx_isr(p->irq, p);
aic7xxx_isr(p);
pause_sequencer(p);
}
aic7xxx_done_cmds_complete(p);
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/dc395x.c
Original file line number Diff line number Diff line change
Expand Up @@ -1815,7 +1815,7 @@ static void dc395x_handle_interrupt(struct AdapterCtlBlk *acb,

static irqreturn_t dc395x_interrupt(int irq, void *dev_id)
{
struct AdapterCtlBlk *acb = (struct AdapterCtlBlk *)dev_id;
struct AdapterCtlBlk *acb = dev_id;
u16 scsi_status;
u8 dma_status;
irqreturn_t handled = IRQ_NONE;
Expand Down
6 changes: 3 additions & 3 deletions drivers/scsi/qlogicfas408.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,10 @@ static unsigned int ql_pcmd(Scsi_Cmnd * cmd)
* Interrupt handler
*/

static void ql_ihandl(int irq, void *dev_id)
static void ql_ihandl(void *dev_id)
{
Scsi_Cmnd *icmd;
struct Scsi_Host *host = (struct Scsi_Host *)dev_id;
struct Scsi_Host *host = dev_id;
struct qlogicfas408_priv *priv = get_priv_by_host(host);
int qbase = priv->qbase;
REG0;
Expand Down Expand Up @@ -438,7 +438,7 @@ irqreturn_t qlogicfas408_ihandl(int irq, void *dev_id)
struct Scsi_Host *host = dev_id;

spin_lock_irqsave(host->host_lock, flags);
ql_ihandl(irq, dev_id);
ql_ihandl(dev_id);
spin_unlock_irqrestore(host->host_lock, flags);
return IRQ_HANDLED;
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/scsi/tmscsim.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,9 +700,9 @@ dc390_InvalidCmd(struct dc390_acb* pACB)


static irqreturn_t __inline__
DC390_Interrupt(int irq, void *dev_id)
DC390_Interrupt(void *dev_id)
{
struct dc390_acb *pACB = (struct dc390_acb*)dev_id;
struct dc390_acb *pACB = dev_id;
struct dc390_dcb *pDCB;
struct dc390_srb *pSRB;
u8 sstatus=0;
Expand Down Expand Up @@ -811,12 +811,12 @@ DC390_Interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
}

static irqreturn_t do_DC390_Interrupt( int irq, void *dev_id)
static irqreturn_t do_DC390_Interrupt(int irq, void *dev_id)
{
irqreturn_t ret;
DEBUG1(printk (KERN_INFO "DC390: Irq (%i) caught: ", irq));
/* Locking is done in DC390_Interrupt */
ret = DC390_Interrupt(irq, dev_id);
ret = DC390_Interrupt(dev_id);
DEBUG1(printk (".. IRQ returned\n"));
return ret;
}
Expand Down
Loading

0 comments on commit c7bec5a

Please sign in to comment.