scsi: ufs-mediatek: Prevent LPM operation on undeclared VCC
authorStanley Chu <stanley.chu@mediatek.com>
Fri, 24 Jul 2020 14:16:27 +0000 (22:16 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 29 Jul 2020 02:59:57 +0000 (22:59 -0400)
In some platforms, VCC regulator may not be declared in device tree to keep
itself "always-on". In this case, hba->vreg_info.vcc is NULL and shall not
be operated during any flow.

Prevent possible NULL hba->vreg_info.vcc access in LPM mode by checking
if it is valid first.

Link: https://lore.kernel.org/r/20200724141627.20094-1-stanley.chu@mediatek.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/ufs/ufs-mediatek.c

index 31af8b3d2b5388435cd7fce82c612ea81617c541..66223fe200fc960cb60ddd70223b81aa21dedeb3 100644 (file)
@@ -574,7 +574,7 @@ static int ufs_mtk_link_set_lpm(struct ufs_hba *hba)
 
 static void ufs_mtk_vreg_set_lpm(struct ufs_hba *hba, bool lpm)
 {
-       if (!hba->vreg_info.vccq2)
+       if (!hba->vreg_info.vccq2 || !hba->vreg_info.vcc)
                return;
 
        if (lpm & !hba->vreg_info.vcc->enabled)