Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp242730ybi; Wed, 29 May 2019 20:29:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxJPonP12ujmzIsI5hoQdH4/81xVV3hZO9wKU1iAu2t8Ea2UwCS1/D2DPb6mt7kt6TW8Gm X-Received: by 2002:a17:902:121:: with SMTP id 30mr1599423plb.314.1559186994234; Wed, 29 May 2019 20:29:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559186994; cv=none; d=google.com; s=arc-20160816; b=wWdZ8X0pc50H5fSmH4O+DAL9nvZH/GNw8M7z5TgGpr+rhGUK/EgC0Iz1MJitEm43Yb oJBvl2LhfYZJgfaBOZ72MIcLqpate3Xcb0dMNFJq/WgrlhN5UUwJrfrBxABKIGlgCPsq DrIE30sXIatGXGLCoH6hN8fVYf4GfQ93bv7WXrp8U111D98wtMroPOIGXEp7honaEUSA tQOe2x//OWxtzsNN+TfLKiX3HhKlhv8QvnzYnzTbTTeKMC2ppQyomv/rzpklbISppXTJ StMcPhZ0/nMEctGLBiSCOdoCxgYvPMRSnykpkcqUvzhHdW2a5dyq0pcXA7aHX+g09Lyl q8vA== 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=xIuPn+gWazKEq6kcC60ZS8HY43Sg96X1fGpyGOw+9KA=; b=FZuvpa1SK8H2OLflSy5t5FLxCKMVytISQc2G8/tBoOp9TIsyIh+bB9kfxIHdqGmvef whOzSmZZj1LM/qOKj6ysvv0Pn78Qel3h9irE3VfJWhvHUsXDmJrbz+OjcczJ5R/jdPPM Bq7ONJD8z3V0kh5WpoxpewtaX/uXLFPtLpBySejoK773Cwz0R+C9UHQRdcfDSvKIWiqh v2jYWOtsUjpTkMcHpfF+2dUMfS1g6lVA+KwfuKYTe0n1qg0391z2FQbF5HWxFzphANNY ct+IhlyoUtRc4ViCq0ZH8M0KYOT61P+KDeRTscc8A298oereKspON5VfIYoMKc/jejIR 1X5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tp99IVbY; 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 h5si1851580pgl.60.2019.05.29.20.29.37; Wed, 29 May 2019 20:29: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=tp99IVbY; 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 S1733304AbfE3D16 (ORCPT + 99 others); Wed, 29 May 2019 23:27:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:56456 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731078AbfE3DTp (ORCPT ); Wed, 29 May 2019 23:19:45 -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 2A427248AE; Thu, 30 May 2019 03:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186384; bh=/yWJP0rcANcNhtnq/8KxUj2EE2aniIXHmsQP1TEQToo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tp99IVbYddypPJQ4nA9XirYJd6uoiTbrmaS4cJAw4e4e0zYvGFJvPx+tW37m9XQvf g3x/GydJe/BLhWu/Nx0Syf0t2rtVdP5VATyuNbA+JAYqFYb7m0zX7zoG0nwd/YUq06 XHCoUeHE8G8CsFTh5QIQR4yVpctwUnj8/HosQmM8= 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.14 150/193] scsi: ufs: Avoid configuring regulator with undefined voltage range Date: Wed, 29 May 2019 20:06:44 -0700 Message-Id: <20190530030509.112113839@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030446.953835040@linuxfoundation.org> References: <20190530030446.953835040@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 c2395b8e72894..d8f0a1ccd9b19 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6580,12 +6580,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