From patchwork Sun Jun 27 16:32:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 467814 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp3283040jao; Sun, 27 Jun 2021 09:30:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7SR/0CfWrvvdqSVdT4sPptYLOs0n/aka52je6dlh/BQNnlboSeeI9obbi1Nd5nZRquPnx X-Received: by 2002:a05:6402:848:: with SMTP id b8mr27730324edz.44.1624811455047; Sun, 27 Jun 2021 09:30:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624811455; cv=none; d=google.com; s=arc-20160816; b=l+2dXIeVVD5a5pjLYTfQEAhyOChaiNOCnJrBvzmAAEknmJTotXdLL8ziGJe4Xw2Dbl GscevFLCzz8iT58KB/ewcn73AMsTp5BC+QC6sUEKwug1uvbqQhWkbled73YUecFUzLar eYCqcEbgxFVbwEg0fYiyJXZQhhU2l37n9dqlnORB1St+GzN9boCiXtyc/cFU+7X1J/Ba 8I/cP36JCWh48/e5Er7B/I6Mtlor8Z5lNtAxIwCUJ9PC4R3vK5rIis536ThQM7970LrQ OjsNO5tIda9VJzA/5HrmVVTFSoGlSqlqDwLtxYHmGhX3lvN9aRjsdlHln5nV0TQZSkI7 QJDA== 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=5ruFEVyO79SQnSMFGfuOEJRLp4hBFibBwEBbyojXtlg=; b=NByVykgdnXkj5hTgSM6JxeEb7du9+YpIHMUzpGLZVh0cWuw1pYGAf2wBYsPTwBXV6b JZMiN03SImUkApjT7vsjC8KUI6gRixfEd9607Cw/dhuMN1xDnGmTcilG4lalj9yyXlUb LBA1GsqVL6UOiBF0ggZqrd1EbtEpZc2AfiATN5Lax2BUoEJRXKxX7+bduAsk+7siyUuc z1FrEGTqyWThUutkcsHBw/flwjahfyfib5pTCEqgCbYPgs/j6mPCVybidr3gp0x8IU9X HfdMKLpyaYe8nlq+3IqNys7kdxqNYyEtrF4STT58achxKl3qsxjIMHQKQ1soUGetd6sT a3tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="h/bAUfU3"; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 s27si11202998edy.94.2021.06.27.09.30.54; Sun, 27 Jun 2021 09:30:55 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-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="h/bAUfU3"; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 S230315AbhF0QdS (ORCPT + 7 others); Sun, 27 Jun 2021 12:33:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:45330 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231272AbhF0QdR (ORCPT ); Sun, 27 Jun 2021 12:33:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ED31F61AC0; Sun, 27 Jun 2021 16:30:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624811453; bh=e+5por/x6H1B9nYsnTR4ERVYy05CrPHFtL6c7o+YNK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h/bAUfU3McnwuFfkS+tBojxE/uU5kvGKcYoYkaGTh+4kkdfagVLimG5ZReQRmGfVt DQIckka7uc0dooIqITCWts4Bhpqq/zdh/HGQIK3R5am5u6uhHKp/I16CnRFqcynaMQ vPBtlsTrob+U3usZtxJeORFPT3sM2VQxNFX/E/BLeNZl+JLsn+BbiA4oqmaHtIQLt3 1K1PQ5uUaXabz29gO887A1BKZQ0IxxbfPoRvK9Ef86eaWGuK9Sx1ONAlxMEC4k12ua IdllCrH+gckgxK22ngU+TXJjY8Y1UqEqNBKpxqNMspEoq0w4XWI6PY77k8rncMmbNK UjdcsTRfT/aEg== From: Jonathan Cameron To: linux-iio@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org Cc: Jonathan Cameron Subject: [PATCH 08/15] iio: dac: ad5624r: Fix incorrect handling of an optional regulator. Date: Sun, 27 Jun 2021 17:32:37 +0100 Message-Id: <20210627163244.1090296-9-jic23@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210627163244.1090296-1-jic23@kernel.org> References: <20210627163244.1090296-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Jonathan Cameron 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 --- drivers/iio/dac/ad5624r_spi.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) -- 2.32.0 Reported-by: kernel test robot Reported-by: kernel test robot diff --git a/drivers/iio/dac/ad5624r_spi.c b/drivers/iio/dac/ad5624r_spi.c index 9bde86982912..b4888c8c14a2 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);