Skip to content

Commit 80bb942

Browse files
damien-lemoalmartinkpetersen
authored andcommitted
scsi: pm8001: Introduce pm8001_kill_tasklet()
Factor out the identical code for killing tasklets in pm8001_pci_remove() and pm8001_pci_suspend() and instead use the new function pm8001_kill_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 a081191 commit 80bb942

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

drivers/scsi/pm8001/pm8001_init.c

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,25 @@ static void pm8001_init_tasklet(struct pm8001_hba_info *pm8001_ha)
235235
(unsigned long)&(pm8001_ha->irq_vector[i]));
236236
}
237237

238+
static void pm8001_kill_tasklet(struct pm8001_hba_info *pm8001_ha)
239+
{
240+
int i;
241+
242+
/* For non-msix and msix interrupts */
243+
if ((!pm8001_ha->pdev->msix_cap || !pci_msi_enabled()) ||
244+
(pm8001_ha->chip_id == chip_8001)) {
245+
tasklet_kill(&pm8001_ha->tasklet[0]);
246+
return;
247+
}
248+
249+
for (i = 0; i < PM8001_MAX_MSIX_VEC; i++)
250+
tasklet_kill(&pm8001_ha->tasklet[i]);
251+
}
252+
238253
#else
239254

240255
static void pm8001_init_tasklet(struct pm8001_hba_info *pm8001_ha) {}
256+
static void pm8001_kill_tasklet(struct pm8001_hba_info *pm8001_ha) {}
241257

242258
#endif
243259

@@ -1283,7 +1299,7 @@ static void pm8001_pci_remove(struct pci_dev *pdev)
12831299
{
12841300
struct sas_ha_struct *sha = pci_get_drvdata(pdev);
12851301
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
1286-
int i, j;
1302+
int i;
12871303

12881304
sas_unregister_ha(sha);
12891305
sas_remove_host(pm8001_ha->shost);
@@ -1292,16 +1308,7 @@ static void pm8001_pci_remove(struct pci_dev *pdev)
12921308
PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha);
12931309

12941310
pm8001_free_irq(pm8001_ha);
1295-
1296-
#ifdef PM8001_USE_TASKLET
1297-
/* For non-msix and msix interrupts */
1298-
if ((!pdev->msix_cap || !pci_msi_enabled()) ||
1299-
(pm8001_ha->chip_id == chip_8001))
1300-
tasklet_kill(&pm8001_ha->tasklet[0]);
1301-
else
1302-
for (j = 0; j < PM8001_MAX_MSIX_VEC; j++)
1303-
tasklet_kill(&pm8001_ha->tasklet[j]);
1304-
#endif
1311+
pm8001_kill_tasklet(pm8001_ha);
13051312
scsi_host_put(pm8001_ha->shost);
13061313

13071314
for (i = 0; i < pm8001_ha->ccb_count; i++) {
@@ -1332,7 +1339,6 @@ static int __maybe_unused pm8001_pci_suspend(struct device *dev)
13321339
struct pci_dev *pdev = to_pci_dev(dev);
13331340
struct sas_ha_struct *sha = pci_get_drvdata(pdev);
13341341
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
1335-
int j;
13361342

13371343
sas_suspend_ha(sha);
13381344
flush_workqueue(pm8001_wq);
@@ -1345,16 +1351,8 @@ static int __maybe_unused pm8001_pci_suspend(struct device *dev)
13451351
PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha);
13461352

13471353
pm8001_free_irq(pm8001_ha);
1354+
pm8001_kill_tasklet(pm8001_ha);
13481355

1349-
#ifdef PM8001_USE_TASKLET
1350-
/* For non-msix and msix interrupts */
1351-
if ((!pdev->msix_cap || !pci_msi_enabled()) ||
1352-
(pm8001_ha->chip_id == chip_8001))
1353-
tasklet_kill(&pm8001_ha->tasklet[0]);
1354-
else
1355-
for (j = 0; j < PM8001_MAX_MSIX_VEC; j++)
1356-
tasklet_kill(&pm8001_ha->tasklet[j]);
1357-
#endif
13581356
pm8001_info(pm8001_ha, "pdev=0x%p, slot=%s, entering "
13591357
"suspended state\n", pdev,
13601358
pm8001_ha->name);

0 commit comments

Comments
 (0)