Commit 151f1b66 authored by Adrian Hunter's avatar Adrian Hunter Committed by Martin K. Petersen

scsi: ufs: Allow an error return value from ->device_reset()

It is simpler for drivers to provide a ->device_reset() callback
irrespective of whether the GPIO, or firmware interface necessary to do the
reset, is discovered during probe.

Change ->device_reset() to return an error code.  Drivers that provide the
callback, but do not do the reset operation should return -EOPNOTSUPP.

Link: https://lore.kernel.org/r/20201103141403.2142-3-adrian.hunter@intel.comReviewed-by: default avatarAsutosh Das <asutoshd@codeaurora.org>
Reviewed-by: default avatarStanley Chu <stanley.chu@mediatek.com>
Reviewed-by: default avatarBean huo <beanhuo@micron.com>
Reviewed-by: default avatarCan Guo <cang@codeaurora.org>
Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent fe1d4c2e
...@@ -743,7 +743,7 @@ static int ufs_mtk_link_startup_notify(struct ufs_hba *hba, ...@@ -743,7 +743,7 @@ static int ufs_mtk_link_startup_notify(struct ufs_hba *hba,
return ret; return ret;
} }
static void ufs_mtk_device_reset(struct ufs_hba *hba) static int ufs_mtk_device_reset(struct ufs_hba *hba)
{ {
struct arm_smccc_res res; struct arm_smccc_res res;
...@@ -764,6 +764,8 @@ static void ufs_mtk_device_reset(struct ufs_hba *hba) ...@@ -764,6 +764,8 @@ static void ufs_mtk_device_reset(struct ufs_hba *hba)
usleep_range(10000, 15000); usleep_range(10000, 15000);
dev_info(hba->dev, "device reset done\n"); dev_info(hba->dev, "device reset done\n");
return 0;
} }
static int ufs_mtk_link_set_hpm(struct ufs_hba *hba) static int ufs_mtk_link_set_hpm(struct ufs_hba *hba)
......
...@@ -1422,13 +1422,13 @@ static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba) ...@@ -1422,13 +1422,13 @@ static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba)
* *
* Toggles the (optional) reset line to reset the attached device. * Toggles the (optional) reset line to reset the attached device.
*/ */
static void ufs_qcom_device_reset(struct ufs_hba *hba) static int ufs_qcom_device_reset(struct ufs_hba *hba)
{ {
struct ufs_qcom_host *host = ufshcd_get_variant(hba); struct ufs_qcom_host *host = ufshcd_get_variant(hba);
/* reset gpio is optional */ /* reset gpio is optional */
if (!host->device_reset) if (!host->device_reset)
return; return -EOPNOTSUPP;
/* /*
* The UFS device shall detect reset pulses of 1us, sleep for 10us to * The UFS device shall detect reset pulses of 1us, sleep for 10us to
...@@ -1439,6 +1439,8 @@ static void ufs_qcom_device_reset(struct ufs_hba *hba) ...@@ -1439,6 +1439,8 @@ static void ufs_qcom_device_reset(struct ufs_hba *hba)
gpiod_set_value_cansleep(host->device_reset, 0); gpiod_set_value_cansleep(host->device_reset, 0);
usleep_range(10, 15); usleep_range(10, 15);
return 0;
} }
#if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND) #if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)
......
...@@ -323,7 +323,7 @@ struct ufs_hba_variant_ops { ...@@ -323,7 +323,7 @@ struct ufs_hba_variant_ops {
int (*resume)(struct ufs_hba *, enum ufs_pm_op); int (*resume)(struct ufs_hba *, enum ufs_pm_op);
void (*dbg_register_dump)(struct ufs_hba *hba); void (*dbg_register_dump)(struct ufs_hba *hba);
int (*phy_initialization)(struct ufs_hba *); int (*phy_initialization)(struct ufs_hba *);
void (*device_reset)(struct ufs_hba *hba); int (*device_reset)(struct ufs_hba *hba);
void (*config_scaling_param)(struct ufs_hba *hba, void (*config_scaling_param)(struct ufs_hba *hba,
struct devfreq_dev_profile *profile, struct devfreq_dev_profile *profile,
void *data); void *data);
...@@ -1207,9 +1207,12 @@ static inline void ufshcd_vops_dbg_register_dump(struct ufs_hba *hba) ...@@ -1207,9 +1207,12 @@ static inline void ufshcd_vops_dbg_register_dump(struct ufs_hba *hba)
static inline void ufshcd_vops_device_reset(struct ufs_hba *hba) static inline void ufshcd_vops_device_reset(struct ufs_hba *hba)
{ {
if (hba->vops && hba->vops->device_reset) { if (hba->vops && hba->vops->device_reset) {
hba->vops->device_reset(hba); int err = hba->vops->device_reset(hba);
ufshcd_set_ufs_dev_active(hba);
ufshcd_update_reg_hist(&hba->ufs_stats.dev_reset, 0); if (!err)
ufshcd_set_ufs_dev_active(hba);
if (err != -EOPNOTSUPP)
ufshcd_update_reg_hist(&hba->ufs_stats.dev_reset, err);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment