Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp695201rdh; Sun, 24 Sep 2023 07:50:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHzA5GUj3CYPT3n4aXqX8g5ubwNWskuVc41sciKAXA4Em/EbWjfFYrV4sV0nSQF65GbSL2g X-Received: by 2002:a05:6a20:100d:b0:13f:5234:24ce with SMTP id gs13-20020a056a20100d00b0013f523424cemr4410302pzc.28.1695567058345; Sun, 24 Sep 2023 07:50:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695567058; cv=none; d=google.com; s=arc-20160816; b=KGzkZAHr6+AcJ0thuTSoHCes4ZB+IYbF1Uh0hmk6ifEC17C8HUMsY0gJM4JnnAP3Eh BLrkfVjS68BsMXrdb9vLj6yvlMeU39mNSPkP09iIeRTd3RKGZqS+/uUr5MYazhnBGIrT eAr7pMqurC80rQUCXP22YW7AXREtcwQhfqTK5Pp/ejyfXuYlhh+DAjhG4HWYodYKPTiK PPfJYvw7bIurqAIiUfozC7D0RHadB3rSAVUeISR0Gvu4EkFEIsMFHbbJe6Jp0ecKd3aE vTmg5D3QI+8zhgqm9qMFf8XKoy5bWKa+iyefSzyX4kcRKnTcBmosvA5nb4GX5zd2d3JU YH+A== 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:subject:cc:to:from:date :dkim-signature; bh=7AIs706Sfdca1aH0KhHClVYOvUBZxEWFlCytVCSqfq0=; fh=t8e9c1x/pUdxzFHTgxrHaRHmhHHp6+z0Yz5Rx5vVa60=; b=F97xA0JL0HwDOKvSAyIsGxjGQUUhLvQTHKX+qaYO89QPQmHLDbUqXTU7WZIL1vYdXN PpuvFQipkGxhopN7trdAL74X7RlcDvpF1foxhcbZwc6MakBAIs8piJRNSefPvT1QBvUR R/+tebuC4BsUUNifUxsPGGAx5RuUFQl3zw7wbrG/grbziX7GyiOxKY7zZlsbBB4Q70DG NoAzhKyyPs08SnZeyAxZhYgSHq6dq+YImNw735fEvJ+pKzUU377eRx2G0kA2V7yuxLr6 r0jtm2qY7tOaoNPub8r6gdGIZhi33Qu6AI9Sb/a8g2H44dyBsEzxmzvXJc5K6XyBl7JT PZug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Dbx1lwT7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id m8-20020a056a00080800b0068fa8499af1si8412015pfk.11.2023.09.24.07.50.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 07:50:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Dbx1lwT7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 1E3F280BB996; Sun, 24 Sep 2023 07:50:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230118AbjIXOur (ORCPT + 99 others); Sun, 24 Sep 2023 10:50:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229973AbjIXOuq (ORCPT ); Sun, 24 Sep 2023 10:50:46 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08113FC; Sun, 24 Sep 2023 07:50:40 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC351C433C8; Sun, 24 Sep 2023 14:50:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695567039; bh=PA4HpJZ/oM4RsAfWDJNFj966iei9Is4OvBg8CiMxIrc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Dbx1lwT7m8TFgbEUbh0Fsnu2wvoR2AuxgNOMNEKhXWSrvpM2bKoXBATVzpnuPxIsw puNDNe/sZxU5sVsgk8aDSXS8Ocdy5huNObC6XzMgamPUzltP85qtRhy8A7Ju96+uQt H10yyzZfJ1c0Esy6RpYG4B6ZpuNKWfVXVxK5QXRNQX8LR8O6beglAut29btsPQEvLs fvq3FZxZ7rUyv7LhZvxzpdy8JDbba1s6wPpkjIpYQ8FrlGxn+RSMHK9SxKp/N2ngLz D3cNY4aYLVGOLswwZHwi/ETJ719iF3YzjncPNwLu+0I3fDPkaq9qjVPor30C5Dsrv7 a0qFqETOy5Wew== Date: Sun, 24 Sep 2023 15:50:32 +0100 From: Jonathan Cameron To: alisadariana@gmail.com Cc: Alisa-Dariana Roman , stable@vger.kernel.org, Lars-Peter Clausen , Michael Hennerich , Alexandru Tachici , Liam Girdwood , Mark Brown , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio: adc: ad7192: Correct reference voltage Message-ID: <20230924155019.1675a37d@jic23-huawei> In-Reply-To: <20230923225827.75681-1-alisadariana@gmail.com> References: <20230923225827.75681-1-alisadariana@gmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sun, 24 Sep 2023 07:50:56 -0700 (PDT) On Sun, 24 Sep 2023 01:58:27 +0300 alisadariana@gmail.com wrote: > From: Alisa-Dariana Roman > > The avdd and the reference voltage are two different sources but the > reference voltage was assigned according to the avdd supply. > > Add vref regulator structure and set the reference voltage according to > the vref supply from the devicetree. > > In case vref supply is missing, reference voltage is set according to > the avdd supply for compatibility with old devicetrees. > > Fixes: b581f748cce0 ("staging: iio: adc: ad7192: move out of staging") > Signed-off-by: Alisa-Dariana Roman > Cc: stable@vger.kernel.org Looks good but I'd prefer dev_err_probe() for the error messages. Obviously that wasn't true for the existing one but as we are touching the code good to clean it up. Thanks, Jonathan > --- > drivers/iio/adc/ad7192.c | 31 +++++++++++++++++++++++++++---- > 1 file changed, 27 insertions(+), 4 deletions(-) > > diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c > index 69d1103b9508..c414fed60dd3 100644 > --- a/drivers/iio/adc/ad7192.c > +++ b/drivers/iio/adc/ad7192.c > @@ -177,6 +177,7 @@ struct ad7192_chip_info { > struct ad7192_state { > const struct ad7192_chip_info *chip_info; > struct regulator *avdd; > + struct regulator *vref; > struct clk *mclk; > u16 int_vref_mv; > u32 fclk; > @@ -1008,10 +1009,32 @@ static int ad7192_probe(struct spi_device *spi) > if (ret) > return dev_err_probe(&spi->dev, ret, "Failed to enable specified DVdd supply\n"); > > - ret = regulator_get_voltage(st->avdd); > - if (ret < 0) { > - dev_err(&spi->dev, "Device tree error, reference voltage undefined\n"); > - return ret; > + st->vref = devm_regulator_get_optional(&spi->dev, "vref"); > + if (IS_ERR(st->vref)) { > + if (PTR_ERR(st->vref) != -ENODEV) > + return PTR_ERR(st->vref); > + > + ret = regulator_get_voltage(st->avdd); > + if (ret < 0) { > + dev_err(&spi->dev, "Device tree error, AVdd voltage undefined\n"); dev_err_probe() > + return ret; > + } > + } else { > + ret = regulator_enable(st->vref); > + if (ret) { > + dev_err(&spi->dev, "Failed to enable specified Vref supply\n"); dev_err_probe() > + return ret; > + } > + > + ret = devm_add_action_or_reset(&spi->dev, ad7192_reg_disable, st->vref); > + if (ret) > + return ret; > + > + ret = regulator_get_voltage(st->vref); > + if (ret < 0) { > + dev_err(&spi->dev, "Device tree error, Vref voltage undefined\n"); dev_err_probe() > + return ret; > + } > } > st->int_vref_mv = ret / 1000; >