Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6034343rdb; Thu, 14 Dec 2023 06:47:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IExLup2oNMcyEGUj+WVUbCvZDYyGGlVoUbqLfX4Zj20dIux8vV59wnQoaJzhoiwf1Lo2uAl X-Received: by 2002:a05:6358:60c1:b0:16c:4fe:7bfc with SMTP id i1-20020a05635860c100b0016c04fe7bfcmr10981475rwi.22.1702565275704; Thu, 14 Dec 2023 06:47:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702565275; cv=none; d=google.com; s=arc-20160816; b=VWdEMtf+7hIJwAJqWS8NDlbod2io4ISrSfg9/ztghZFMmEqgxPGwC3Hnc6N3REnOrZ iHjFDETPMsqbssZ05wdWSVF70xYd4+LSh8dekgMhEkL+1aYtCvXabfKNkLVPcHtxBb6p XVl5aNXqbxe61t4YBukA5V2Ahu4gtdNlbdfvv/J9mB5i01urO+AEmDU1Dje442EvRsKP 62TfqY3d24G18hB4pg2yWaIFjtjVCsWGXCeIs8tBDkC5BnUPdIpaRVMn159RlDMrLTTS aewEvej2+yS5JQvSVieKZwxeors2c/4Bt3LIN1BHUUXWhcf7YppxmWKdTGfdCiXOPUrN tB0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=EwN9NHENRHnCA41nlTKRtiLQoxnyC64C3nSCh+R/2+Y=; fh=s2CzmXvLDj2doEqpIF0LGMr0Sj20bQfdahLd83LwWV8=; b=ui1SdV5iLWd6zDEt8m0rsWqRXezUmOUgni25jF+yxq4YwzUsarhQtQt0LnanVad/VY 5PJR4Ffigf5OW7ssKIEuNF8VOZwDNhOBxmzJEpnQrOrqxCj/EEKgjS5p6SceI9Cig1V4 YJ+McBgMyplg3Ijo8aOFWCdYP/pMmvwDgqfCQsif5USo1eDewR1W/MZpZ4WO8KIz3Y6w 7CYJ/ffxfaK/RyVjFgzHzqKjmuXgM9vnDNnFN9G/BNh0H0aajlX5a8Ul4IFc41+txHUT wgcdBVMLdp/sbgqChqChbuK5EXu5nKNkaXjcu+TVYRl0y4TaAwA0rpdtZ6ECATq16B2m 2Wag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id c31-20020a630d1f000000b005c212bdc7d2si11034251pgl.611.2023.12.14.06.47.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 06:47:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 2B4AD8229F37; Thu, 14 Dec 2023 06:47:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573418AbjLNOre (ORCPT + 99 others); Thu, 14 Dec 2023 09:47:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230015AbjLNOrd (ORCPT ); Thu, 14 Dec 2023 09:47:33 -0500 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3094116; Thu, 14 Dec 2023 06:47:39 -0800 (PST) X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="13822066" X-IronPort-AV: E=Sophos;i="6.04,275,1695711600"; d="scan'208";a="13822066" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2023 06:47:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="1021526074" X-IronPort-AV: E=Sophos;i="6.04,275,1695711600"; d="scan'208";a="1021526074" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga006.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2023 06:47:33 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.97) (envelope-from ) id 1rDmzp-00000005s1e-3AHo; Thu, 14 Dec 2023 16:47:29 +0200 Date: Thu, 14 Dec 2023 16:47:29 +0200 From: Andy Shevchenko To: Ceclan Dumitru Cc: Jonathan Cameron , linus.walleij@linaro.org, brgl@bgdev.pl, linux-gpio@vger.kernel.org, Lars-Peter Clausen , Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Walle , Arnd Bergmann , ChiaEn Wu , Niklas Schnelle , Leonard =?iso-8859-1?Q?G=F6hrs?= , Mike Looijmans , Haibo Chen , Hugo Villeneuve , Ceclan Dumitru , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 2/2] iio: adc: ad7173: add AD7173 driver Message-ID: References: <20231212104451.22522-1-mitrutzceclan@gmail.com> <20231212104451.22522-2-mitrutzceclan@gmail.com> <20231214123029.000002f1@Huawei.com> <375bf803-a5d5-4778-938a-b8218b116375@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <375bf803-a5d5-4778-938a-b8218b116375@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Thu, 14 Dec 2023 06:47:53 -0800 (PST) On Thu, Dec 14, 2023 at 02:57:35PM +0200, Ceclan Dumitru wrote: > On 12/14/23 14:30, Jonathan Cameron wrote: > > On Tue, 12 Dec 2023 12:44:36 +0200 > > Dumitru Ceclan wrote: ... > >> + ret = fwnode_property_match_property_string(child, > >> + "adi,reference-select", > >> + ad7173_ref_sel_str, > >> + ARRAY_SIZE(ad7173_ref_sel_str)); > >> + Redundant blank line. > >> + if (ret < 0) > >> + ref_sel = AD7173_SETUP_REF_SEL_INT_REF; > >> + else > >> + ref_sel = ret; > > Simpler pattern for properties with a default is not to check the error code. > > > > ref_sel = AD7173_SETUP_REF_SEL_INT_REF; > > > > fwnode_property_match_property_String(child, ... > > > > so only if it succeeds is the value overridden. > > Where exactly would the value be overridden, the function does not have an > argument passed for the found index. The function is written to return either > the found index or a negative error. > > The proposed pattern would just ignore the returned index and would always > leave ref_sel to default. Am I missing something? > > I can see in the thread where it was introduced that you proposed: > "Looking at the usecases I wonder if it would be better to pass in > an unsigned int *ret which is only updated on a match?" > > But on the iio togreg branch that was suggested I could the function on, it > does not have that parameter. Yeah, with the current API we can have one check (no 'else' branch): ref_sel = AD7173_SETUP_REF_SEL_INT_REF; ret = ... if (ret >= 0) ref_sel = ret; But your approach is good to me. ... It's always possible to change prototype, and now of course is the best time as all the users are provided in the single tree. That said, patches are welcome if this is what we want. (My proposal was to return index in case of no error, but at the same time leave it in the returned code, so it will be aligned with other match functions of fwnode. But this in either way will complicate the implementation. And I don't find critical to have if-else in each caller as some of them may do something different on the error case, when option is mandatory. In such cases we usually don't provide output if we know that an error condition occurs. -- With Best Regards, Andy Shevchenko