From: Bean Huo <[email protected]>
Cleanup UFS descriptor length initialization, and delete some unnecessary code.
Changelog:
v3 - v4:
1. add desc_id >= QUERY_DESC_IDN_MAX check in patch 4/5 (Avri Altman)
2. update buff_len to hold the true descriptor size in 4/5 (Avri Altman)
3. add new patch 3/5
v2 - v3:
1. Fix typo in the commit message (Avri Altman & Bart van Assche)
2. Delete ufshcd_init_desc_sizes() in patch 3/4 (Stanley Chu)
3. Remove max_t() and buff_len in patch 1/4 (Bart van Assche)
4. Add patch 4/4 to compatable with 3.1 UFS unit descriptor length
v1 - v2:
1. split patch
2. fix one compiling WARNING (Reported-by: kbuild test robot <[email protected]>)
Bean Huo (5):
scsi: ufs: remove max_t in ufs_get_device_desc
scsi: ufs: delete ufshcd_read_desc()
scsi: ufs: fix potential access NULL pointer while memcpy
scsi: ufs: cleanup ufs initialization path
scsi: ufs: add compatibility with 3.1 UFS unit descriptor length
drivers/scsi/ufs/ufs.h | 11 +-
drivers/scsi/ufs/ufs_bsg.c | 5 +-
drivers/scsi/ufs/ufshcd.c | 205 +++++++++----------------------------
drivers/scsi/ufs/ufshcd.h | 16 +--
4 files changed, 53 insertions(+), 184 deletions(-)
--
2.17.1
From: Bean Huo <[email protected]>
Delete ufshcd_read_desc(). Instead, let caller directly call
ufshcd_read_desc_param().
Signed-off-by: Bean Huo <[email protected]>
Reviewed-by: Avri Altman <[email protected]>
Reviewed-by: Bart van Assche <[email protected]>
Reviewed-by: Stanley Chu <[email protected]>
---
drivers/scsi/ufs/ufshcd.c | 27 ++++++++-------------------
1 file changed, 8 insertions(+), 19 deletions(-)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index f57acfbf9d60..f7e8bfefe3d4 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -3221,16 +3221,6 @@ int ufshcd_read_desc_param(struct ufs_hba *hba,
return ret;
}
-static inline int ufshcd_read_desc(struct ufs_hba *hba,
- enum desc_idn desc_id,
- int desc_index,
- void *buf,
- u32 size)
-{
- return ufshcd_read_desc_param(hba, desc_id, desc_index, 0, buf, size);
-}
-
-
/**
* struct uc_string_id - unicode string
*
@@ -3278,9 +3268,8 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
if (!uc_str)
return -ENOMEM;
- ret = ufshcd_read_desc(hba, QUERY_DESC_IDN_STRING,
- desc_index, uc_str,
- QUERY_DESC_MAX_SIZE);
+ ret = ufshcd_read_desc_param(hba, QUERY_DESC_IDN_STRING, desc_index, 0,
+ (u8 *)uc_str, QUERY_DESC_MAX_SIZE);
if (ret < 0) {
dev_err(hba->dev, "Reading String Desc failed after %d retries. err = %d\n",
QUERY_REQ_RETRIES, ret);
@@ -6684,8 +6673,8 @@ static void ufshcd_set_active_icc_lvl(struct ufs_hba *hba)
if (!desc_buf)
return;
- ret = ufshcd_read_desc(hba, QUERY_DESC_IDN_POWER, 0,
- desc_buf, buff_len);
+ ret = ufshcd_read_desc_param(hba, QUERY_DESC_IDN_POWER, 0, 0,
+ desc_buf, buff_len);
if (ret) {
dev_err(hba->dev,
"%s: Failed reading power descriptor.len = %d ret = %d",
@@ -6886,8 +6875,8 @@ static int ufs_get_device_desc(struct ufs_hba *hba)
goto out;
}
- err = ufshcd_read_desc(hba, QUERY_DESC_IDN_DEVICE, 0, desc_buf,
- hba->desc_size.dev_desc);
+ err = ufshcd_read_desc_param(hba, QUERY_DESC_IDN_DEVICE, 0, 0, desc_buf,
+ hba->desc_size.dev_desc);
if (err) {
dev_err(hba->dev, "%s: Failed reading Device Desc. err = %d\n",
__func__, err);
@@ -7168,8 +7157,8 @@ static int ufshcd_device_geo_params_init(struct ufs_hba *hba)
goto out;
}
- err = ufshcd_read_desc(hba, QUERY_DESC_IDN_GEOMETRY, 0,
- desc_buf, buff_len);
+ err = ufshcd_read_desc_param(hba, QUERY_DESC_IDN_GEOMETRY, 0, 0,
+ desc_buf, buff_len);
if (err) {
dev_err(hba->dev, "%s: Failed reading Geometry Desc. err = %d\n",
__func__, err);
--
2.17.1