Skip to content

Commit 07ca8c1

Browse files
damien-lemoalmartinkpetersen
authored andcommitted
scsi: pm8001: Introduce pm8001_handle_irq()
Factor out the common code of pm8001_interrupt_handler_msix and of pm8001_interrupt_handler_intx() into the new function pm8001_handle_irq() and use this new helper in these two functions to simplify the code. Signed-off-by: Damien Le Moal <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: Jack Wang <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 80bb942 commit 07ca8c1

File tree

1 file changed

+22
-28
lines changed

1 file changed

+22
-28
lines changed

drivers/scsi/pm8001/pm8001_init.c

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,23 @@ static void pm8001_kill_tasklet(struct pm8001_hba_info *pm8001_ha) {}
257257

258258
#endif
259259

260+
static irqreturn_t pm8001_handle_irq(struct pm8001_hba_info *pm8001_ha,
261+
int irq)
262+
{
263+
if (unlikely(!pm8001_ha))
264+
return IRQ_NONE;
265+
266+
if (!PM8001_CHIP_DISP->is_our_interrupt(pm8001_ha))
267+
return IRQ_NONE;
268+
269+
#ifdef PM8001_USE_TASKLET
270+
tasklet_schedule(&pm8001_ha->tasklet[irq]);
271+
return IRQ_HANDLED;
272+
#else
273+
return PM8001_CHIP_DISP->isr(pm8001_ha, irq);
274+
#endif
275+
}
276+
260277
/**
261278
* pm8001_interrupt_handler_msix - main MSIX interrupt handler.
262279
* It obtains the vector number and calls the equivalent bottom
@@ -267,22 +284,10 @@ static void pm8001_kill_tasklet(struct pm8001_hba_info *pm8001_ha) {}
267284
*/
268285
static irqreturn_t pm8001_interrupt_handler_msix(int irq, void *opaque)
269286
{
270-
struct isr_param *irq_vector;
271-
struct pm8001_hba_info *pm8001_ha;
272-
irqreturn_t ret = IRQ_HANDLED;
273-
irq_vector = (struct isr_param *)opaque;
274-
pm8001_ha = irq_vector->drv_inst;
287+
struct isr_param *irq_vector = (struct isr_param *)opaque;
288+
struct pm8001_hba_info *pm8001_ha = irq_vector->drv_inst;
275289

276-
if (unlikely(!pm8001_ha))
277-
return IRQ_NONE;
278-
if (!PM8001_CHIP_DISP->is_our_interrupt(pm8001_ha))
279-
return IRQ_NONE;
280-
#ifdef PM8001_USE_TASKLET
281-
tasklet_schedule(&pm8001_ha->tasklet[irq_vector->irq_id]);
282-
#else
283-
ret = PM8001_CHIP_DISP->isr(pm8001_ha, irq_vector->irq_id);
284-
#endif
285-
return ret;
290+
return pm8001_handle_irq(pm8001_ha, irq_vector->irq_id);
286291
}
287292

288293
/**
@@ -293,21 +298,10 @@ static irqreturn_t pm8001_interrupt_handler_msix(int irq, void *opaque)
293298

294299
static irqreturn_t pm8001_interrupt_handler_intx(int irq, void *dev_id)
295300
{
296-
struct pm8001_hba_info *pm8001_ha;
297-
irqreturn_t ret = IRQ_HANDLED;
298301
struct sas_ha_struct *sha = dev_id;
299-
pm8001_ha = sha->lldd_ha;
300-
if (unlikely(!pm8001_ha))
301-
return IRQ_NONE;
302-
if (!PM8001_CHIP_DISP->is_our_interrupt(pm8001_ha))
303-
return IRQ_NONE;
302+
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
304303

305-
#ifdef PM8001_USE_TASKLET
306-
tasklet_schedule(&pm8001_ha->tasklet[0]);
307-
#else
308-
ret = PM8001_CHIP_DISP->isr(pm8001_ha, 0);
309-
#endif
310-
return ret;
304+
return pm8001_handle_irq(pm8001_ha, 0);
311305
}
312306

313307
static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha);

0 commit comments

Comments
 (0)