From patchwork Thu Sep 16 15:57:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 512980 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1357842jao; Thu, 16 Sep 2021 09:11:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySTTGuIUccjMSkAuQaaLrDbALHr7bcd6HPpDQMJ+wmLZi+4o66HDJhO27OMRU+5NjF/XGv X-Received: by 2002:a05:6e02:148e:: with SMTP id n14mr1692022ilk.319.1631808698514; Thu, 16 Sep 2021 09:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631808698; cv=none; d=google.com; s=arc-20160816; b=yujz8+jlZG/RN3Q4g2i5n6fPetyZ6K1RjEITzkideUFNAt7xofuDVeoGrx3goMu5ei rp5hHzD7Ba39Fa3Cntlpr1fuRDjTVi8xyZIV9HR4lKeM7dWGmoj404s5ihDHW3qZBHkv brDzlbXtgPn3VccQlG9pDbHibRdPGcC6mJAVU7uILx5h3cCjDWKFkdMuy2YId5woe87E UjQm3GYfs7sqi8EBaWPqiW7Sl2jl4sFHYSN6g6SBtl0x2ieIRaaA9Q+QK0ZAq12oq9hD u0fiN5AqKk65D2cKBnBPIHtTV1YvYl/VxYg1QdAGBykQIGxcYULS+sviImYM/cy3aPVC 9sTQ== 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=q67vG7pdujt42clvWSd46v8hCjqkuIiG+Tvq6exw2Sw=; b=GrJ18Z6Z7VT22tR5Ax4RVdtfNhvQYJ0YeUER6tPGgWp++9Zt3j7OxRkdwYQ9+CeD5C 9QKaZFgJScDIMOjXXwcaiTajS0JwZpWNpsbykIFq24mnmMzIhE4Pf8C0aYq/njucHCJH 4Z5k+4Vx/q2OpcusJnn3PIEQoOAH48mR4/rPDYBL6byOtvKlC/1IzUKjAOBW2VXoBaQU ZW92jYrWdrhGrUhy2H0ipL2IQDTJEjgWZzUoVXvrSG05OghFR5if1YolDUQCuTBXTQNd 49Mbmu8qoDPqL8KRVNp+uNvbPsaUMap0v94/dzE5RCz+4WJ0mhelu83ECvEV3SH4JZSW TZ7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IBKL6b9G; 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 78si880224iob.24.2021.09.16.09.11.38; Thu, 16 Sep 2021 09:11:38 -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=IBKL6b9G; 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 S235765AbhIPQM5 (ORCPT + 11 others); Thu, 16 Sep 2021 12:12:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:48354 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237354AbhIPQKp (ORCPT ); Thu, 16 Sep 2021 12:10:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D476561350; Thu, 16 Sep 2021 16:08:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808514; bh=l5v/rb/8ioYC6MGBYgVUaNFI8j0ENAXTj6L18sSOvjM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IBKL6b9G+xPbSfS/Rz7CsH92eLdVYuRGRp34mcA/wfaVC5psRhJmAMbTiarvSpczs W9Svvr0tEhNuqu5AY9IF3RDKDZQp7xL4FVKHAaKPAb79nLOSS+3sIf7vs/39QocdQl PvxVoMt89grArNCAsEeBLvrKtIpVaLXSnF6deCT8= 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.10 120/306] iio: dac: ad5624r: Fix incorrect handling of an optional regulator. Date: Thu, 16 Sep 2021 17:57:45 +0200 Message-Id: <20210916155758.160862677@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@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 2b2b8edfd258..ab4997bfd6d4 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);