Skip to content

Commit d21bfab

Browse files
damien-lemoalmartinkpetersen
authored andcommitted
scsi: pm8001: Introduce pm8001_free_irq()
Instead of repeating the same code twice in pm8001_pci_remove() and pm8001_pci_suspend() to free IRQs, introduuce the function pm8001_free_irq() to do that. 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 dae40be commit d21bfab

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

drivers/scsi/pm8001/pm8001_init.c

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ static irqreturn_t pm8001_interrupt_handler_intx(int irq, void *dev_id)
274274
}
275275

276276
static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha);
277+
static void pm8001_free_irq(struct pm8001_hba_info *pm8001_ha);
277278

278279
/**
279280
* pm8001_alloc - initiate our hba structure and 6 DMAs area.
@@ -1057,6 +1058,24 @@ static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha)
10571058
SHOST_TO_SAS_HA(pm8001_ha->shost));
10581059
}
10591060

1061+
static void pm8001_free_irq(struct pm8001_hba_info *pm8001_ha)
1062+
{
1063+
#ifdef PM8001_USE_MSIX
1064+
struct pci_dev *pdev = pm8001_ha->pdev;
1065+
int i;
1066+
1067+
for (i = 0; i < pm8001_ha->number_of_intr; i++)
1068+
synchronize_irq(pci_irq_vector(pdev, i));
1069+
1070+
for (i = 0; i < pm8001_ha->number_of_intr; i++)
1071+
free_irq(pci_irq_vector(pdev, i), &pm8001_ha->irq_vector[i]);
1072+
1073+
pci_free_irq_vectors(pdev);
1074+
#else
1075+
free_irq(pm8001_ha->irq, pm8001_ha->sas);
1076+
#endif
1077+
}
1078+
10601079
/**
10611080
* pm8001_pci_probe - probe supported device
10621081
* @pdev: pci device which kernel has been prepared for.
@@ -1252,24 +1271,17 @@ static int pm8001_init_ccb_tag(struct pm8001_hba_info *pm8001_ha)
12521271
static void pm8001_pci_remove(struct pci_dev *pdev)
12531272
{
12541273
struct sas_ha_struct *sha = pci_get_drvdata(pdev);
1255-
struct pm8001_hba_info *pm8001_ha;
1274+
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
12561275
int i, j;
1257-
pm8001_ha = sha->lldd_ha;
1276+
12581277
sas_unregister_ha(sha);
12591278
sas_remove_host(pm8001_ha->shost);
12601279
list_del(&pm8001_ha->list);
12611280
PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF);
12621281
PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha);
12631282

1264-
#ifdef PM8001_USE_MSIX
1265-
for (i = 0; i < pm8001_ha->number_of_intr; i++)
1266-
synchronize_irq(pci_irq_vector(pdev, i));
1267-
for (i = 0; i < pm8001_ha->number_of_intr; i++)
1268-
free_irq(pci_irq_vector(pdev, i), &pm8001_ha->irq_vector[i]);
1269-
pci_free_irq_vectors(pdev);
1270-
#else
1271-
free_irq(pm8001_ha->irq, sha);
1272-
#endif
1283+
pm8001_free_irq(pm8001_ha);
1284+
12731285
#ifdef PM8001_USE_TASKLET
12741286
/* For non-msix and msix interrupts */
12751287
if ((!pdev->msix_cap || !pci_msi_enabled()) ||
@@ -1309,7 +1321,8 @@ static int __maybe_unused pm8001_pci_suspend(struct device *dev)
13091321
struct pci_dev *pdev = to_pci_dev(dev);
13101322
struct sas_ha_struct *sha = pci_get_drvdata(pdev);
13111323
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
1312-
int i, j;
1324+
int j;
1325+
13131326
sas_suspend_ha(sha);
13141327
flush_workqueue(pm8001_wq);
13151328
scsi_block_requests(pm8001_ha->shost);
@@ -1319,15 +1332,9 @@ static int __maybe_unused pm8001_pci_suspend(struct device *dev)
13191332
}
13201333
PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF);
13211334
PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha);
1322-
#ifdef PM8001_USE_MSIX
1323-
for (i = 0; i < pm8001_ha->number_of_intr; i++)
1324-
synchronize_irq(pci_irq_vector(pdev, i));
1325-
for (i = 0; i < pm8001_ha->number_of_intr; i++)
1326-
free_irq(pci_irq_vector(pdev, i), &pm8001_ha->irq_vector[i]);
1327-
pci_free_irq_vectors(pdev);
1328-
#else
1329-
free_irq(pm8001_ha->irq, sha);
1330-
#endif
1335+
1336+
pm8001_free_irq(pm8001_ha);
1337+
13311338
#ifdef PM8001_USE_TASKLET
13321339
/* For non-msix and msix interrupts */
13331340
if ((!pdev->msix_cap || !pci_msi_enabled()) ||

0 commit comments

Comments
 (0)