From patchwork Thu Sep 16 15:58:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "gregkh@linuxfoundation.org" X-Patchwork-Id: 513023 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1425308jao; Thu, 16 Sep 2021 10:21:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxD0v5K70gm5Acrj1XtMr+G5xjKVA2Xx1m8Q5SutDNZnzyr14oWewcf+lTsv6TH47adh1o4 X-Received: by 2002:a17:906:b7cf:: with SMTP id fy15mr7573214ejb.397.1631812891726; Thu, 16 Sep 2021 10:21:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631812891; cv=none; d=google.com; s=arc-20160816; b=IkZvk9uaSljw1dCzncd2pWC+p6cDfMKOs4pMV4RsjTcv51eEo7ZQutNtr0oJnwvSIU Zj7bZmUSXa0p1KEmC8VvXBd3DY3GoZ5JjBHRrlGG+lkXIU6mXkbbxUxmWddP/FJeNqaC fS5L3oWvURK/fhSRSIGrTNF5CGoFg/dV+/UKZFxEXc3IFYdX9yjq4h2KR+moufkXq0gf YnpJyr/5ts6Fv7osdKjIEOBHCRmPCr0YNrADlBWtTFYhkW2mZr0G5CclnLiPZOeLQREa RpEFa5AHO1J5t5LogoY2QOsOGHjwspBJc48w0ikviu5MtyFTs2aiudWLDY+mzcQ6OWta UonQ== 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=tBVYH/688GhCjSZxsEEtf1kUOhgfvjKer+OJl80sQwQL8PHcGPfdPwHEZlGW06BL4U tTi0xJ09dRAhYSrCOzl5WvKsFT+OTIiQJZrvlJYqt7Wx8N0rEeLtamgE5nUG0JxvJ4+p UOpgBHE1WJPsJJuyiP4JBbb+JoybjG/qRjK9YzNyH+viWD3VAd/HEnewBOpNe5YoIOTI 6jzznSPzb4WBG74yxolIRr23EwCI0zxIFZhcFDWATuUQdqCjy1nWjaxdd4jJ4KXxPBqh 7K2CqIjqdRJEtLV6DHQBCAbIYNEYoxmPL1iR+s3s5g33qX51wr9roaCLcU9e5f3mx1lZ 2p8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=S201nWy4; 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 eo9si3377794ejc.746.2021.09.16.10.21.31; Thu, 16 Sep 2021 10:21:31 -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=S201nWy4; 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 S1350743AbhIPRWu (ORCPT + 11 others); Thu, 16 Sep 2021 13:22:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:44344 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352222AbhIPRUu (ORCPT ); Thu, 16 Sep 2021 13:20:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 707DC61B95; Thu, 16 Sep 2021 16:42:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810540; bh=IyiNhFKL0KxUs4JnoWiHh+h0HctV5ZgiE4YJXvvLK8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S201nWy4mg7FyK60hIwtjlvaRP/vbJfkTQqFOtwfykLEBEg9VNnCl6MR5Q3bh9cBx q2mIdoaXhny2gDQcKPPwJtKHHO2Uo8b3cUVJUenib9YOQIsVtAOYPEXt8+YhOtyT7B Vm+Bs5joVhJ21pXeZUDU70mWsZ5FhEe3UH0iT6yc= 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.14 179/432] iio: dac: ad5624r: Fix incorrect handling of an optional regulator. Date: Thu, 16 Sep 2021 17:58:48 +0200 Message-Id: <20210916155816.805331940@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@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);