Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp2565395lkm; Mon, 20 Sep 2021 18:51:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjlVYq/ZR/BBijxSX7MCd+WFpGEUfcQxYU8Xx//rQDqbeW3FG38r5kyVhI1MRXVIswx2bR X-Received: by 2002:a02:270c:: with SMTP id g12mr10277847jaa.75.1632189097400; Mon, 20 Sep 2021 18:51:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632189097; cv=none; d=google.com; s=arc-20160816; b=Ri6oR5oAcV66qiH7i74PyurNGGNVtoQAZpX0wbCXaZ1KgCWwu/aNbwZs5LJlzTrObK 41taZkl69tMqAOuaw5OTs/7rmkRuP82q7aFcIhXTPDNxBk4gIQkLeC0DRbDsnWX8r3A8 SZtYdkPPP7aQGHx8IPudcMwxYzcAnTRcKsQ8Zrp0PM9ozkDo6xRrpmD/AYc1Ltd8VPS/ lF+Bl7Teu0LKRxfd2Sjxe5fc6UldaroiMKO2NTSS8t8i+KGtrBlcydb9/JbHwfphEXry UU5PCipGbRWAntfC7nN9m5U+1h0ir/FctNMYI3c4YzewcaCHxwUibyI7HDgqbzd3+WFA SMXQ== 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=XM08p4sBpCrMWTCGgoNYKSD8dMp67bzpI0xQwhfux2k=; b=m4wQrq8ebKjAKZ2RyJvm2lW8TZwKcYdme0G1xa/w/g0ALNc4MN8Z24ot+TCuEJva+h vxkcy0nlTfEUa9KwLlW6lKs8DowEoeOs0OizEFb+JcBfGjpintokRDKU2kdupmPwfBhL 0wDWkS30iT4KmLb/iSA351P20hizlpJ7jeIbTm0aY9WO4uu9fVEVrNRqmQ9DfQuVXxdm MNYBnxNL2b4zFdkqETQ7h05Daiyw1RUDfFBCZU3QwgOQcCxfiL8/Oe7Gi7mRVcdL1uU3 lBG4PG2wOn9wRiXheuZDYr/CZdY95kOxm0PI28RiB8q2yA2w9FlTnSHHo7MNokZeE57a Ah4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xctM365+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 d10si13586802ios.58.2021.09.20.18.51.26; Mon, 20 Sep 2021 18:51:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=xctM365+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S1358576AbhITSME (ORCPT + 99 others); Mon, 20 Sep 2021 14:12:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:33250 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350304AbhITSGA (ORCPT ); Mon, 20 Sep 2021 14:06:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F3F2F63246; Mon, 20 Sep 2021 17:17:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158271; bh=omYj6XUZbaTMM9lekXdod8fKtmqaxDBOsY1wjQ6eYwI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xctM365+uNEAL5sH0xf9eTANqs4qRa8FwddJkyprDYRYXLPdGbuvZ6jq343bis/OV imZ3hmuxbVC1fp85V4+P4S7RrxxwiMbOJgqCW7rSVkxu5QJZph/6LdMO/uFGbA22om 4i2y4dC4khO996a/66a5vdPL5RDa6lQoKV8WqV/8= 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=20S=C3=A1?= , Sasha Levin Subject: [PATCH 5.4 078/260] iio: dac: ad5624r: Fix incorrect handling of an optional regulator. Date: Mon, 20 Sep 2021 18:41:36 +0200 Message-Id: <20210920163933.788226704@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163931.123590023@linuxfoundation.org> References: <20210920163931.123590023@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) diff --git a/drivers/iio/dac/ad5624r_spi.c b/drivers/iio/dac/ad5624r_spi.c index e6c022e1dc1c..17cc8b3fc5d8 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); -- 2.30.2