Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2319218pxb; Mon, 20 Sep 2021 18:42:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLrRSfKc+sl5PeBrUYpbQ/nWYwzTBqZ5cCtkpcxFqy11aio+H9G7rjinoQwwza0hDtWP3L X-Received: by 2002:a6b:7842:: with SMTP id h2mr3093552iop.157.1632188530107; Mon, 20 Sep 2021 18:42:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188530; cv=none; d=google.com; s=arc-20160816; b=MVxDfOsVnNJ23jiY6KFvnEKjMaQgweZFvBCj7bZoSPpl6asV9KFTDtNF1Re9cEENHU 9JJ/lyvmNZZviug8o6t40MECJ+olYw2uRTqFHEoYIDab+D86e89wdb0bQP97PI8p2RHx pvhpDaXFTkkYDVlSItPUu5q+gI60tjYWmR1n+yg9ZOGgfjcaRm1b+OBhI0hVnu4/pxXI XUZ/X9AtaxY4k6QgmWbi0NZ5u2MkIlThutX9Mh1GFcz+kTFzpzDs6jJf/sOOzRtWr9hU 9qv+dkbO0YDr65AMqdNmn8a70JeCwMt3ZzcVVAmsc9ov6jP+RGZueicpFjiNFXPKi/hy ml8g== 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=IuOGy2S11/ORyfCMmBg4DYY4v4zzJpJl2ZZ1OJCtnH8=; b=UBu6q46ADoWWB0mGvt/8eOu9ptgE88x5ozAvgd/1x98IZjS6ZlTrpArEFW6dbKXsxK V44pYhAo0/Jnx84daMQUhaEM6u/aRiYVz5rSC59m2A/NPHF4aLu/FLbbhXEGF31IrqMn DUyBBXLSOmJgLE1c85Hx2mnYwJgPn2Lt9YcFaBqDctU74j8Ci2fsCmM69ws7MmBXYavv EQw+m74xxQZXFWYTa/Iy4ZLFsG4NWUjYVuTeHCpX0XkYIh7jsYcjVijbjiNeXEOQWCof iXjkY4drI8RsxNAM739E2m9SnUdnzCqWhzBmOQFAmWH8mGSVE8/jwypLXl7bv75zKov5 0r3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oRxKxrIJ; 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 h15si14922111ili.51.2021.09.20.18.41.59; Mon, 20 Sep 2021 18:42:10 -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=oRxKxrIJ; 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 S244556AbhITQwg (ORCPT + 99 others); Mon, 20 Sep 2021 12:52:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:38784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbhITQtt (ORCPT ); Mon, 20 Sep 2021 12:49:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B62AA61222; Mon, 20 Sep 2021 16:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632156502; bh=SY6y8U71EGd4aHjByJyQV570JiwGzg0mb0VxOk/josg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oRxKxrIJ43R1000IaJpgo4WvubFRJ3RpAxrSbIpbnwPCuNRNN2uHAgVZAq/b1MtlI A6yfs3LSwmGY6oPzf2RqTgDO6xtv2ViC6MbP1QuOX193e24WbHCK+nZswEQkSxgDsf hgLgfuCCDf+J2KWoKCYN31Q38BMgY0rez5v2aLDw= 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 4.4 087/133] iio: dac: ad5624r: Fix incorrect handling of an optional regulator. Date: Mon, 20 Sep 2021 18:42:45 +0200 Message-Id: <20210920163915.491493104@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163912.603434365@linuxfoundation.org> References: <20210920163912.603434365@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 5489ec43b95d..e5cefdb674f8 100644 --- a/drivers/iio/dac/ad5624r_spi.c +++ b/drivers/iio/dac/ad5624r_spi.c @@ -231,7 +231,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) @@ -242,6 +242,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