From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <SRS0=LLNM=ZF=vger.kernel.org=linux-kernel-owner@kernel.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
	aws-us-west-2-korg-lkml-1.web.codeaurora.org
X-Spam-Level: 
X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID,
	HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,
	SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no
	version=3.4.0
Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
	by smtp.lore.kernel.org (Postfix) with ESMTP id A07BFC17449
	for <linux-kernel@archiver.kernel.org>; Wed, 13 Nov 2019 08:35:36 +0000 (UTC)
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
	by mail.kernel.org (Postfix) with ESMTP id 71602222C9
	for <linux-kernel@archiver.kernel.org>; Wed, 13 Nov 2019 08:35:36 +0000 (UTC)
Authentication-Results: mail.kernel.org;
	dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="k19ltE40"
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
        id S1727143AbfKMIff (ORCPT
        <rfc822;linux-kernel@archiver.kernel.org>);
        Wed, 13 Nov 2019 03:35:35 -0500
Received: from mx0b-00128a01.pphosted.com ([148.163.139.77]:50704 "EHLO
        mx0b-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK)
        by vger.kernel.org with ESMTP id S1726155AbfKMIfe (ORCPT
        <rfc822;linux-kernel@vger.kernel.org>);
        Wed, 13 Nov 2019 03:35:34 -0500
Received: from pps.filterd (m0167091.ppops.net [127.0.0.1])
        by mx0b-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAD8WtEl025599;
        Wed, 13 Nov 2019 03:35:18 -0500
Received: from nam01-bn3-obe.outbound.protection.outlook.com (mail-bn3nam01lp2054.outbound.protection.outlook.com [104.47.33.54])
        by mx0b-00128a01.pphosted.com with ESMTP id 2w7pr6k44w-1
        (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);
        Wed, 13 Nov 2019 03:35:18 -0500
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=Oc877TE+80M71ItB+zdd3JlLcQFcyYPJVZuRRtXvX8kJh6gL9nq7cZ8Yh6TNrvPuU4PF2R/kI7TpkI14bQ8FyR1Vxv/O1vlTQveBhzB8ssAdKvTULLU9cdXGD6S1Oc/xY26322/3nrEAu5LL3vGCox4pv63LiaoIS53Hr+GEVfNjBsp+qcm2bso4/8SN1wokC9KZS3BWO8lexDeXBd7yoSeE8b2jNBIZXKGgPpppJ2BXyvQcGJw6fihOk2KH1/Ox8HdO53cdyRwU9/XFf3sdTD4ah0jCim35FkqU45g930ClegFcUmo4DYl/Fh55ppUo8woXZMwypXokXJXZPr47sQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=ACFf3j0dAaFmyDZvuC5Px2tq1qxXMi0WCMoDGHMmLt4=;
 b=OUkW0LJqVOUReyqwEA9a5ZIHMpIjIt0oF4afmcGAuEnE5fWhqNwkDxGt4aLRo5EY3M5LBa6uJ/1L2Y13v/lBX1H82oIvfostAVZkjHj0ADSLu6gcs1NbF98wLnDzgzgQN4foWmJNkeRD1MqvPHHf113afOvajuMfOS2kDlADEgv+aaNBMRZk7tHg6sItIMLpj4yqv2NXvH6qsr2ZlaoQbr5bSjkbpTFHWP1dnTr8zWqTAlPoE6AYbL3gy5YIAgayffGt1DNL3ZArSgjhZfM42X8bSrNy3pUlZJFwlFW1Luj24hR20GOdjhHag+nsSSk+Qi0stc+DLvv+K0nvzIEKcQ==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is
 137.71.25.57) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=analog.com;
 dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message
 not signed); arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=ACFf3j0dAaFmyDZvuC5Px2tq1qxXMi0WCMoDGHMmLt4=;
 b=k19ltE40nan0dt07aI70TrWhgYT/AOitkx6sJ03sU5IKi7AFvh/tRkxp7WMr/wGj+Wq73FU6B8RvWYlKlEQ9kUMFEFZJH6cmBmP3mtvRAEBM3SJV1UgHUBwVhOGTKMXb3DGWx414QoBZf2GOKzJOpco/8XyKH8bAhBVCgTT3/DE=
