Skip to content

Commit 639e204

Browse files
bvanasschemartinkpetersen
authored andcommitted
scsi: ufs: core: Move the ufshcd_device_init() calls
Move the ufshcd_device_init() and ufshcd_process_hba_result() calls to the ufshcd_probe_hba() callers. This change refactors the code without modifying the behavior of the UFSHCI driver. This change prepares for moving one ufshcd_device_init() call into ufshcd_init(). Signed-off-by: Bart Van Assche <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 0936001 commit 639e204

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ static int ufshcd_reset_and_restore(struct ufs_hba *hba);
298298
static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd);
299299
static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag);
300300
static void ufshcd_hba_exit(struct ufs_hba *hba);
301+
static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params);
301302
static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params);
302303
static int ufshcd_setup_clocks(struct ufs_hba *hba, bool on);
303304
static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba *hba);
@@ -7690,8 +7691,14 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba)
76907691
err = ufshcd_hba_enable(hba);
76917692

76927693
/* Establish the link again and restore the device */
7693-
if (!err)
7694-
err = ufshcd_probe_hba(hba, false);
7694+
if (!err) {
7695+
ktime_t probe_start = ktime_get();
7696+
7697+
err = ufshcd_device_init(hba, /*init_dev_params=*/false);
7698+
if (!err)
7699+
err = ufshcd_probe_hba(hba, false);
7700+
ufshcd_process_probe_result(hba, probe_start, err);
7701+
}
76957702

76967703
if (err)
76977704
dev_err(hba->dev, "%s: Host init failed %d\n", __func__, err);
@@ -8827,13 +8834,8 @@ static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params)
88278834
*/
88288835
static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params)
88298836
{
8830-
ktime_t start = ktime_get();
88318837
int ret;
88328838

8833-
ret = ufshcd_device_init(hba, init_dev_params);
8834-
if (ret)
8835-
goto out;
8836-
88378839
if (!hba->pm_op_in_progress &&
88388840
(hba->quirks & UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH)) {
88398841
/* Reset the device and controller before doing reinit */
@@ -8846,13 +8848,13 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params)
88468848
dev_err(hba->dev, "Host controller enable failed\n");
88478849
ufshcd_print_evt_hist(hba);
88488850
ufshcd_print_host_state(hba);
8849-
goto out;
8851+
return ret;
88508852
}
88518853

88528854
/* Reinit the device */
88538855
ret = ufshcd_device_init(hba, init_dev_params);
88548856
if (ret)
8855-
goto out;
8857+
return ret;
88568858
}
88578859

88588860
ufshcd_print_pwr_info(hba);
@@ -8872,9 +8874,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params)
88728874
ufshcd_write_ee_control(hba);
88738875
ufshcd_configure_auto_hibern8(hba);
88748876

8875-
out:
8876-
ufshcd_process_probe_result(hba, start, ret);
8877-
return ret;
8877+
return 0;
88788878
}
88798879

88808880
/**
@@ -8885,11 +8885,16 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params)
88858885
static void ufshcd_async_scan(void *data, async_cookie_t cookie)
88868886
{
88878887
struct ufs_hba *hba = (struct ufs_hba *)data;
8888+
ktime_t probe_start;
88888889
int ret;
88898890

88908891
down(&hba->host_sem);
88918892
/* Initialize hba, detect and initialize UFS device */
8892-
ret = ufshcd_probe_hba(hba, true);
8893+
probe_start = ktime_get();
8894+
ret = ufshcd_device_init(hba, /*init_dev_params=*/true);
8895+
if (ret == 0)
8896+
ret = ufshcd_probe_hba(hba, true);
8897+
ufshcd_process_probe_result(hba, probe_start, ret);
88938898
up(&hba->host_sem);
88948899
if (ret)
88958900
goto out;

0 commit comments

Comments
 (0)