From patchwork Thu Sep 16 15:58:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 513000 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1387374jao; Thu, 16 Sep 2021 09:41:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxD3y+/03e20BtB8sUETMGpuH3gmWaG7KI2IOfLn5Mi3BXOAkJr73BazOdXJS1EZIpUatJy X-Received: by 2002:a6b:3ec4:: with SMTP id l187mr5118556ioa.217.1631810485562; Thu, 16 Sep 2021 09:41:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631810485; cv=none; d=google.com; s=arc-20160816; b=Dd7e3rpaEnpKI3dzweUS/q1XEs+ugif2X6uInSE16QT16fGcO+AsbkhOoX0nePdh1J GRmQUi/QTg97LvmyvX5LW7d+FkMiVP/ck2ixRm3irYDRN3ysi0jyl3tdqVFFl4gw0zUe iPiSYpsHPXyRs1T2brSMKF6EZUx6NH2IcnJaQUBnpeVGmhMdj3CWAITVXx0GZuNTUhcE DlWzxLZ/ZEJCpFxym91NgfTe+ukGjl2aJ31O/HBeSv1FTfMVmD+digZzdF+bHaTSjzkb 0vaOMpqrKuwNRlwAdtrUqQnzvJvsI5nr68tLLR37rgdGLvLHxEAeMQde/hf1wbgKLqUR g/Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ikeRLZhFtH6xmQOtcdO/mlUfJ58uLx7X3GVxKTlcsN4=; b=MwujHOl42Lafx8W57qSe5aS6a7Y7HLkgKaOUYShw4Ghmh/FtYT4ATO9Mat1/ohoGCh XAQswut/CsXjwo3ESU0BpYDt667WvtcklFH/JdMr0XZVMRl3LeOMoza4mBg/HkQxo+DO ZL2Vgb/Z+iIPUsfOZTskVAeA1ZuRK07w776NUa1+q44ZrBY6rvHYFMLIfMTCZdnx658u V1O3JwzF3DJKJxgyaD73gzFDrKAi4Vt3NetpLY5C+5cL2gl0Jdd821jXcKRSWwMW61wJ IsgXY+M4D6nJMjT9EO+N9tZHhjqE/8WW8ascTjkL/s+vPo7cptNuAiJW2/V72KMM8d0W LI/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xyTFxEFY; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 189si2833022jaj.45.2021.09.16.09.41.25; Thu, 16 Sep 2021 09:41:25 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xyTFxEFY; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243178AbhIPQml (ORCPT + 11 others); Thu, 16 Sep 2021 12:42:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:51356 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241780AbhIPQkk (ORCPT ); Thu, 16 Sep 2021 12:40:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 60A7461A0C; Thu, 16 Sep 2021 16:24:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631809440; bh=IyiNhFKL0KxUs4JnoWiHh+h0HctV5ZgiE4YJXvvLK8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xyTFxEFYB+ShqdZSy/nSu81LJ9R04kzsdgk4i9x/zXiosMSA8VNfzZFhdgjKnuSEU 8Zs7rwutOzPb4lwnKDkzc7UBhv4fio7RWFYvy43wRTudrBNKL0fu7CRP1xsvVYMtN9 mOtZy58JOtI71qomPCXlnbPQnuf81JtqpzMvsQqM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , kernel test robot , =?utf-8?q?Nuno_S=C3=A1?= , Sasha Levin Subject: [PATCH 5.13 156/380] iio: dac: ad5624r: Fix incorrect handling of an optional regulator. Date: Thu, 16 Sep 2021 17:58:33 +0200 Message-Id: <20210916155809.383028702@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155803.966362085@linuxfoundation.org> References: <20210916155803.966362085@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jonathan Cameron [ Upstream commit 97683c851f9cdbd3ea55697cbe2dcb6af4287bbd ] The naming of the regulator is problematic. VCC is usually a supply voltage whereas these devices have a separate VREF pin. Secondly, the regulator core might have provided a stub regulator if a real regulator wasn't provided. That would in turn have failed to provide a voltage when queried. So reality was that there was no way to use the internal reference. In order to avoid breaking any dts out in the wild, make sure to fallback to the original vcc naming if vref is not available. Signed-off-by: Jonathan Cameron Reported-by: kernel test robot Acked-by: Nuno Sá Link: https://lore.kernel.org/r/20210627163244.1090296-9-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/dac/ad5624r_spi.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) -- 2.30.2 diff --git a/drivers/iio/dac/ad5624r_spi.c b/drivers/iio/dac/ad5624r_spi.c index 9bde86982912..530529feebb5 100644 --- a/drivers/iio/dac/ad5624r_spi.c +++ b/drivers/iio/dac/ad5624r_spi.c @@ -229,7 +229,7 @@ static int ad5624r_probe(struct spi_device *spi) if (!indio_dev) return -ENOMEM; st = iio_priv(indio_dev); - st->reg = devm_regulator_get(&spi->dev, "vcc"); + st->reg = devm_regulator_get_optional(&spi->dev, "vref"); if (!IS_ERR(st->reg)) { ret = regulator_enable(st->reg); if (ret) @@ -240,6 +240,22 @@ static int ad5624r_probe(struct spi_device *spi) goto error_disable_reg; voltage_uv = ret; + } else { + if (PTR_ERR(st->reg) != -ENODEV) + return PTR_ERR(st->reg); + /* Backwards compatibility. This naming is not correct */ + st->reg = devm_regulator_get_optional(&spi->dev, "vcc"); + if (!IS_ERR(st->reg)) { + ret = regulator_enable(st->reg); + if (ret) + return ret; + + ret = regulator_get_voltage(st->reg); + if (ret < 0) + goto error_disable_reg; + + voltage_uv = ret; + } } spi_set_drvdata(spi, indio_dev);