Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp444971pxb; Thu, 9 Sep 2021 04:45:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaBiKnwSfCujeQsU70wT83uEtW9RbAwLVxDmSqAHpMBJo5JhX0plGipI/f8wzw/RpWIfda X-Received: by 2002:a6b:b4d3:: with SMTP id d202mr2332610iof.8.1631187943929; Thu, 09 Sep 2021 04:45:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631187943; cv=none; d=google.com; s=arc-20160816; b=BpXYID3lpuVE3PLFKlkKprKKkp1r5kf7w77TxwMmC/gDJfNZZ6LfAGpRCC5qCtkvKx 9NAV6psbdpX/0WB/4hTg1QbtAShnmvg70St9vRxFxO3//1glVPVBxYFpM9Tk3SheJ4Hh 4MHU3zDoI8ye3WtcKYq9QwIUWBR5lHSqXoWDopGusIR9cZS2RZ1Wzr4Zoa912ZEjxEB7 nzUQWBrwvKonnae7aHZk+N4wfPeqRiNWEEwjQZ79ORLzazKaKWMahSMAwT5VdNfxHTvb 1l9uCxzf1epXjtvCnQp5zMq8gHPXKZ/vyInbhOjYTcD1ZznfVADoyX0n5OU2k2oN+wqm u6wg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ikeRLZhFtH6xmQOtcdO/mlUfJ58uLx7X3GVxKTlcsN4=; b=pmusTxEUjIZPqMIFARuX3V2TrBWrf2nIYqTK3KHDUIS/SkgDHfKvjKyKAJBl0gmovN lTZh64G6U4iDdW9B+s9g+0vl+gKmPX9kk7WdQYVV+autjK2RiJciGJ/627bIAUR7ilnv Nsu1qt0tuN4nI1f9x/fgk0U3aDQIJ6Vcq8aZEDpNrIvoHf10bnJ9wPvk7deSAzVg4PAc ZD+sbIFdhUrx0HTiHzmI83/AiKWVoXz2xY3s5nkR05m0bzpOmI9xzSGG3RTFcQUjZsS/ fYiee08hZ4vKqrBKIl6WkyAxus7RzPQBM26gG7gI7bA+XpCuHIQvbaU6nZWY/E6G4B5f pcKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qm5I8dhM; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h199si1482239iof.50.2021.09.09.04.45.32; Thu, 09 Sep 2021 04:45:43 -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=@kernel.org header.s=k20201202 header.b=qm5I8dhM; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236911AbhIILn6 (ORCPT + 99 others); Thu, 9 Sep 2021 07:43:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:46342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237087AbhIILmr (ORCPT ); Thu, 9 Sep 2021 07:42:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 80FD961100; Thu, 9 Sep 2021 11:41:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187698; bh=IyiNhFKL0KxUs4JnoWiHh+h0HctV5ZgiE4YJXvvLK8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qm5I8dhM2AmqpAdAhvTUPWi5c+dfN3MaQQqKQllSsP1ItlYBiw4Ud/90cnoxcFMaB 0VD41TWOQNb0qadvYMFHdPHnc98pou3TRhv1NKeP7tUVJqwcIlGYY2ROPtLugBhw+d eDySnV9p3DveGJzLkLjGwOWx7QLd4IgMFWhTAAVHLNgig5YxwFKzsmVhKe7PtbEEL7 s67Bwu9FWlxWWVQrfguy2i9hnS7IeSKFk07QSweUT19wlmOYBwkBjzGeTIGrhn0hg/ xGKAeVjyPewaMXDToorCfRUyzLGBIj0FRFNn/fL8L+hyItIUSyqlh6Chf2HXlf9yaw PozPiFCMmpWZQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jonathan Cameron , kernel test robot , =?UTF-8?q?Nuno=20S=C3=A1?= , Sasha Levin , linux-iio@vger.kernel.org Subject: [PATCH AUTOSEL 5.14 024/252] iio: dac: ad5624r: Fix incorrect handling of an optional regulator. Date: Thu, 9 Sep 2021 07:37:18 -0400 Message-Id: <20210909114106.141462-24-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore 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 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); -- 2.30.2