Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>,
	Peter Wang <peter.wang@mediatek.com>,
	Avri Altman <avri.altman@wdc.com>,
	Andrew Halaney <ahalaney@redhat.com>,
	Bean Huo <beanhuo@micron.com>,
	Maramaina Naresh <quic_mnaresh@quicinc.com>
Subject: [PATCH v6 04/11] scsi: ufs: core: Introduce ufshcd_process_probe_result()
Date: Wed, 16 Oct 2024 13:12:00 -0700	[thread overview]
Message-ID: <20241016201249.2256266-5-bvanassche@acm.org> (raw)
In-Reply-To: <20241016201249.2256266-1-bvanassche@acm.org>

Prepare for moving a ufshcd_device_init() call from inside
ufshcd_probe_hba() into the ufshcd_probe_hba() callers by introducing
the function ufshcd_process_probe_result(). No functionality has been
changed.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/ufs/core/ufshcd.c | 35 ++++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 17604397aaba..724060a9eae7 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -7684,6 +7684,29 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
 	return err;
 }
 
+/**
+ * ufshcd_process_probe_result - Process the ufshcd_probe_hba() result.
+ * @hba: UFS host controller instance.
+ * @probe_start: time when the ufshcd_probe_hba() call started.
+ * @ret: ufshcd_probe_hba() return value.
+ */
+static void ufshcd_process_probe_result(struct ufs_hba *hba,
+					ktime_t probe_start, int ret)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(hba->host->host_lock, flags);
+	if (ret)
+		hba->ufshcd_state = UFSHCD_STATE_ERROR;
+	else if (hba->ufshcd_state == UFSHCD_STATE_RESET)
+		hba->ufshcd_state = UFSHCD_STATE_OPERATIONAL;
+	spin_unlock_irqrestore(hba->host->host_lock, flags);
+
+	trace_ufshcd_init(dev_name(hba->dev), ret,
+			  ktime_to_us(ktime_sub(ktime_get(), probe_start)),
+			  hba->curr_dev_pwr_mode, hba->uic_link_state);
+}
+
 /**
  * ufshcd_host_reset_and_restore - reset and restore host controller
  * @hba: per-adapter instance
@@ -8850,7 +8873,6 @@ static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params)
 static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params)
 {
 	ktime_t start = ktime_get();
-	unsigned long flags;
 	int ret;
 
 	ret = ufshcd_device_init(hba, init_dev_params);
@@ -8896,16 +8918,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params)
 	ufshcd_configure_auto_hibern8(hba);
 
 out:
-	spin_lock_irqsave(hba->host->host_lock, flags);
-	if (ret)
-		hba->ufshcd_state = UFSHCD_STATE_ERROR;
-	else if (hba->ufshcd_state == UFSHCD_STATE_RESET)
-		hba->ufshcd_state = UFSHCD_STATE_OPERATIONAL;
-	spin_unlock_irqrestore(hba->host->host_lock, flags);
-
-	trace_ufshcd_init(dev_name(hba->dev), ret,
-		ktime_to_us(ktime_sub(ktime_get(), start)),
-		hba->curr_dev_pwr_mode, hba->uic_link_state);
+	ufshcd_process_probe_result(hba, start, ret);
 	return ret;
 }
 

  parent reply	other threads:[~2024-10-16 20:13 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-16 20:11 [PATCH v6 00/11] Combine the two UFS driver scsi_add_host() calls Bart Van Assche
2024-10-16 20:11 ` [PATCH v6 01/11] scsi: ufs: core: Introduce ufshcd_add_scsi_host() Bart Van Assche
2024-10-16 20:11 ` [PATCH v6 02/11] scsi: ufs: core: Introduce ufshcd_post_device_init() Bart Van Assche
2024-10-16 20:11 ` [PATCH v6 03/11] scsi: ufs: core: Call ufshcd_add_scsi_host() later Bart Van Assche
2024-10-16 20:12 ` Bart Van Assche [this message]
2024-10-16 20:12 ` [PATCH v6 05/11] scsi: ufs: core: Convert a comment into an explicit check Bart Van Assche
2024-10-16 20:12 ` [PATCH v6 06/11] scsi: ufs: core: Move the ufshcd_device_init() calls Bart Van Assche
2024-10-16 20:12 ` [PATCH v6 07/11] scsi: ufs: core: Move the ufshcd_device_init(hba, true) call Bart Van Assche
2024-10-16 20:12 ` [PATCH v6 08/11] scsi: ufs: core: Expand " Bart Van Assche
2024-10-16 20:12 ` [PATCH v6 09/11] scsi: ufs: core: Remove code that is no longer needed Bart Van Assche
2024-10-16 20:12 ` [PATCH v6 10/11] scsi: ufs: core: Move the MCQ scsi_add_host() call Bart Van Assche
2024-10-16 20:12 ` [PATCH v6 11/11] scsi: ufs: core: Move code out of an if-statement Bart Van Assche
2024-10-31 14:46   ` Neil Armstrong
2024-10-31 17:51     ` Bart Van Assche
2024-10-31 19:55       ` Neil Armstrong
2024-10-31 21:15         ` Bart Van Assche
2024-11-05 22:01           ` Bart Van Assche
2024-11-06  8:48             ` Neil Armstrong
2024-11-06  9:57             ` Neil Armstrong
2024-11-06 17:51               ` Bart Van Assche
2024-11-07 10:49                 ` Manivannan Sadhasivam
2024-10-25 19:30 ` [PATCH v6 00/11] Combine the two UFS driver scsi_add_host() calls Martin K. Petersen
2024-11-05  2:32 ` 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=20241016201249.2256266-5-bvanassche@acm.org \
    --to=bvanassche@acm.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=ahalaney@redhat.com \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=martin.petersen@oracle.com \
    --cc=peter.wang@mediatek.com \
    --cc=quic_mnaresh@quicinc.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