Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2339384rdb; Mon, 20 Nov 2023 08:22:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IEDdqFxGQt4A/DrR0k+HoE45EeArevRzy8ja/GRwa6JgY1yfXRm775i0wTV0Mo06N/z4cYF X-Received: by 2002:a05:6a00:4c1b:b0:68f:c078:b0c9 with SMTP id ea27-20020a056a004c1b00b0068fc078b0c9mr11426870pfb.11.1700497367841; Mon, 20 Nov 2023 08:22:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700497367; cv=none; d=google.com; s=arc-20160816; b=sCqL3q9/7BPI8WJcNXVk5h1Y49VJn99GDpXaND2SLPiKcRvKBNR+86+ogLRf4wCzDN wNoqqO5pNfF3Lp9D4bjE3iejn5IFo6004grHDfgoH6XfQAOpSA2OqwkgCaIRk/PxVqNi 07QNEhiRvaLmR1wWD+J/ZzF2kau4L3t2oANBnEDp2mMPdgbHQl73aOoiS0QaQMMm5Tz3 I+aTyg6y+qI1+iuGmJzMdA5FV7vmrNcc1X2l5e1TAzXJkjQU7ZQWZ2mr0cxPwIfEARG+ 3PRIcYXUbY74X9otXlmfJp8EYxtOeGOybIVtjCoXztjFHfpNzYJe3oX5ffbos3ePjdCE jY7g== 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=PccokFcaOW5BEkJPOs60hd02SY1Q0qcIQOXUjLjJouc=; fh=XWw+BW6ysVVvGwvBQ/Y14nJAJ2sn5fZpKa7olY0ritM=; b=aBTTAxeiJut6vA1NRu2JC+Oni3bWuo3JljPmMA2Shn0fvkLocBw4K95exKOnJYHXsL CGG/mJfwz8TtIb9/W+7w1o5MFmZTpHzXO4GMb0C/qaz8EvhTvawyNjGX4S8g1lMhRBib vO4y8Ie5LO48b3kGUUsJtczYgH3DgFmGL/ADpDERB9UtGTBDsuZ9GQcohIGd6xBNqGVs QsK2nPJ0U8u16aK10y0RRGjBT5GibhDOKTT8TXNQicZZa2KVancOWFbtgkgJR0h1QV5n Fc5PkjMDDsswSmYlRvcIeYl+d2599JiMEVmYaNLrttATuvN5xBD/8M2GtkJGEm5W4crr N/qw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id b5-20020a056a000cc500b006cba60de063si2049761pfv.22.2023.11.20.08.22.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 08:22:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id DED3880725F8; Mon, 20 Nov 2023 08:21:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231486AbjKTQVT (ORCPT + 99 others); Mon, 20 Nov 2023 11:21:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230129AbjKTQVS (ORCPT ); Mon, 20 Nov 2023 11:21:18 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24979ED; Mon, 20 Nov 2023 08:21:15 -0800 (PST) X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="371825473" X-IronPort-AV: E=Sophos;i="6.04,214,1695711600"; d="scan'208";a="371825473" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 08:21:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="836767261" X-IronPort-AV: E=Sophos;i="6.04,214,1695711600"; d="scan'208";a="836767261" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga004.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 08:21:10 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.97) (envelope-from ) id 1r571G-0000000Fb43-06bt; Mon, 20 Nov 2023 18:21:06 +0200 Date: Mon, 20 Nov 2023 18:21:05 +0200 From: Andy Shevchenko To: Ceclan Dumitru Cc: 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 v4 2/2] iio: adc: ad7173: add AD7173 driver Message-ID: References: <20231116134655.21052-1-user@HYB-hhAwRlzzMZb> <20231116134655.21052-2-user@HYB-hhAwRlzzMZb> <5cf3824f-6375-4c76-86ff-c5389ddf4196@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5cf3824f-6375-4c76-86ff-c5389ddf4196@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Mon, 20 Nov 2023 08:21:24 -0800 (PST) On Mon, Nov 20, 2023 at 05:55:12PM +0200, Ceclan Dumitru wrote: > On 11/20/23 15:00, Andy Shevchenko wrote: > > On Thu, Nov 16, 2023 at 03:46:55PM +0200, mitrutzceclan wrote: ... > >> +struct ad7173_channel_config { > >> + bool live; > >> + u8 cfg_slot; > >> + /* Following fields are used to compare equality. Bipolar must be first */ > >> + bool bipolar; > >> + bool input_buf; > >> + u8 odr; > >> + u8 ref_sel; > > > > If you group better by types, it might save a few bytes on the architectures / > > compilers where bool != byte. > > > Grouping by type will result in not being able to use memcmp() for > comparing configs. But then there is the issue that I was under the > assumption that bool=byte. If that is not the case, the config equality > check might be comparing padding bytes. It's most likely the case, BUT... it is not guaranteed by the C standard. > In this case what do you suggest: > - using the packed attribute > - using only u8 > - drop memcmp, manually compare fields Use struct_group() to show explicitly the group of members. If it's not an ABI in any sense, then memcmp() is fine. ... > >> + cmp_size = sizeof(*cfg) - offset; > > > > sizeof_field() from the above mentioned header? > > This computes the size of multiple fields, following cfg_slot. Better to > group the fields that need to be compared into another struct then use > sizeof_field()? See above. ... > >> + return vref / (MICRO/MILLI); > > > > What does the denominator mean and why you can't simply use MILL? > > Original vref values are in micro, I considered that it was adequate to > represent the conversion from MICRO to MILLI as a fraction. > > >> + *val = st->info->sinc5_data_rates[reg] / (MICRO/MILLI); > >> + *val2 = (st->info->sinc5_data_rates[reg] % MILLI) * (MICRO/MILLI); > > > > Same Q about denominator. > > > Here, a misunderstanding on my part of a suggestion from Jonathan in V2, > will be removed. You need to clarify with him that. -- With Best Regards, Andy Shevchenko