Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20241016201249.2256266-7-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
639e2043 09360013

+18 -13
+18 -13
drivers/ufs/core/ufshcd.c
··· 298 298 static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd); 299 299 static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag); 300 300 static void ufshcd_hba_exit(struct ufs_hba *hba); 301 + static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params); 301 302 static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params); 302 303 static int ufshcd_setup_clocks(struct ufs_hba *hba, bool on); 303 304 static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba *hba); ··· 7691 7690 err = ufshcd_hba_enable(hba); 7692 7691 7693 7692 /* Establish the link again and restore the device */ 7694 - if (!err) 7695 - err = ufshcd_probe_hba(hba, false); 7693 + if (!err) { 7694 + ktime_t probe_start = ktime_get(); 7695 + 7696 + err = ufshcd_device_init(hba, /*init_dev_params=*/false); 7697 + if (!err) 7698 + err = ufshcd_probe_hba(hba, false); 7699 + ufshcd_process_probe_result(hba, probe_start, err); 7700 + } 7696 7701 7697 7702 if (err) 7698 7703 dev_err(hba->dev, "%s: Host init failed %d\n", __func__, err); ··· 8834 8827 */ 8835 8828 static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params) 8836 8829 { 8837 - ktime_t start = ktime_get(); 8838 8830 int ret; 8839 - 8840 - ret = ufshcd_device_init(hba, init_dev_params); 8841 - if (ret) 8842 - goto out; 8843 8831 8844 8832 if (!hba->pm_op_in_progress && 8845 8833 (hba->quirks & UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH)) { ··· 8848 8846 dev_err(hba->dev, "Host controller enable failed\n"); 8849 8847 ufshcd_print_evt_hist(hba); 8850 8848 ufshcd_print_host_state(hba); 8851 - goto out; 8849 + return ret; 8852 8850 } 8853 8851 8854 8852 /* Reinit the device */ 8855 8853 ret = ufshcd_device_init(hba, init_dev_params); 8856 8854 if (ret) 8857 - goto out; 8855 + return ret; 8858 8856 } 8859 8857 8860 8858 ufshcd_print_pwr_info(hba); ··· 8874 8872 ufshcd_write_ee_control(hba); 8875 8873 ufshcd_configure_auto_hibern8(hba); 8876 8874 8877 - out: 8878 - ufshcd_process_probe_result(hba, start, ret); 8879 - return ret; 8875 + return 0; 8880 8876 } 8881 8877 8882 8878 /** ··· 8885 8885 static void ufshcd_async_scan(void *data, async_cookie_t cookie) 8886 8886 { 8887 8887 struct ufs_hba *hba = (struct ufs_hba *)data; 8888 + ktime_t probe_start; 8888 8889 int ret; 8889 8890 8890 8891 down(&hba->host_sem); 8891 8892 /* 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); 8893 8898 up(&hba->host_sem); 8894 8899 if (ret) 8895 8900 goto out;