Commit 3192d28e authored by Bart Van Assche's avatar Bart Van Assche Committed by Martin K. Petersen
Browse files

scsi: ufs: core: Introduce ufshcd_post_device_init()



Prepare for inlining one ufshcd_device_init() call by introducing the
new function ufshcd_post_device_init(). No functionality has been
changed.

Reviewed-by: default avatarAvri Altman <avri.altman@wdc.com>
Reviewed-by: default avatarManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: default avatarBao D. Nguyen <quic_nguyenb@quicinc.com>
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20241016201249.2256266-3-bvanassche@acm.org


Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 17a97397
Loading
Loading
Loading
Loading
+35 −27
Original line number Diff line number Diff line
@@ -8686,6 +8686,40 @@ static void ufshcd_config_mcq(struct ufs_hba *hba)
		 hba->nutrs);
}

static int ufshcd_post_device_init(struct ufs_hba *hba)
{
	int ret;

	ufshcd_tune_unipro_params(hba);

	/* UFS device is also active now */
	ufshcd_set_ufs_dev_active(hba);
	ufshcd_force_reset_auto_bkops(hba);

	ufshcd_set_timestamp_attr(hba);
	schedule_delayed_work(&hba->ufs_rtc_update_work,
			      msecs_to_jiffies(UFS_RTC_UPDATE_INTERVAL_MS));

	if (!hba->max_pwr_info.is_valid)
		return 0;

	/*
	 * Set the right value to bRefClkFreq before attempting to
	 * switch to HS gears.
	 */
	if (hba->dev_ref_clk_freq != REF_CLK_FREQ_INVAL)
		ufshcd_set_dev_ref_clk(hba);
	/* Gear up to HS gear. */
	ret = ufshcd_config_pwr_mode(hba, &hba->max_pwr_info.info);
	if (ret) {
		dev_err(hba->dev, "%s: Failed setting power mode, err = %d\n",
			__func__, ret);
		return ret;
	}

	return 0;
}

static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params)
{
	int ret;
@@ -8755,33 +8789,7 @@ static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params)
		}
	}

	ufshcd_tune_unipro_params(hba);

	/* UFS device is also active now */
	ufshcd_set_ufs_dev_active(hba);
	ufshcd_force_reset_auto_bkops(hba);

	ufshcd_set_timestamp_attr(hba);
	schedule_delayed_work(&hba->ufs_rtc_update_work,
			      msecs_to_jiffies(UFS_RTC_UPDATE_INTERVAL_MS));

	/* Gear up to HS gear if supported */
	if (hba->max_pwr_info.is_valid) {
		/*
		 * Set the right value to bRefClkFreq before attempting to
		 * switch to HS gears.
		 */
		if (hba->dev_ref_clk_freq != REF_CLK_FREQ_INVAL)
			ufshcd_set_dev_ref_clk(hba);
		ret = ufshcd_config_pwr_mode(hba, &hba->max_pwr_info.info);
		if (ret) {
			dev_err(hba->dev, "%s: Failed setting power mode, err = %d\n",
					__func__, ret);
			return ret;
		}
	}

	return 0;
	return ufshcd_post_device_init(hba);
}

/**