Received: from DM6PR03CA0053.namprd03.prod.outlook.com (2603:10b6:5:100::30)
 by BN7PR03MB3780.namprd03.prod.outlook.com (2603:10b6:408:31::13) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.22; Wed, 13 Nov
 2019 08:35:16 +0000
Received: from BL2NAM02FT039.eop-nam02.prod.protection.outlook.com
 (2a01:111:f400:7e46::207) by DM6PR03CA0053.outlook.office365.com
 (2603:10b6:5:100::30) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2430.22 via Frontend
 Transport; Wed, 13 Nov 2019 08:35:16 +0000
Received-SPF: Pass (protection.outlook.com: domain of analog.com designates
 137.71.25.57 as permitted sender) receiver=protection.outlook.com;
 client-ip=137.71.25.57; helo=nwd2mta2.analog.com;
Received: from nwd2mta2.analog.com (137.71.25.57) by
 BL2NAM02FT039.mail.protection.outlook.com (10.152.77.152) with Microsoft SMTP
 Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2451.23
 via Frontend Transport; Wed, 13 Nov 2019 08:35:16 +0000
Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107])
        by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id xAD8Z7Pk003224
        (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK);
        Wed, 13 Nov 2019 00:35:07 -0800
Received: from tachici-Precision-5530.ad.analog.com (10.48.65.123) by
 NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id
 14.3.408.0; Wed, 13 Nov 2019 03:35:15 -0500
From:   Alexandru Tachici <alexandru.tachici@analog.com>
To:     <linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>
CC:     <lars@metafoo.de>, <jic23@kernel.org>,
        Alexandru Tachici <alexandru.tachici@analog.com>
Subject: [PATCH] iio: dac: ad7303: use regulator get optional to check for ext supply
Date:   Wed, 13 Nov 2019 10:33:03 +0200
Message-ID: <20191113083303.2229-1-alexandru.tachici@analog.com>
X-Mailer: git-send-email 2.20.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-ADIRoutedOnPrem: True
X-EOPAttributedMessage: 0
X-MS-Office365-Filtering-HT: Tenant
X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(136003)(346002)(396003)(39860400002)(376002)(199004)(189003)(8936002)(48376002)(86362001)(7636002)(50226002)(305945005)(51416003)(486006)(1076003)(246002)(8676002)(126002)(70206006)(476003)(7696005)(70586007)(5660300002)(44832011)(2870700001)(2616005)(2906002)(50466002)(26005)(107886003)(336012)(4326008)(36756003)(47776003)(6666004)(316002)(54906003)(478600001)(186003)(106002)(426003)(356004)(110136005);DIR:OUT;SFP:1101;SCL:1;SRVR:BN7PR03MB3780;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1;
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-Correlation-Id: 66a035a0-4654-4cac-ba7b-08d7681468db
X-MS-TrafficTypeDiagnostic: BN7PR03MB3780:
X-Microsoft-Antispam-PRVS: <BN7PR03MB37803ACC4190BECBAACF932890760@BN7PR03MB3780.namprd03.prod.outlook.com>
X-MS-Oob-TLC-OOBClassifiers: OLM:1079;
X-Forefront-PRVS: 0220D4B98D
X-MS-Exchange-SenderADCheck: 1
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: /Zs0XXy2MxmDJvWv+QkUAyn8of2wqloPl/vz2NGQBNKBrKUbe7nAr8Ra5bPebJWbXvKr52LybEhA1n75WObvp6daldU3NzEQhbpwCXW9zXEHdSXJWJsFAGyVNuTzImEbXg3eBBtocAuH2SbGhlaxp1etOWp7YpeextRekwFKX2oq/u5LYaG29SYPgIIF5z0DtBHzHu500NopZTjSosMX1Wl02v0M751Bs61L6k7iH2HYxoBY2Ik5AKrbNLzGMBZHSrhyNMGXY17ojYK1y+YDRTL7dvQGxUHCqREs/x9ueQAKFbRCWK/nOO/mJk9EwQbu5z14dTjR9kTINhTC/2+cnGO2HVgcheXNWXgaP+iSt3Zv3P9dhtt8eOM458wJoj0dGTJRyGRymZIcBBeEe2eqiBtcKUzsHv4EMJKTeUWNifsRMDo+sU9lf/EJy4xzJCCX
X-OriginatorOrg: analog.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2019 08:35:16.3639
 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: 66a035a0-4654-4cac-ba7b-08d7681468db
