> + ktime_t start; > + s64 time; Can this be done with less variables? e.g is this working? ktime_t timeout; > > err = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_SET_FLAG, > QUERY_FLAG_IDN_FDEVICEINIT, 0, NULL); > @@ -4161,20 +4165,27 @@ static int ufshcd_complete_dev_init(struct ufs_hba > *hba) > goto out; > } > > - /* poll for max. 1000 iterations for fDeviceInit flag to clear */ > - for (i = 0; i < 1000 && !err && flag_res; i++) > - err = ufshcd_query_flag_retry(hba, > UPIU_QUERY_OPCODE_READ_FLAG, > - QUERY_FLAG_IDN_FDEVICEINIT, 0, &flag_res); > + /* Poll fDeviceInit flag to be cleared */ > + start = ktime_get(); timeout = ktime_add_ms(ktime_get(), FDEVICEINIT_COMPL_TIMEOUT); > + do { > + err = ufshcd_query_flag(hba, UPIU_QUERY_OPCODE_READ_FLAG, > + QUERY_FLAG_IDN_FDEVICEINIT, 0, &flag_res); > + if (!flag_res) > + break; > + usleep_range(5000, 10000); > + time = ktime_to_ms(ktime_sub(ktime_get(), start)); > + } while (time < FDEVICEINIT_COMPL_TIMEOUT); while (ktime_before(ktime_get(), timeout)); Thanks, Avri