Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp273039ybi; Wed, 29 May 2019 21:07:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxN0NJBB+T7356vlY33cZr7Y9U0ecOB8OeYniCZB0EoMEvW6kaQI2zcG2jIZ79Bbu7QiSBB X-Received: by 2002:aa7:8d85:: with SMTP id i5mr1655509pfr.242.1559189274112; Wed, 29 May 2019 21:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559189274; cv=none; d=google.com; s=arc-20160816; b=HA+22lLh4k/kHDttDEuiNKodCRg9QDKLdKbp+C7IyaSMzP9ARLhX74upm+KThYOJn2 XM0B28Q3KfQ7wlTzOTkhTHYcRiWHkm4vvpxaRChpnn2cT700TvMb4C13TY/al12g4Y9/ sz4rngE5gPsIOtKy0N9A6tWyOfuwk/CbJFU+y0YHUc8bHLGgyeU6GUMGe33dLvmeDyWc USioU8kt842N0EmGbrjWJrmssAJWV1711jTFHkbsrEB88F9znVc08lfQ5F8SAXDOS4Bi xopQtJ1BfC6z1kOXcEaLmZ+r8BSatsRO01Y1Ceku8stw8Fo9QT492m0dyV7kuVWS+IJ7 V5CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=16FPMinv97YmhMHF+pFUKwgUjz4CkgQRjbCPkK+VTvc=; b=qPIM8+qGrgCa1XXQDsBQ/dPPGrmlXhryxdTDTm4pX8Lc2GDICHg2W3okAEqFvdiITH 8bHNpIn1VRLLzEbVOqhwrLXa+Gz3RFRk75SWk8lL0NKxkxkl9SsiELBZk3bRhGs/bP7y a00R9LAz3BxRh1W8wccKoPibr2cbYs4AVnfNUs5bIlKxpkVALrDeRDQu7dss53WCVPVg PRvGKXVsma6NDbQppZdaxgRE6Zdqe39a9vZLc5d09N8pQs9mvKeq4D+uMAMqGj3gMIpk Zu7SlVSoRXgjMvdw5+FY3aplTyaJP54qY5/UQHRoHlXiMOG4IqFlv/GwkaSkVo5iL0+j HPGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OiA8ASa1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l2si1694287pje.54.2019.05.29.21.07.37; Wed, 29 May 2019 21:07:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OiA8ASa1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387739AbfE3EFR (ORCPT + 99 others); Thu, 30 May 2019 00:05:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:48242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731244AbfE3DRq (ORCPT ); Wed, 29 May 2019 23:17:46 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F0F6324714; Thu, 30 May 2019 03:17:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186266; bh=YRNX5ot3l87qGEcd39al6ExW3hbakWOuGQKFDD2NnP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OiA8ASa19hYiubVfq1ss1n6Ob0kkOSFohlCDvD/yDeTUKdhmRgJsROLUSoXY9WW0O xgMo4X8TX3748SG3zbg/ZSfgIa6QIpc+50smmSvUqwe8gYbMjv6K5KeJIJ4abNaIpe JNhoqjXwqAFPIJx4eL6TP+SMc43d2kk8SaOVibfI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stanley Chu , Avri Altman , Alim Akhtar , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.19 202/276] scsi: ufs: Avoid configuring regulator with undefined voltage range Date: Wed, 29 May 2019 20:06:00 -0700 Message-Id: <20190530030537.758631270@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 3b141e8cfd54ba3e5c610717295b2a02aab26a05 ] For regulators used by UFS, vcc, vccq and vccq2 will have voltage range initialized by ufshcd_populate_vreg(), however other regulators may have undefined voltage range if dt-bindings have no such definition. In above undefined case, both "min_uV" and "max_uV" fields in ufs_vreg struct will be zero values and these values will be configured on regulators in different power modes. Currently this may have no harm if both "min_uV" and "max_uV" always keep "zero values" because regulator_set_voltage() will always bypass such invalid values and return "good" results. However improper values shall be fixed to avoid potential bugs. Simply bypass voltage configuration if voltage range is not defined. Signed-off-by: Stanley Chu Reviewed-by: Avri Altman Acked-by: Alim Akhtar Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/ufs/ufshcd.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 73156579e9885..3183fa8c58578 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6822,12 +6822,15 @@ static int ufshcd_config_vreg(struct device *dev, name = vreg->name; if (regulator_count_voltages(reg) > 0) { - min_uV = on ? vreg->min_uV : 0; - ret = regulator_set_voltage(reg, min_uV, vreg->max_uV); - if (ret) { - dev_err(dev, "%s: %s set voltage failed, err=%d\n", + if (vreg->min_uV && vreg->max_uV) { + min_uV = on ? vreg->min_uV : 0; + ret = regulator_set_voltage(reg, min_uV, vreg->max_uV); + if (ret) { + dev_err(dev, + "%s: %s set voltage failed, err=%d\n", __func__, name, ret); - goto out; + goto out; + } } uA_load = on ? vreg->max_uA : 0; -- 2.20.1