X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a
X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com]
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR03MB3780
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572
 definitions=2019-11-13_02:2019-11-13,2019-11-13 signatures=0
X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 mlxscore=0
 priorityscore=1501 suspectscore=0 phishscore=0 bulkscore=0
 lowpriorityscore=0 mlxlogscore=981 malwarescore=0 adultscore=0
 impostorscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx
 scancount=1 engine=8.12.0-1910280000 definitions=main-1911130078
Sender: linux-kernel-owner@vger.kernel.org
Precedence: bulk
List-ID: <linux-kernel.vger.kernel.org>
X-Mailing-List: linux-kernel@vger.kernel.org

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 <alexandru.tachici@analog.com>
---
 drivers/iio/dac/ad7303.c | 23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/drivers/iio/dac/ad7303.c b/drivers/iio/dac/ad7303.c
index 14bbac6bee98..e0c5fed4475c 100644
--- a/drivers/iio/dac/ad7303.c
+++ b/drivers/iio/dac/ad7303.c
@@ -12,7 +12,6 @@
 #include <linux/slab.h>
 #include <linux/sysfs.h>
 #include <linux/regulator/consumer.h>
-#include <linux/of.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
@@ -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,13 @@ 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;
+	st->vref_reg = devm_regulator_get_optional(&spi->dev, "REF");
+	if (IS_ERR(st->vref_reg)) {
+		ret = PTR_ERR(st->vref_reg);
+		goto err_disable_vdd_reg;
 	}
 
