Re: [PATCH v4 2/4] ufs: core: Remove redundant desc_size variable from hba

From: Bart Van Assche
Date: Wed Dec 07 2022 - 18:36:49 EST


On 11/27/22 04:08, Arthur Simchaev wrote:
Always read the descriptor with QUERY_DESC_MAX_SIZE.
According to the spec, the device returns the actual size

Reviewed-by: Bean Huo <beanhuo@xxxxxxxxxx>
Signed-off-by: Arthur Simchaev <Arthur.Simchaev@xxxxxxx>
---
drivers/ufs/core/ufshcd.c | 53 +++++++++++++----------------------------------
include/ufs/ufs.h | 1 -
include/ufs/ufshcd.h | 1 -
3 files changed, 14 insertions(+), 41 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 2e47c69..70e96b6 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -3377,28 +3377,11 @@ int ufshcd_query_descriptor_retry(struct ufs_hba *hba,
void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id,
int *desc_len)
{
- if (desc_id >= QUERY_DESC_IDN_MAX || desc_id == QUERY_DESC_IDN_RFU_0 ||
- desc_id == QUERY_DESC_IDN_RFU_1)
- *desc_len = 0;
- else
- *desc_len = hba->desc_size[desc_id];
+ /*Always returns QUERY_DESC_MAX_SIZE*/
+ *desc_len = QUERY_DESC_MAX_SIZE;
}
EXPORT_SYMBOL(ufshcd_map_desc_id_to_length);

Comments should explain something that is nontrivial instead of duplicating the
code. Additionally, this change makes ufshcd_map_desc_id_to_length() too short
too keep it as a function. Please remove this function entirely and insert the
following code into the callers of this function:

desc_len = QUERY_DESC_MAX_SIZE

Thanks,

Bart.