Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp553052rdh; Thu, 23 Nov 2023 11:10:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IHlOCHXs/0AdBdjGol67zi0olRUbKAauaQtXZ7L/knkySAZQupmPmeHvG6KBMRmwq+RhyTN X-Received: by 2002:a05:6808:1211:b0:3b2:e34f:349b with SMTP id a17-20020a056808121100b003b2e34f349bmr335472oil.42.1700766601319; Thu, 23 Nov 2023 11:10:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700766601; cv=none; d=google.com; s=arc-20160816; b=FU6mf3tLrIVhyOChpmdfD0PWr9cF9aNhTCTQPDcZ3jHCosx1urj0WUjv4rs7ZoUbjy ZPFhrzjOhTqT/EOoQBAgn52cZ4D5DFFHAKrY/h6hVrULDIQU6UE83b60+mNpYuCNadb6 pdsd5GJ3xW1CLPKheP91yPmn42dS0QtZSn/dRLX7V9IM1uzWEDdMZYzTeURzHk6qiEoL bx/3OTuz9CUrD9L3O1xpxXPRgnhGK2nNFGUJQZ1yHvEXYlLQuiBpJLYE5XDece02UD7v +CXLllFrRA30dT+JP5P9WSITJjQwzDDK2i3NcOLHvtFO5c4FC7mO44ETac3Chxlwn7Yd RLuA== 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=+Go9hMY3Fv+2K5wQX0VTh4xZIIq6XBBh6l03wqYeT1o=; fh=cyHazg1AN4VWOd/H44jDxx9utHvPIhsaoOANqSmNx2o=; b=Ugv7PMMlHxMgqywm/yzplUycfAmMq/GYBarjvHpw7sFjXuuufOx21iQa5Mxq/VItN3 v+Ub1vUiN+RdAkuRoDv5uD7P9NxYKB4aJyywY6eiYm8Geqcl/ClGpWnM5ewMtkZtwWD+ UjO82++41GwxG7z32GlSBpFibvB4qXSHS8ora9IIa/7N3nex5ynDvRSVw9dj1RAtV+fG zXsguTNuZxXr3y6mTmEuBcJHVLn58RMltyA9YceVqA/JOFUrYRKwejT128/pSD4c5njV AxKGE+ej+W65l+iBUrbRZ6x8ZruCP7lzkcc2VmbRk2PfiBjHfkYVxm8C7BWoh2MIgNAL iHSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cDfcvTch; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id e30-20020a630f1e000000b00589878c0a5bsi1734322pgl.71.2023.11.23.11.10.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 11:10:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cDfcvTch; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id E48FB81ED045; Thu, 23 Nov 2023 11:09:58 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230072AbjKWTJn (ORCPT + 99 others); Thu, 23 Nov 2023 14:09:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbjKWTJm (ORCPT ); Thu, 23 Nov 2023 14:09:42 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBE749E for ; Thu, 23 Nov 2023 11:09:48 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C706C433C7; Thu, 23 Nov 2023 19:09:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700766588; bh=H31tYMRMi9KqwFq+p39ksYkA9U91as7rK22EFXyG874=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cDfcvTch5RfNfxfF5D79XFdoatrLc/szYurTXztwWV/Dqw2WfIvQRbT1ly1TJRkr1 JdnTlb4EQGY1DiK2wriv9OEDl28V0vdl7Dtcbl3phz7B9SzdMCTD9ePpKgjNPVah4c J7EkAjCek5sBU/ZDkej90SIeovaVGGEpOIBo4NfyAJHgVqVjkdMP/gla45kzs7imCv z5TGPafyWpBEln7Ci39ksTkqTtO1jWWOQFRlmIh9BT7ntLm7JigCIZN/E04Y3wN2eq v3f6L4nGQ2mtNfDRqsaYJtCDCEoKOqE5udKhRbKrXsyvn4yCz8FWKHHacSNJMpo/CN 9yf6M2Tk+P45g== Date: Thu, 23 Nov 2023 19:09:36 +0000 From: Jonathan Cameron To: Andy Shevchenko Cc: mitrutzceclan , linus.walleij@linaro.org, brgl@bgdev.pl, linux-gpio@vger.kernel.org, Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Walle , Arnd Bergmann , ChiaEn Wu , Niklas Schnelle , Leonard =?UTF-8?B?R8O2aHJz?= , 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 v6 2/2] iio: adc: ad7173: add AD7173 driver Message-ID: <20231123190936.51f61b8d@jic23-huawei> In-Reply-To: References: <20231123152331.5751-1-user@HYB-hhAwRlzzMZb> <20231123152331.5751-2-user@HYB-hhAwRlzzMZb> 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.3 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,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 agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 23 Nov 2023 11:09:59 -0800 (PST) > > ... > > > + return vref / (MICRO/MILLI); > > Wouldn't MILLI in the denominator just suffice? Just a quick comment here. Given this is converting from micro to milli units I'd consider the maths here be acting as documentation of that which would be lost if /MILLI only used. Need spaces around the / though > > ... > > > + case IIO_CHAN_INFO_SAMP_FREQ: > > + reg = st->channels[chan->address].cfg.odr; > > + > > + *val = st->info->sinc5_data_rates[reg] / MILLI; > > + *val2 = (st->info->sinc5_data_rates[reg] % MILLI) * (MICRO/MILLI); > > + > > + return IIO_VAL_INT_PLUS_MICRO; > > + } > > > + ret = fwnode_property_read_string(child, "adi,reference-select", &ref_label); > > + if (!ret) { > > + for (i = 0; i < ARRAY_SIZE(ad7173_ref_sel_str); i++) > > + if (strcmp(ref_label, ad7173_ref_sel_str[i]) == 0) { > > + ref_sel = i; > > + break; > > + } > > > + if (i == ARRAY_SIZE(ad7173_ref_sel_str)) > > + return dev_err_probe(dev, -EINVAL, "Invalid channel reference name %s", ref_label); > > Too long line. > > > + } else if (ret != -EINVAL) { > > + return dev_err_probe(dev, ret, "Invalid channel reference value"); > > + } > > > Use standard pattern and it will be easier to see that 'else' is redundant. > > if (ret == -EINVAL) // However I don't like this handling of > // properties, but up to you and maintainer Personally I'd check for existence of property first and only try reading if it exists. Avoid dance with resetting ret to 0. > ret = 0; > if (ret) > return dev_err_probe(...); > > > BUT. Isn't it a home grown variant of fwnode_property_match_property_string()? true enough... I'd still add an existence check first given this one is optional. Jonathan