scsi: ufs: read device descriptor once
We are reading the device descriptor once for applying the device
quirks and then device descriptor isn't saved anywhere for future
use. Now that we also need the bDeviceSubClass parameter (of device
descriptor), this change refactors the code to read the device
descriptor once and save the imprortant parameters for later use
by driver.
Change-Id: Icb5d0380a9dcac0e7bd042d9be3abd8bcf6ead48
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index e0ac4a3..86d5d0b 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -6895,6 +6895,29 @@
return err;
}
+static int ufs_read_device_desc_data(struct ufs_hba *hba)
+{
+ int err;
+ u8 desc_buf[QUERY_DESC_DEVICE_MAX_SIZE];
+
+ err = ufshcd_read_device_desc(hba, desc_buf, sizeof(desc_buf));
+ if (err)
+ return err;
+
+ /*
+ * getting vendor (manufacturerID) and Bank Index in big endian
+ * format
+ */
+ hba->dev_info.w_manufacturer_id =
+ desc_buf[DEVICE_DESC_PARAM_MANF_ID] << 8 |
+ desc_buf[DEVICE_DESC_PARAM_MANF_ID + 1];
+ hba->dev_info.b_device_sub_class =
+ desc_buf[DEVICE_DESC_PARAM_DEVICE_SUB_CLASS];
+ hba->dev_info.i_product_name = desc_buf[DEVICE_DESC_PARAM_PRDCT_NAME];
+
+ return 0;
+}
+
/**
* ufshcd_probe_hba - probe hba to detect device and initialize
* @hba: per-adapter instance
@@ -6932,6 +6955,11 @@
if (ret)
goto out;
+ /* cache important parameters from device descriptor for later use */
+ ret = ufs_read_device_desc_data(hba);
+ if (ret)
+ goto out;
+
ufs_advertise_fixup_device(hba);
ufshcd_tune_unipro_params(hba);