Skip to content

Commit a081191

Browse files
damien-lemoalmartinkpetersen
authored andcommitted
scsi: pm8001: Introduce pm8001_init_tasklet()
Factor out the identical code for initializing tasklets in pm8001_pci_alloc() and pm8001_pci_resume() and instead use the new function pm8001_init_tasklet(). 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 d21bfab commit a081191

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

drivers/scsi/pm8001/pm8001_init.c

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,27 @@ static void pm8001_tasklet(unsigned long opaque)
218218
BUG_ON(1);
219219
PM8001_CHIP_DISP->isr(pm8001_ha, irq_vector->irq_id);
220220
}
221+
222+
static void pm8001_init_tasklet(struct pm8001_hba_info *pm8001_ha)
223+
{
224+
int i;
225+
226+
/* Tasklet for non msi-x interrupt handler */
227+
if ((!pm8001_ha->pdev->msix_cap || !pci_msi_enabled()) ||
228+
(pm8001_ha->chip_id == chip_8001)) {
229+
tasklet_init(&pm8001_ha->tasklet[0], pm8001_tasklet,
230+
(unsigned long)&(pm8001_ha->irq_vector[0]));
231+
return;
232+
}
233+
for (i = 0; i < PM8001_MAX_MSIX_VEC; i++)
234+
tasklet_init(&pm8001_ha->tasklet[i], pm8001_tasklet,
235+
(unsigned long)&(pm8001_ha->irq_vector[i]));
236+
}
237+
238+
#else
239+
240+
static void pm8001_init_tasklet(struct pm8001_hba_info *pm8001_ha) {}
241+
221242
#endif
222243

223244
/**
@@ -512,7 +533,6 @@ static struct pm8001_hba_info *pm8001_pci_alloc(struct pci_dev *pdev,
512533
{
513534
struct pm8001_hba_info *pm8001_ha;
514535
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
515-
int j;
516536

517537
pm8001_ha = sha->lldd_ha;
518538
if (!pm8001_ha)
@@ -543,17 +563,8 @@ static struct pm8001_hba_info *pm8001_pci_alloc(struct pci_dev *pdev,
543563
else
544564
pm8001_ha->iomb_size = IOMB_SIZE_SPC;
545565

546-
#ifdef PM8001_USE_TASKLET
547-
/* Tasklet for non msi-x interrupt handler */
548-
if ((!pdev->msix_cap || !pci_msi_enabled())
549-
|| (pm8001_ha->chip_id == chip_8001))
550-
tasklet_init(&pm8001_ha->tasklet[0], pm8001_tasklet,
551-
(unsigned long)&(pm8001_ha->irq_vector[0]));
552-
else
553-
for (j = 0; j < PM8001_MAX_MSIX_VEC; j++)
554-
tasklet_init(&pm8001_ha->tasklet[j], pm8001_tasklet,
555-
(unsigned long)&(pm8001_ha->irq_vector[j]));
556-
#endif
566+
pm8001_init_tasklet(pm8001_ha);
567+
557568
if (pm8001_ioremap(pm8001_ha))
558569
goto failed_pci_alloc;
559570
if (!pm8001_alloc(pm8001_ha, ent))
@@ -1362,7 +1373,7 @@ static int __maybe_unused pm8001_pci_resume(struct device *dev)
13621373
struct sas_ha_struct *sha = pci_get_drvdata(pdev);
13631374
struct pm8001_hba_info *pm8001_ha;
13641375
int rc;
1365-
u8 i = 0, j;
1376+
u8 i = 0;
13661377
DECLARE_COMPLETION_ONSTACK(completion);
13671378

13681379
pm8001_ha = sha->lldd_ha;
@@ -1390,17 +1401,9 @@ static int __maybe_unused pm8001_pci_resume(struct device *dev)
13901401
rc = pm8001_request_irq(pm8001_ha);
13911402
if (rc)
13921403
goto err_out_disable;
1393-
#ifdef PM8001_USE_TASKLET
1394-
/* Tasklet for non msi-x interrupt handler */
1395-
if ((!pdev->msix_cap || !pci_msi_enabled()) ||
1396-
(pm8001_ha->chip_id == chip_8001))
1397-
tasklet_init(&pm8001_ha->tasklet[0], pm8001_tasklet,
1398-
(unsigned long)&(pm8001_ha->irq_vector[0]));
1399-
else
1400-
for (j = 0; j < PM8001_MAX_MSIX_VEC; j++)
1401-
tasklet_init(&pm8001_ha->tasklet[j], pm8001_tasklet,
1402-
(unsigned long)&(pm8001_ha->irq_vector[j]));
1403-
#endif
1404+
1405+
pm8001_init_tasklet(pm8001_ha);
1406+
14041407
PM8001_CHIP_DISP->interrupt_enable(pm8001_ha, 0);
14051408
if (pm8001_ha->chip_id != chip_8001) {
14061409
for (i = 1; i < pm8001_ha->number_of_intr; i++)

0 commit comments

Comments
 (0)