All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	linux-scsi@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>,
	Avri Altman <avri.altman@wdc.com>
Subject: [PATCH v3 21/28] scsi: ufs: Introduce ufshcd_clkgate_delay_set()
Date: Tue, 19 Apr 2022 15:58:04 -0700	[thread overview]
Message-ID: <20220419225811.4127248-22-bvanassche@acm.org> (raw)
In-Reply-To: <20220419225811.4127248-1-bvanassche@acm.org>

Since the code to modify delay_ms while holding the host lock occurs
twice, introduce a function that performs this action.

Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufs-mediatek.c |  5 +----
 drivers/scsi/ufs/ufshcd.c       | 18 +++++++++++++-----
 drivers/scsi/ufs/ufshcd.h       |  2 ++
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 2b26acc74efb..d19b35495302 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -857,7 +857,6 @@ static int ufs_mtk_pre_link(struct ufs_hba *hba)
 
 static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba)
 {
-	unsigned long flags;
 	u32 ah_ms;
 
 	if (ufshcd_is_clkgating_allowed(hba)) {
@@ -866,9 +865,7 @@ static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba)
 					  hba->ahit);
 		else
 			ah_ms = 10;
-		spin_lock_irqsave(hba->host->host_lock, flags);
-		hba->clk_gating.delay_ms = ah_ms + 5;
-		spin_unlock_irqrestore(hba->host->host_lock, flags);
+		ufshcd_clkgate_delay_set(hba->dev, ah_ms + 5);
 	}
 }
 
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index d1c3f6291538..cb74a9eeee70 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -1864,18 +1864,26 @@ static ssize_t ufshcd_clkgate_delay_show(struct device *dev,
 	return sysfs_emit(buf, "%lu\n", hba->clk_gating.delay_ms);
 }
 
+void ufshcd_clkgate_delay_set(struct device *dev, unsigned long value)
+{
+	struct ufs_hba *hba = dev_get_drvdata(dev);
+	unsigned long flags;
+
+	spin_lock_irqsave(hba->host->host_lock, flags);
+	hba->clk_gating.delay_ms = value;
+	spin_unlock_irqrestore(hba->host->host_lock, flags);
+}
+EXPORT_SYMBOL_GPL(ufshcd_clkgate_delay_set);
+
 static ssize_t ufshcd_clkgate_delay_store(struct device *dev,
 		struct device_attribute *attr, const char *buf, size_t count)
 {
-	struct ufs_hba *hba = dev_get_drvdata(dev);
-	unsigned long flags, value;
+	unsigned long value;
 
 	if (kstrtoul(buf, 0, &value))
 		return -EINVAL;
 
-	spin_lock_irqsave(hba->host->host_lock, flags);
-	hba->clk_gating.delay_ms = value;
-	spin_unlock_irqrestore(hba->host->host_lock, flags);
+	ufshcd_clkgate_delay_set(dev, value);
 	return count;
 }
 
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 14414225faa1..3eb5d2c17e39 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -1186,6 +1186,8 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
 int ufshcd_hold(struct ufs_hba *hba, bool async);
 void ufshcd_release(struct ufs_hba *hba);
 