-	if (ext_ref) {
-		st->vref_reg = devm_regulator_get(&spi->dev, "REF");
-		if (IS_ERR(st->vref_reg)) {
-			ret = PTR_ERR(st->vref_reg);
-			goto err_disable_vdd_reg;
-		}
-
+	if (st->vref_reg) {
 		ret = regulator_enable(st->vref_reg);
 		if (ret)
 			goto err_disable_vdd_reg;
-- 
2.20.1


From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <SRS0=try7=ZI=vger.kernel.org=linux-kernel-owner@kernel.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
	aws-us-west-2-korg-lkml-1.web.codeaurora.org
X-Spam-Level: 
X-Spam-Status: No, score=-8.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED,
	DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,
	SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=unavailable
	autolearn_force=no version=3.4.0
Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
	by smtp.lore.kernel.org (Postfix) with ESMTP id 8F493C432C3
	for <linux-kernel@archiver.kernel.org>; Sat, 16 Nov 2019 16:18:07 +0000 (UTC)
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
	by mail.kernel.org (Postfix) with ESMTP id 68CB221479
	for <linux-kernel@archiver.kernel.org>; Sat, 16 Nov 2019 16:18:07 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;
	s=default; t=1573921087;
	bh=PoAjATiyMw59a4B+QqOkZq9Qem/RNBGHAwCV08vIXVA=;
	h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From;
	b=yFCvYVF8fDm1wE/gK6EFZ+wsVQQex4pnri77wt/64z+gu0X7eYzS4ttnZNQzrWmF0
	 1gdBjgxo0mkfnj2ScrIwI0P21kjBWZVZWAOQ+EnBqh4HL5l+kMbyfGkgeC7Fjh8ffs
	 7ohDg5EW2PJDcXXL0LGfX9ckZgsEJm0iONs2aGJE=
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
        id S1731725AbfKPQSG (ORCPT
        <rfc822;linux-kernel@archiver.kernel.org>);
        Sat, 16 Nov 2019 11:18:06 -0500
Received: from mail.kernel.org ([198.145.29.99]:35438 "EHLO mail.kernel.org"
        rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP
        id S1729820AbfKPQR6 (ORCPT <rfc822;linux-kernel@vger.kernel.org>);
        Sat, 16 Nov 2019 11:17:58 -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 2AE0021844;
        Sat, 16 Nov 2019 16:17:57 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;
        s=default; t=1573921078;
        bh=PoAjATiyMw59a4B+QqOkZq9Qem/RNBGHAwCV08vIXVA=;
        h=Date:From:To:Cc:Subject:In-Reply-To:References:From;
        b=NiwuN3cA5wNzoy+x+tLZQfyxvfyWNPzhLN6tZr4PAOrsYM5JegUavQuoUHPsTD8xk
         W7IrhDvv90baPuGBVxR33GKjGPY8OXFsepKcSuvuzXQLvaYJLs80YkOCVDbTnX6Z8u
         dH145/up7L911obt7v5ID9W3H/3IcMgPi51jqtx0=
Date:   Sat, 16 Nov 2019 16:17:53 +0000
From:   Jonathan Cameron <jic23@kernel.org>
To:     Alexandru Tachici <alexandru.tachici@analog.com>
Cc:     <linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
        <lars@metafoo.de>
Subject: Re: [PATCH] iio: dac: ad7303: use regulator get optional to check
 for ext supply
Message-ID: <20191116161753.24d620df@archlinux>
In-Reply-To: <20191113083303.2229-1-alexandru.tachici@analog.com>
References: <20191113083303.2229-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: <linux-kernel.vger.kernel.org>
X-Mailing-List: linux-kernel@vger.kernel.org

On Wed, 13 Nov 2019 10:33:03 +0200
Alexandru Tachici <alexandru.tachici@analog.com> 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 <alexandru.tachici@analog.com>

Hi.
I agree in principle but I don't think devm_regulator_get_optional
returns NULL when a regulator isn't supplied.

Thanks,

Jonathan

> ---
>  drivers/iio/dac/ad7303.c | 23 +++++------------------
>  1 file changed, 5 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad7303.c b/drivers/iio/dac/ad7303.c
> index 14bbac6bee98..e0c5fed4475c 100644
> --- a/drivers/iio/dac/ad7303.c
> +++ b/drivers/iio/dac/ad7303.c
> @@ -12,7 +12,6 @@
>  #include <linux/slab.h>
>  #include <linux/sysfs.h>
>  #include <linux/regulator/consumer.h>
> -#include <linux/of.h>
>  
>  #include <linux/iio/iio.h>
>  #include <linux/iio/sysfs.h>
> @@ -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,13 @@ 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;
> +	st->vref_reg = devm_regulator_get_optional(&spi->dev, "REF");
> +	if (IS_ERR(st->vref_reg)) {
> +		ret = PTR_ERR(st->vref_reg);

devm_regulator_get_optional returns a ptr  encoding -ENODEV if the
regulator is not supplied.  That isn't an error here so needs to be
handled differently from other error codes.

> +		goto err_disable_vdd_reg;
>  	}
>  
> -	if (ext_ref) {
> -		st->vref_reg = devm_regulator_get(&spi->dev, "REF");
> -		if (IS_ERR(st->vref_reg)) {
> -			ret = PTR_ERR(st->vref_reg);
> -			goto err_disable_vdd_reg;
> -		}
> -
> +	if (st->vref_reg) {
>  		ret = regulator_enable(st->vref_reg);
>  		if (ret)
>  			goto err_disable_vdd_reg;


From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <SRS0=CA45=ZK=vger.kernel.org=linux-kernel-owner@kernel.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
	aws-us-west-2-korg-lkml-1.web.codeaurora.org
X-Spam-Level: 
X-Spam-Status: No, score=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID,
	HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,
	SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable
	autolearn_force=no version=3.4.0
Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
	by smtp.lore.kernel.org (Postfix) with ESMTP id DD64AC43215
	for <linux-kernel@archiver.kernel.org>; Mon, 18 Nov 2019 11:00:23 +0000 (UTC)
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
	by mail.kernel.org (Postfix) with ESMTP id ABA2420730
	for <linux-kernel@archiver.kernel.org>; Mon, 18 Nov 2019 11:00:23 +0000 (UTC)
Authentication-Results: mail.kernel.org;
	dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="mZmwJ2rA"
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
        id S1726774AbfKRLAW (ORCPT
        <rfc822;linux-kernel@archiver.kernel.org>);
        Mon, 18 Nov 2019 06:00:22 -0500
Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:37874 "EHLO
        mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK)
        by vger.kernel.org with ESMTP id S1726703AbfKRLAW (ORCPT
        <rfc822;linux-kernel@vger.kernel.org>);
        Mon, 18 Nov 2019 06:00:22 -0500
Received: from pps.filterd (m0167089.ppops.net [127.0.0.1])
        by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAIArUI8003770;
        Mon, 18 Nov 2019 06:00:07 -0500
Received: from nam03-dm3-obe.outbound.protection.outlook.com (mail-dm3nam03lp2059.outbound.protection.outlook.com [104.47.41.59])
        by mx0a-00128a01.pphosted.com with ESMTP id 2waew7fcfm-1
        (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);
        Mon, 18 Nov 2019 06:00:07 -0500
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=a2xTFFjlN4ZejzKB7y+hnwUiJdLnujt7QonfIdFaXI82NnsM9mu9I3UyVXa2WLnhg4fMYG+dVXrTgyEFDDjbVpUg/hneg/xm8N253MSWu3LhtYsvuXxPr9AeNFBxdh4SR/ILqXJx3vOPMh4w86Op+sLgC1zh3F4URDICtAXBGJGUYVJ/2n5vOj5De6chDeLoQg8GJyv/NgM+bq5+sdjUIYvOp2fNVqCXrnYqlJ6eOkB7Q8Y0Bu5t/M6JX/vRJldioKegEvDms7yWOW2/53WkftP056XwT2QFQSf0ZZkKoL4Rc0/vVcwNLOmr1Lk/439/qml6nYwMCpdly2CJs+IBMw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=kPwPBjpHpLafE87i5JRKe+KwVxwbFfJuPnIIH/uGiGE=;
 b=dfuOMki9b960DqI3MI2wJofc0x6/TC16Ued6hjucUl6vYHbiiWB/M/Vngo7E+O25Lnsqv2n/m3TQoRZEYfq4MVe65gT6VpIo89bY9DaiBEHOShntfPpxLORIH0b/v+Srxkx+MEB1xIdMWtXQjj10DWxLquCLthDdJ8frKSED4We/kS3YIyV6C/tO1SKG6zwZF+m8HjdGRtbAoklHtd7f3D0sbt8WDGFLQsVNRz2crwsA95GGSi4A2KSJF5aeIGnt0nLiwYiswk4BBS2QAJ0E4SyVsJI3JQ5hf8gKUwPI4CBocwTDRP4M6zXCm1CYEcFluUYgl5sqoEfQ+nCzyyHJNA==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is
 137.71.25.57) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=analog.com;
 dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message
 not signed); arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=kPwPBjpHpLafE87i5JRKe+KwVxwbFfJuPnIIH/uGiGE=;
 b=mZmwJ2rAVKN3X//hjgJuShUFWitu0RDCIN37l7rLKE9ewZKlLCjq5zuHjPCHb5IDwU5fVb7n2U8vObvZIDKGG5BMZg45KCWjnEkaQwznOPMbpqvFXvABS4xSWVqrYV8rHurOuGd/ZjelapSoxxw7OQkVVOerZ8Y1bFJeIQsvIYY=
Received: from BN8PR03CA0006.namprd03.prod.outlook.com (2603:10b6:408:94::19)
 by DM6PR03MB4652.namprd03.prod.outlook.com (2603:10b6:5:18d::31) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.23; Mon, 18 Nov
 2019 11:00:04 +0000
Received: from SN1NAM02FT024.eop-nam02.prod.protection.outlook.com
 (2a01:111:f400:7e44::200) by BN8PR03CA0006.outlook.office365.com
 (2603:10b6:408:94::19) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.22 via Frontend
 Transport; Mon, 18 Nov 2019 10:59:58 +0000
Received-SPF: Pass (protection.outlook.com: domain of analog.com designates
 137.71.25.57 as permitted sender) receiver=protection.outlook.com;
 client-ip=137.71.25.57; helo=nwd2mta2.analog.com;
Received: from nwd2mta2.analog.com (137.71.25.57) by
 SN1NAM02FT024.mail.protection.outlook.com (10.152.72.127) with Microsoft SMTP
 Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2451.23
 via Frontend Transport; Mon, 18 Nov 2019 10:59:58 +0000
Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107])
        by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id xAIAxnLx010665
        (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK);
        Mon, 18 Nov 2019 02:59:49 -0800
