diff mbox series

[v2,1/3] scsi: ufs: core: Add ufshcd_is_ufs_dev_busy()

Message ID 20231122172512.103748-2-beanhuo@iokpp.de (mailing list archive)
State Superseded
Headers show
Series Add UFS RTC support | expand

Commit Message

Bean Huo Nov. 22, 2023, 5:25 p.m. UTC
From: Bean Huo <beanhuo@micron.com>

Add helper inline for retrieving whether UFS device is busy or not.

Signed-off-by: Bean Huo <beanhuo@micron.com>
---
 drivers/ufs/core/ufshcd.c | 6 +-----
 include/ufs/ufshcd.h      | 8 +++++++-
 2 files changed, 8 insertions(+), 6 deletions(-)

Comments

Bart Van Assche Nov. 22, 2023, 5:43 p.m. UTC | #1
On 11/22/23 09:25, Bean Huo wrote:
> --- a/include/ufs/ufshcd.h
> +++ b/include/ufs/ufshcd.h
> @@ -126,7 +126,6 @@ enum uic_link_state {
>   	((h)->curr_dev_pwr_mode == UFS_POWERDOWN_PWR_MODE)
>   #define ufshcd_is_ufs_dev_deepsleep(h) \
>   	((h)->curr_dev_pwr_mode == UFS_DEEPSLEEP_PWR_MODE)
> -
>   /*
>    * UFS Power management levels.
>    * Each level is in increasing order of power savings, except DeepSleep
> @@ -1408,6 +1407,13 @@ static inline int ufshcd_vops_phy_initialization(struct ufs_hba *hba)
>   	return 0;
>   }
>   
> +static inline bool ufshcd_is_ufs_dev_busy(struct ufs_hba *hba)
> +{
> +	return (hba->clk_gating.active_reqs || hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL ||
> +		hba->outstanding_reqs || hba->outstanding_tasks || hba->active_uic_cmd ||
> +		hba->uic_async_done);
> +}

Since the above function is only used in drivers/ufs/core/ufshcd.c,
please move it back to that source file. The public header file
include/ufs/ufshcd.h is for definitions and declarations used by both
the UFS driver core and the UFS driver host files.

Thanks,

Bart.
diff mbox series

Patch

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 68d7da02944f..5d009d2c34f0 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -1916,11 +1916,7 @@  static void ufshcd_gate_work(struct work_struct *work)
 					hba->clk_gating.state);
 		goto rel_lock;
 	}
-
-	if (hba->clk_gating.active_reqs
-		|| hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL
-		|| hba->outstanding_reqs || hba->outstanding_tasks
-		|| hba->active_uic_cmd || hba->uic_async_done)
+	if (ufshcd_is_ufs_dev_busy(hba))
 		goto rel_lock;
 
 	spin_unlock_irqrestore(hba->host->host_lock, flags);
diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
index 7f0b2c5599cd..b0cd6c6591ef 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -126,7 +126,6 @@  enum uic_link_state {
 	((h)->curr_dev_pwr_mode == UFS_POWERDOWN_PWR_MODE)
 #define ufshcd_is_ufs_dev_deepsleep(h) \
 	((h)->curr_dev_pwr_mode == UFS_DEEPSLEEP_PWR_MODE)
-
 /*
  * UFS Power management levels.
  * Each level is in increasing order of power savings, except DeepSleep
@@ -1408,6 +1407,13 @@  static inline int ufshcd_vops_phy_initialization(struct ufs_hba *hba)
 	return 0;
 }
 
+static inline bool ufshcd_is_ufs_dev_busy(struct ufs_hba *hba)
+{
+	return (hba->clk_gating.active_reqs || hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL ||
+		hba->outstanding_reqs || hba->outstanding_tasks || hba->active_uic_cmd ||
+		hba->uic_async_done);
+}
+
 extern const struct ufs_pm_lvl_states ufs_pm_lvl_states[];
 
 int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len,