From: Damien Le Moal <dlemoal@kernel.org>
To: "Martin K . Petersen" <martin.petersen@oracle.com>,
linux-scsi@vger.kernel.org
Cc: Jack Wang <jinpu.wang@ionos.com>
Subject: [PATCH 02/10] scsi: pm8001: Introduce pm8001_free_irq()
Date: Mon, 11 Sep 2023 12:01:59 +0900 [thread overview]
Message-ID: <20230911030207.242917-3-dlemoal@kernel.org> (raw)
In-Reply-To: <20230911030207.242917-1-dlemoal@kernel.org>
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 <dlemoal@kernel.org>
---
drivers/scsi/pm8001/pm8001_init.c | 49 ++++++++++++++++++-------------
1 file changed, 28 insertions(+), 21 deletions(-)
diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
index 443a3176c6c0..3b7d47cd70ba 100644
--- a/drivers/scsi/pm8001/pm8001_init.c
+++ b/drivers/scsi/pm8001/pm8001_init.c
@@ -274,6 +274,7 @@ static irqreturn_t pm8001_interrupt_handler_intx(int irq, void *dev_id)
}
static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha);
+static void pm8001_free_irq(struct pm8001_hba_info *pm8001_ha);
/**
* 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)
SHOST_TO_SAS_HA(pm8001_ha->shost));
}
+static void pm8001_free_irq(struct pm8001_hba_info *pm8001_ha)
+{
+#ifdef PM8001_USE_MSIX
+ struct pci_dev *pdev = pm8001_ha->pdev;
+ int i;
+
+ for (i = 0; i < pm8001_ha->number_of_intr; i++)
+ synchronize_irq(pci_irq_vector(pdev, i));
+
+ for (i = 0; i < pm8001_ha->number_of_intr; i++)
+ free_irq(pci_irq_vector(pdev, i), &pm8001_ha->irq_vector[i]);
+
+ pci_free_irq_vectors(pdev);
+#else
+ free_irq(pm8001_ha->irq, pm8001_ha->sas);
+#endif
+}
+
/**
* pm8001_pci_probe - probe supported device
* @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)
static void pm8001_pci_remove(struct pci_dev *pdev)
{
struct sas_ha_struct *sha = pci_get_drvdata(pdev);
- struct pm8001_hba_info *pm8001_ha;
+ struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
int i, j;
- pm8001_ha = sha->lldd_ha;
+
sas_unregister_ha(sha);
sas_remove_host(pm8001_ha->shost);
list_del(&pm8001_ha->list);
PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF);
PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha);
-#ifdef PM8001_USE_MSIX
- for (i = 0; i < pm8001_ha->number_of_intr; i++)
- synchronize_irq(pci_irq_vector(pdev, i));
- for (i = 0; i < pm8001_ha->number_of_intr; i++)
- free_irq(pci_irq_vector(pdev, i), &pm8001_ha->irq_vector[i]);
- pci_free_irq_vectors(pdev);
-#else
- free_irq(pm8001_ha->irq, sha);
-#endif
+ pm8001_free_irq(pm8001_ha);
+
#ifdef PM8001_USE_TASKLET
/* For non-msix and msix interrupts */
if ((!pdev->msix_cap || !pci_msi_enabled()) ||
@@ -1309,7 +1321,8 @@ static int __maybe_unused pm8001_pci_suspend(struct device *dev)
struct pci_dev *pdev = to_pci_dev(dev);
struct sas_ha_struct *sha = pci_get_drvdata(pdev);
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
- int i, j;
+ int j;
+
sas_suspend_ha(sha);
flush_workqueue(pm8001_wq);
scsi_block_requests(pm8001_ha->shost);
@@ -1319,15 +1332,9 @@ static int __maybe_unused pm8001_pci_suspend(struct device *dev)
}
PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF);
PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha);
-#ifdef PM8001_USE_MSIX
- for (i = 0; i < pm8001_ha->number_of_intr; i++)
- synchronize_irq(pci_irq_vector(pdev, i));
- for (i = 0; i < pm8001_ha->number_of_intr; i++)
- free_irq(pci_irq_vector(pdev, i), &pm8001_ha->irq_vector[i]);
- pci_free_irq_vectors(pdev);
-#else
- free_irq(pm8001_ha->irq, sha);
-#endif
+
+ pm8001_free_irq(pm8001_ha);
+
#ifdef PM8001_USE_TASKLET
/* For non-msix and msix interrupts */
if ((!pdev->msix_cap || !pci_msi_enabled()) ||
--
2.41.0
next prev parent reply other threads:[~2023-09-11 3:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-11 3:01 [PATCH 00/10] scsi: pm8001: Bug fix and cleanup Damien Le Moal
2023-09-11 3:01 ` [PATCH 01/10] scsi: pm8001: Setup IRQs on resume Damien Le Moal
2023-09-11 7:53 ` Jinpu Wang
2023-09-11 3:01 ` Damien Le Moal [this message]
2023-09-11 8:11 ` [PATCH 02/10] scsi: pm8001: Introduce pm8001_free_irq() Jinpu Wang
2023-09-11 3:02 ` [PATCH 03/10] scsi: pm8001: Introduce pm8001_init_tasklet() Damien Le Moal
2023-09-11 3:02 ` [PATCH 04/10] scsi: pm8001: Introduce pm8001_kill_tasklet() Damien Le Moal
2023-09-11 3:02 ` [PATCH 05/10] scsi: pm8001: Introduce pm8001_handle_irq() Damien Le Moal
2023-09-11 3:02 ` [PATCH 06/10] scsi: pm8001: Simplify pm8001_chip_interrupt_enable/disable() Damien Le Moal
2023-09-11 3:02 ` [PATCH 07/10] scsi: pm8001: Remove pm80xx_chip_intx_interrupt_enable/disable() Damien Le Moal
2023-09-11 3:02 ` [PATCH 08/10] scsi: pm8001: Remove PM8001_USE_MSIX Damien Le Moal
2023-09-11 3:02 ` [PATCH 09/10] scsi: pm8001: Remove PM8001_USE_TASKLET Damien Le Moal
2023-09-11 3:02 ` [PATCH 10/10] scsi: pm8001: Remove PM8001_READ_VPD Damien Le Moal
2023-09-11 13:44 ` kernel test robot
2023-09-11 8:27 ` [PATCH 00/10] scsi: pm8001: Bug fix and cleanup Jinpu Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230911030207.242917-3-dlemoal@kernel.org \
--to=dlemoal@kernel.org \
--cc=jinpu.wang@ionos.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.