Received: from tachici-Precision-5530.ad.analog.com (10.48.65.123) by
 NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id
 14.3.408.0; Mon, 18 Nov 2019 05:59:57 -0500
From:   Alexandru Tachici <alexandru.tachici@analog.com>
To:     <linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>
CC:     <lars@metafoo.de>, <jic23@kernel.org>,
        Alexandru Tachici <alexandru.tachici@analog.com>
Subject: [PATCH v2] iio: dac: ad7303: use regulator get optional to check for ext supply
Date:   Mon, 18 Nov 2019 12:58:07 +0200
Message-ID: <20191118105807.6842-1-alexandru.tachici@analog.com>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20191113083303.2229-1-alexandru.tachici@analog.com>
References: <20191113083303.2229-1-alexandru.tachici@analog.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-ADIRoutedOnPrem: True
X-EOPAttributedMessage: 0
X-MS-Office365-Filtering-HT: Tenant
X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(376002)(396003)(346002)(136003)(39860400002)(199004)(189003)(54534003)(8676002)(426003)(50226002)(51416003)(7696005)(4326008)(76176011)(26005)(106002)(2906002)(5660300002)(11346002)(2616005)(476003)(126002)(486006)(44832011)(107886003)(2870700001)(54906003)(86362001)(1076003)(316002)(47776003)(305945005)(8936002)(446003)(336012)(186003)(110136005)(246002)(50466002)(48376002)(356004)(6666004)(478600001)(70206006)(70586007)(36756003)(7636002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR03MB4652;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1;
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-Correlation-Id: f27751d9-c2d6-45b3-0121-08d76c1673da
X-MS-TrafficTypeDiagnostic: DM6PR03MB4652:
X-Microsoft-Antispam-PRVS: <DM6PR03MB46521E92DE761F0BC370CDC6904D0@DM6PR03MB4652.namprd03.prod.outlook.com>
X-MS-Oob-TLC-OOBClassifiers: OLM:3826;
X-Forefront-PRVS: 0225B0D5BC
X-MS-Exchange-SenderADCheck: 1
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: C/s5y92F161R7gGaKrSVQpGb93qBfEUWVHlfdB+/gVDWeVvc0ApUB+XBd74Wpc7K8YpoCQ2CuiYTBHPSeGSrMgUuXoCXsf+BFBgJMNsSIAzp16WU7BMDsYXe/On59h3akFhDDcAX/xZacuA9/+oOrpppHeJ2GY/tcncit4vAW15hpu9RcfBN9hCh8KNpw//GjU/wgXjrgppS+DkdXUCW1afwXFXYOkeW+ZefG7JklGwj/kSBFf7b51cvx9zkANrpTl4vRvGox/X6mtsfxgf75w7IOeUiLrVGw5M71quc5HAdaQepR05Zob3K1fanvJZjDf4A+mC4ZDPz9oo5C8Y8vgBUNLLS/Umi4jcbHRLqTe390v9c0Wnn3Iw/j/aA1LyxiNmnRIAsvoSF05XVvQM+BMmEdoMeyZi3Mje2g08jZk2FArm0Zi4FjS5vTHXQAQT4
X-OriginatorOrg: analog.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2019 10:59:58.3900
 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: f27751d9-c2d6-45b3-0121-08d76c1673da
X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a
X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com]
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR03MB4652
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572
 definitions=2019-11-18_02:2019-11-15,2019-11-18 signatures=0
