Skip to content

Commit ff40f31

Browse files
ptr324martinkpetersen
authored andcommitted
scsi: ufs: host: mediatek: Add clock scaling query function
Introduce a clock scaling readiness query function to streamline the process of checking clock scaling parameters. This function simplifies the code by encapsulating the logic for determining if clock scaling is ready. Signed-off-by: Peter Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Chun-Hung Wu <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 7996746 commit ff40f31

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

drivers/ufs/host/ufs-mediatek.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,16 @@ static bool ufs_mtk_is_allow_vccqx_lpm(struct ufs_hba *hba)
141141
return host->caps & UFS_MTK_CAP_ALLOW_VCCQX_LPM;
142142
}
143143

144+
static bool ufs_mtk_is_clk_scale_ready(struct ufs_hba *hba)
145+
{
146+
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
147+
struct ufs_mtk_clk *mclk = &host->mclk;
148+
149+
return mclk->ufs_sel_clki &&
150+
mclk->ufs_sel_max_clki &&
151+
mclk->ufs_sel_min_clki;
152+
}
153+
144154
static void ufs_mtk_cfg_unipro_cg(struct ufs_hba *hba, bool enable)
145155
{
146156
u32 tmp;
@@ -922,7 +932,6 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba)
922932
{
923933
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
924934
struct list_head *head = &hba->clk_list_head;
925-
struct ufs_mtk_clk *mclk = &host->mclk;
926935
struct ufs_clk_info *clki, *clki_tmp;
927936

928937
/*
@@ -944,8 +953,7 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba)
944953
}
945954
}
946955

947-
if (!mclk->ufs_sel_clki || !mclk->ufs_sel_max_clki ||
948-
!mclk->ufs_sel_min_clki) {
956+
if (!ufs_mtk_is_clk_scale_ready(hba)) {
949957
hba->caps &= ~UFSHCD_CAP_CLK_SCALING;
950958
dev_info(hba->dev,
951959
"%s: Clk-scaling not ready. Feature disabled.",

0 commit comments

Comments
 (0)