public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
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 v2 05/10] scsi: pm8001: Introduce pm8001_handle_irq()
Date: Tue, 12 Sep 2023 08:27:40 +0900	[thread overview]
Message-ID: <20230911232745.325149-6-dlemoal@kernel.org> (raw)
In-Reply-To: <20230911232745.325149-1-dlemoal@kernel.org>

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 <dlemoal@kernel.org>
Acked-by: Jack Wang <jinpu.wang@ionos.com>
---
 drivers/scsi/pm8001/pm8001_init.c | 50 ++++++++++++++-----------------
 1 file changed, 22 insertions(+), 28 deletions(-)

diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
index 44a027d76fba..0ec43e155511 100644
--- a/drivers/scsi/pm8001/pm8001_init.c
+++ b/drivers/scsi/pm8001/pm8001_init.c
@@ -257,6 +257,23 @@ static void pm8001_kill_tasklet(struct pm8001_hba_info *pm8001_ha) {}
 
 #endif
 
+static irqreturn_t pm8001_handle_irq(struct pm8001_hba_info *pm8001_ha,
+				     int irq)
+{
+	if (unlikely(!pm8001_ha))
+		return IRQ_NONE;
+
+	if (!PM8001_CHIP_DISP->is_our_interrupt(pm8001_ha))
+		return IRQ_NONE;
+
+#ifdef PM8001_USE_TASKLET
+	tasklet_schedule(&pm8001_ha->tasklet[irq]);
+	return IRQ_HANDLED;
+#else
+	return PM8001_CHIP_DISP->isr(pm8001_ha, irq);
+#endif
+}
+
 /**
  * pm8001_interrupt_handler_msix - main MSIX interrupt handler.
  * 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) {}
  */
 static irqreturn_t pm8001_interrupt_handler_msix(int irq, void *opaque)
 {
-	struct isr_param *irq_vector;
-	struct pm8001_hba_info *pm8001_ha;
-	irqreturn_t ret = IRQ_HANDLED;
-	irq_vector = (struct isr_param *)opaque;
-	pm8001_ha = irq_vector->drv_inst;
+	struct isr_param *irq_vector = (struct isr_param *)opaque;
+	struct pm8001_hba_info *pm8001_ha = irq_vector->drv_inst;
 
-	if (unlikely(!pm8001_ha))
-		return IRQ_NONE;
-	if (!PM8001_CHIP_DISP->is_our_interrupt(pm8001_ha))
-		return IRQ_NONE;
-#ifdef PM8001_USE_TASKLET
-	tasklet_schedule(&pm8001_ha->tasklet[irq_vector->irq_id]);
-#else
-	ret = PM8001_CHIP_DISP->isr(pm8001_ha, irq_vector->irq_id);
-#endif
-	return ret;
+	return pm8001_handle_irq(pm8001_ha, irq_vector->irq_id);
 }
 
 /**
@@ -293,21 +298,10 @@ static irqreturn_t pm8001_interrupt_handler_msix(int irq, void *opaque)
 
 static irqreturn_t pm8001_interrupt_handler_intx(int irq, void *dev_id)
 {
-	struct pm8001_hba_info *pm8001_ha;
-	irqreturn_t ret = IRQ_HANDLED;
 	struct sas_ha_struct *sha = dev_id;
-	pm8001_ha = sha->lldd_ha;
-	if (unlikely(!pm8001_ha))
-		return IRQ_NONE;
-	if (!PM8001_CHIP_DISP->is_our_interrupt(pm8001_ha))
-		return IRQ_NONE;
+	struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
 
-#ifdef PM8001_USE_TASKLET
-	tasklet_schedule(&pm8001_ha->tasklet[0]);
-#else
-	ret = PM8001_CHIP_DISP->isr(pm8001_ha, 0);
-#endif
-	return ret;
+	return pm8001_handle_irq(pm8001_ha, 0);
 }
 
 static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha);
-- 
2.41.0


  parent reply	other threads:[~2023-09-12  2:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-11 23:27 [PATCH v2 00/10] scsi: pm8001: Bug fix and cleanup Damien Le Moal
2023-09-11 23:27 ` [PATCH v2 01/10] scsi: pm8001: Setup IRQs on resume Damien Le Moal
2023-09-11 23:27 ` [PATCH v2 02/10] scsi: pm8001: Introduce pm8001_free_irq() Damien Le Moal
2023-09-11 23:27 ` [PATCH v2 03/10] scsi: pm8001: Introduce pm8001_init_tasklet() Damien Le Moal
2023-09-11 23:27 ` [PATCH v2 04/10] scsi: pm8001: Introduce pm8001_kill_tasklet() Damien Le Moal
2023-09-11 23:27 ` Damien Le Moal [this message]
2023-09-11 23:27 ` [PATCH v2 06/10] scsi: pm8001: Simplify pm8001_chip_interrupt_enable/disable() Damien Le Moal
2023-09-11 23:27 ` [PATCH v2 07/10] scsi: pm8001: Remove pm80xx_chip_intx_interrupt_enable/disable() Damien Le Moal
2023-09-11 23:27 ` [PATCH v2 08/10] scsi: pm8001: Remove PM8001_USE_MSIX Damien Le Moal
2023-09-11 23:27 ` [PATCH v2 09/10] scsi: pm8001: Remove PM8001_USE_TASKLET Damien Le Moal
2023-09-11 23:27 ` [PATCH v2 10/10] scsi: pm8001: Remove PM8001_READ_VPD Damien Le Moal
2023-09-14  1:40 ` [PATCH v2 00/10] scsi: pm8001: Bug fix and cleanup Martin K. Petersen
2023-09-22  1:42 ` Martin K. Petersen
2023-09-27 19:34 ` Martin K. Petersen

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=20230911232745.325149-6-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox