Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0ad8ab59 authored by Dolev Raviv's avatar Dolev Raviv
Browse files

scsi: ufs: prevent illegal icc level configuration



When device power descriptor values are not aligned with regulators
values, ufshcd_find_max_sup_active_icc_level returns an illegal value.
This will cause the write attribute query to fail with illegal value
error.

Change-Id: I8082356bf21039c2ee7018640c8f1067631e9289
Signed-off-by: default avatarDolev Raviv <draviv@codeaurora.org>
Signed-off-by: default avatarRaviv Shvili <rshvili@codeaurora.org>
parent 759f5a97
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -3665,9 +3665,9 @@ static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd)
 *
 * Returns calculated max ICC level for specific regulator
 */
static u8 ufshcd_get_max_icc_level(int sup_curr_uA, u8 start_scan, char *buff)
static u32 ufshcd_get_max_icc_level(int sup_curr_uA, u32 start_scan, char *buff)
{
	u8 i;
	int i;
	int curr_uA;
	u16 data;
	u16 unit;
@@ -3694,7 +3694,12 @@ static u8 ufshcd_get_max_icc_level(int sup_curr_uA, u8 start_scan, char *buff)
		if (sup_curr_uA >= curr_uA)
			break;
	}
	return i;
	if (i < 0) {
		i = 0;
		pr_err("%s: Couldn't find valid icc_level = %d", __func__, i);
	}

	return (u32)i;
}

/**
@@ -3706,10 +3711,10 @@ static u8 ufshcd_get_max_icc_level(int sup_curr_uA, u8 start_scan, char *buff)
 *
 * Returns calculated ICC level
 */
static u8 ufshcd_find_max_sup_active_icc_level(struct ufs_hba *hba,
static u32 ufshcd_find_max_sup_active_icc_level(struct ufs_hba *hba,
							u8 *desc_buf, int len)
{
	u8 icc_level = 0;
	u32 icc_level = 0;

	if (!hba->vreg_info.vcc || !hba->vreg_info.vccq ||
						!hba->vreg_info.vccq2) {