X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015
 bulkscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=977 spamscore=0
 malwarescore=0 priorityscore=1501 mlxscore=0 phishscore=0 impostorscore=0
 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000
 definitions=main-1911180099
Sender: linux-kernel-owner@vger.kernel.org
Precedence: bulk
List-ID: <linux-kernel.vger.kernel.org>
X-Mailing-List: linux-kernel@vger.kernel.org

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 <alexandru.tachici@analog.com>
---
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 <linux/slab.h>
 #include <linux/sysfs.h>
 #include <linux/regulator/consumer.h>
-#include <linux/of.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
@@ -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;
-- 
2.20.1


From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <SRS0=E2Zf=ZP=vger.kernel.org=linux-kernel-owner@kernel.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
	aws-us-west-2-korg-lkml-1.web.codeaurora.org
X-Spam-Level: 
X-Spam-Status: No, score=-8.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED,
	DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,
	SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=unavailable
	autolearn_force=no version=3.4.0
Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
	by smtp.lore.kernel.org (Postfix) with ESMTP id 21466C432C3
	for <linux-kernel@archiver.kernel.org>; Sat, 23 Nov 2019 14:23:02 +0000 (UTC)
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
	by mail.kernel.org (Postfix) with ESMTP id ED06020719
	for <linux-kernel@archiver.kernel.org>; Sat, 23 Nov 2019 14:23:01 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;
	s=default; t=1574518982;
	bh=CZvS75BTOSHfse9UoNY85eRZLojSKzzLceJhQNi3lU4=;
	h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From;
	b=XvhZlZOIYm1QIhjxUOO67lVhIx6vIZ7hISDgrFjtmX09BJMu84nlP6mRIx/K50LS2
	 zuD07Zr8W9SenQPifO/F26JX4ZRfEFZrcas7ZkvgGC473arB4iBfG5w4omLfCw1Z4W
	 L0ryWs8Ug2GSrIoTkybXroBemDsceEsJ2T9Cb1dU=
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
        id S1726825AbfKWOXA (ORCPT
        <rfc822;linux-kernel@archiver.kernel.org>);
        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 <rfc822;linux-kernel@vger.kernel.org>);
        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 <jic23@kernel.org>
To:     Alexandru Tachici <alexandru.tachici@analog.com>
Cc:     <linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
        <lars@metafoo.de>
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: <linux-kernel.vger.kernel.org>
X-Mailing-List: linux-kernel@vger.kernel.org

On Mon, 18 Nov 2019 12:58:07 +0200
Alexandru Tachici <alexandru.tachici@analog.com> 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 <alexandru.tachici@analog.com>
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 <linux/slab.h>
>  #include <linux/sysfs.h>
>  #include <linux/regulator/consumer.h>
> -#include <linux/of.h>
>  
>  #include <linux/iio/iio.h>
>  #include <linux/iio/sysfs.h>
> @@ -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;