+void ufshcd_clkgate_delay_set(struct device *dev, unsigned long value);
+
 void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id,
 				  int *desc_length);
 

  parent reply	other threads:[~2022-04-19 22:59 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-19 22:57 [PATCH v3 00/28] Split the ufshcd.h header file Bart Van Assche
2022-04-19 22:57 ` [PATCH v3 01/28] scsi: ufs: Fix a spelling error in a source code comment Bart Van Assche
2022-04-19 22:57 ` [PATCH v3 02/28] scsi: ufs: Declare ufshcd_wait_for_register() static Bart Van Assche
2022-04-19 22:57 ` [PATCH v3 03/28] scsi: ufs: Remove superfluous boolean conversions Bart Van Assche
2022-04-19 22:57 ` [PATCH v3 04/28] scsi: ufs: Simplify statements that return a boolean Bart Van Assche
2022-04-19 22:57 ` [PATCH v3 05/28] scsi: ufs: Remove ufshcd_lrb.sense_bufflen Bart Van Assche
2022-04-19 22:57 ` [PATCH v3 06/28] scsi: ufs: Remove ufshcd_lrb.sense_buffer Bart Van Assche
2022-04-19 22:57 ` [PATCH v3 07/28] scsi: ufs: Use get_unaligned_be16() instead of be16_to_cpup() Bart Van Assche
2022-04-19 22:57 ` [PATCH v3 08/28] scsi: ufs: Remove the UFS_FIX() and END_FIX() macros Bart Van Assche
2022-04-19 22:57 ` [PATCH v3 09/28] scsi: ufs: Rename struct ufs_dev_fix into ufs_dev_quirk Bart Van Assche
2022-04-19 22:57 ` [PATCH v3 10/28] scsi: ufs: Declare the quirks array const Bart Van Assche
2022-04-19 22:57 ` [PATCH v3 11/28] scsi: ufs: Invert the return value of ufshcd_is_hba_active() Bart Van Assche
2022-04-19 22:57 ` [PATCH v3 12/28] scsi: ufs: Remove unused constants and code Bart Van Assche
2022-04-19 22:57 ` [PATCH v3 13/28] scsi: ufs: Switch to aggregate initialization Bart Van Assche
2022-04-19 22:57 ` [PATCH v3 14/28] scsi: ufs: Make the config_scaling_param calls type safe Bart Van Assche
2022-04-19 22:57 ` [PATCH v3 15/28] scsi: ufs: Remove the driver version Bart Van Assche
2022-04-19 22:57 ` [PATCH v3 16/28] scsi: ufs: Rename sdev_ufs_device into ufs_device_wlun Bart Van Assche
2022-04-19 22:58 ` [PATCH v3 17/28] scsi: ufs: Use an SPDX license identifier in the Kconfig file Bart Van Assche
2022-04-19 22:58 ` [PATCH v3 18/28] scsi: ufs: Remove paths from source code comments Bart Van Assche
2022-04-19 22:58 ` [PATCH v3 19/28] scsi: ufs: Remove the TRUE and FALSE definitions Bart Van Assche
2022-04-19 22:58 ` [PATCH v3 20/28] scsi: ufs: Remove locking from around single register writes Bart Van Assche
2022-04-19 22:58 ` Bart Van Assche [this message]
2022-04-19 22:58 ` [PATCH v3 22/28] scsi: ufs: qcom: Fix ufs_qcom_resume() Bart Van Assche
2022-04-19 22:58 ` [PATCH v3 23/28] scsi: ufs: Remove unnecessary ufshcd-crypto.h include directives Bart Van Assche
2022-04-19 22:58 ` [PATCH v3 24/28] scsi: ufs: Fix kernel-doc syntax in ufshcd.h Bart Van Assche
2022-04-19 22:58 ` [PATCH v3 25/28] scsi: ufs: Minimize #include directives Bart Van Assche
2022-04-19 22:58 ` [PATCH v3 26/28] scsi: ufs: Split the ufshcd.h header file Bart Van Assche
2022-04-19 22:58 ` [PATCH v3 27/28] scsi: ufs: Move the struct ufs_ref_clk definition Bart Van Assche
2022-04-19 22:58 ` [PATCH v3 28/28] scsi: ufs: Move the ufs_is_valid_unit_desc_lun() definition Bart Van Assche
2022-04-25 20:58 ` [PATCH v3 00/28] Split the ufshcd.h header file Bean Huo
2022-04-26  2:43 ` Martin K. Petersen
2022-05-03  0:51 ` 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=20220419225811.4127248-22-bvanassche@acm.org \
    --to=bvanassche@acm.org \
    --cc=adrian.hunter@intel.com \
    --cc=avri.altman@wdc.com \
    --cc=jaegeuk@kernel.org \
    --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.