Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp684302ybc; Sat, 23 Nov 2019 06:24:28 -0800 (PST) X-Google-Smtp-Source: APXvYqxAIH4O5x18nqWlBiL0cXY1oXy0aOSfoAP3K31xt3tsqodFnIwfMHOHMJGxh0/P6bvYVdQU X-Received: by 2002:a17:906:7c5:: with SMTP id m5mr27332758ejc.231.1574519068112; Sat, 23 Nov 2019 06:24:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574519068; cv=none; d=google.com; s=arc-20160816; b=RKP+WvwYzu8WNQOBbDiI2PfVw7CBt3vR9pBhD4f6GnH1YlVzp/VIU1LV8D6KWQwE/O F7YcTwhHyXWJkFetAKdAPUx3s/VxNzFsFTCSMubJ3+pkRR30YL4VMEBOGlm7Uc2ZjT// 9xQPG7QXAg/VKEpgX2CgHSCh/d+EzaPNfQEn0/a6lkahtAic0jqPQ8QfmtU9wV5WIO4l a+ipaUOV21O6dlMoB0j7b5649UL0fA9MB4ZlaA+PA0zImdfJGJrT6pgPvTlEMNt255GW 3bsGFZ2MoeYGNZZmyU4Xo8CfQkyMnRKIMXhUH+oD//FawAvxAF/3KRNUmsIsxGgSD9Qt X7Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=2i64TdvF0QJkDCEr+EOSF+8Php5APLe0AQ5WFffDOAE=; b=DibkU6f/mjZEdWpkI4+FxEOV2R53seTkV7KIor0p5CcqlnPWdewqsfRASP57y2KsJF sLqCf/KiVgWiRRtUpFukWdE5wltRYmJAN/huJ6gjuXQIP3In3bmAHfj7OjZ9d8Mpbtx+ bIDQn3JoSUw/SNSoxkkh5NmfkD1Q6YD/f6oopL09JIZeb3HHX7FrZiBSNT2yzHHhWgqp gKoXtssgsxwoHJuD0+5YGLk4xDc5T8N54GLJNpjDY7ViY09t66GDXrK4vhP94BrGEdmg oWSy8c6Tk7ILWuRG6xq4at+v+Tdj9oDd5DVcSZBP3ILyvtuQpcxVCmIkh0YFCwhgsj0e LmGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=A6Ippmz2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id m15si771161ejk.320.2019.11.23.06.24.03; Sat, 23 Nov 2019 06:24:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=A6Ippmz2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726735AbfKWOXA (ORCPT + 99 others); Sat, 23 Nov 2019 09:23:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:57218 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726524AbfKWOXA (ORCPT ); Sat, 23 Nov 2019 09:23:00 -0500 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 21A7B20714; Sat, 23 Nov 2019 14:22:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574518979; bh=CZvS75BTOSHfse9UoNY85eRZLojSKzzLceJhQNi3lU4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=A6Ippmz2d3E68AOQsSoys5lqbZlioeIlRhuxapgKiNq1Q74irynbSQScrCqmePs1O TIVOzB5v/3RjP5Rx6PtQY9uv4B5XICzhE5EHPfV1PTUVy1NX2pDGuUqw4j9ykJ3b8A EePqyTFHI5PmN7YPY/uaBLzjkmdxX9pY13NMFrIY= Date: Sat, 23 Nov 2019 14:22:56 +0000 From: Jonathan Cameron To: Alexandru Tachici Cc: , , Subject: Re: [PATCH v2] iio: dac: ad7303: use regulator get optional to check for ext supply Message-ID: <20191123142256.7bdcee03@archlinux> In-Reply-To: <20191118105807.6842-1-alexandru.tachici@analog.com> References: <20191113083303.2229-1-alexandru.tachici@analog.com> <20191118105807.6842-1-alexandru.tachici@analog.com> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 18 Nov 2019 12:58:07 +0200 Alexandru Tachici wrote: > Previously, the code was using the of_read_property_bool() to check if > an external regulator was provided. However, this is redundant, as it's > more simple/direct to just ask the regulator is provided, via a > `devm_regulator_get_optional()` call. > > Signed-off-by: Alexandru Tachici Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to see if we missed anything. Thanks, Jonathan > --- > Changelog v1 -> v2: > > - check for -ENODEV error for devm_regulator_get_optional() call > > drivers/iio/dac/ad7303.c | 25 +++++++------------------ > 1 file changed, 7 insertions(+), 18 deletions(-) > > diff --git a/drivers/iio/dac/ad7303.c b/drivers/iio/dac/ad7303.c > index 14bbac6bee98..15af8a1cce3e 100644 > --- a/drivers/iio/dac/ad7303.c > +++ b/drivers/iio/dac/ad7303.c > @@ -12,7 +12,6 @@ > #include > #include > #include > -#include > > #include > #include > @@ -202,7 +201,6 @@ static int ad7303_probe(struct spi_device *spi) > const struct spi_device_id *id = spi_get_device_id(spi); > struct iio_dev *indio_dev; > struct ad7303_state *st; > - bool ext_ref; > int ret; > > indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); > @@ -224,24 +222,15 @@ static int ad7303_probe(struct spi_device *spi) > if (ret) > return ret; > > - if (spi->dev.of_node) { > - ext_ref = of_property_read_bool(spi->dev.of_node, > - "REF-supply"); > - } else { > - struct ad7303_platform_data *pdata = spi->dev.platform_data; > - if (pdata && pdata->use_external_ref) > - ext_ref = true; > - else > - ext_ref = false; > - } > - > - if (ext_ref) { > - st->vref_reg = devm_regulator_get(&spi->dev, "REF"); > - if (IS_ERR(st->vref_reg)) { > - ret = PTR_ERR(st->vref_reg); > + st->vref_reg = devm_regulator_get_optional(&spi->dev, "REF"); > + if (IS_ERR(st->vref_reg)) { > + ret = PTR_ERR(st->vref_reg); > + if (ret != -ENODEV) > goto err_disable_vdd_reg; > - } > + st->vref_reg = NULL; > + } > > + if (st->vref_reg) { > ret = regulator_enable(st->vref_reg); > if (ret) > goto err_disable_vdd_reg;