Received: by 2002:a05:7208:70d5:b0:7f:5597:fa5c with SMTP id q21csp2212020rba; Sun, 24 Mar 2024 06:49:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVuwUnupqPIIMTwAhBZRm0mi9oQ7Rfd7GThVOQmStmbFpTe+5PPzfyCzTSeMfxKdOEfLK3C5f7PT+Ga59331l4AVBy8zx0buLWh8Zg4yg== X-Google-Smtp-Source: AGHT+IHvpA9H8QwSBTRdlQuUP4WMJL2lC/vRYXOoJlFHRQ7iSP3DjARLVgX6AtRuWVL1gmooCcP9 X-Received: by 2002:a05:6a00:178a:b0:6e8:3d35:a880 with SMTP id s10-20020a056a00178a00b006e83d35a880mr5411147pfg.7.1711288145657; Sun, 24 Mar 2024 06:49:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711288145; cv=pass; d=google.com; s=arc-20160816; b=YMBhyIwzVqxR1SRgKRmQ9nEI0zYILCqEURxKUUO50wNAgTnbNReXLxKveWRUR8iI6v S4WtELMm+ilD869ppR6TbVjXPY6mxgKAe6p0HFa8uRDE8hkw2SkeViARfk6CbdeZSDkI 6vxkIjzf0x+B5fW75wgj5X4hQAxXquzX4fm42b6A0Mhnz8OTuJz2vxFB3QR/iFxwFKuA xhPx4CGW/AL7WCaF1H6AU3jJJgk3eVwL0fioWQmEsBTIpm9cATUYHKWW6G8RBWd8JU1p EFYuJ8MBDhiXmY/FUxvcqEH1wxJM9SVGn6TB92gNgEYHX3/naRFCBZuXZMEH5kF6Mcey LVpQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=8S/0emR+Ye5YUkZb9BI+lz7/idg9jCJM4cg1DbWvA0k=; fh=zTrl+6Ru59Ke28gt8OaaT0CEjYj/E8VOZuC/0WM6sgQ=; b=pYeoxbrACpAHYrtR6k7Z9jdFc4+kCVvh/vMrMFFOJj9UK3kJftaQMHsDYc40W02/3j m2YxQd4NT9eABJkBITcVb+BcLTwvoUuZ7GMP2ncBXSISGy0hoy4jRPER02pgL1pKjpcq M0l2F7rF7MMe5AWAO0x024rXjFpmCkX9Scp24JbWHNcwvCMkF4emrAC3QtDJKLsgVlSp hKdTpMNz5VG1OkAEzWKNgPeh7C4N6v2t4yGJDjSLtgU7akMNI6RXN6LS5/QBTbyD+lgd hjf9Z/B3qvhzQd2TukpgASGysVcQOrGJTvOhDOooZgebLYijDxAJs2mQvBrBOYqblEFI K50g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Svn04hu9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112684-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112684-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id p10-20020a056a000b4a00b006eaab1c15f5si339470pfo.247.2024.03.24.06.49.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 06:49:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112684-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Svn04hu9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112684-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112684-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 84844B20EBC for ; Sun, 24 Mar 2024 13:48:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ED89717C8D; Sun, 24 Mar 2024 13:48:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Svn04hu9" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E62717BD8; Sun, 24 Mar 2024 13:48:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711288129; cv=none; b=al16N1oSKFHGPM1RsPpM1u8HGIKZY/1f/SqCxsemjOObhADb95YCtBrhCx+17TI/cjbexLuRrqPKY1cA5Xf2hZF87Tp1zngpOrhFdGaRAp6ef2Z9GPyEBBLxm7eutQK4R2WNWF4QB+N8qxfboWBy2NngseICCKIr66ScQbXnZwY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711288129; c=relaxed/simple; bh=zRMB1/rY1fmj+rn+rQdZtN7w8NIdtyU62gDn1wZDU5k=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kcA9/w9K1PK5VYbEoRjhrVCZS+zlx10E+q21Z/rfJuHdspWCdjDXmZrGTis1qz4/X2Yy6e5pS023+iFg6j8yAC98A1VbtC94WC+v5Gqso16CxsgJ874eWE9OUjzC4HsUKjH7po3mNg99gFOZXd+L2Ieu2Sb8Qn+RFVXxvFwLR8Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Svn04hu9; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A34EDC433C7; Sun, 24 Mar 2024 13:48:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711288128; bh=zRMB1/rY1fmj+rn+rQdZtN7w8NIdtyU62gDn1wZDU5k=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Svn04hu9InZRCzC98oCb/1Di+4l+P5WVSgmISLjgIxOmc+Bplh1GGkXY9m52TlQU7 55/6RxB7RCf3GFcp8+zkztllJVHR81qxbl9Ck30+xbfOi1UniDpyGOkrursnTkBacs Rh7WXpjl4+VOs0VcPT0JeQvb45OWkrvLjGmE1S37VBMn7rz9AYseapjHVDNcYc+5Cb fWEkvclV2/dbdQZcUbR/ExzOUsAwLkgE82okiVxP8RbxQoqW+/b/p4sVLVcmQsj1ED HjZpTBbzafii13qSTURf6vXc+Ca6RVtOq1x7jhN9ingByu/6a7lgGwP5laJouV1iV/ 8TxhoCUmCW5qA== Date: Sun, 24 Mar 2024 13:48:35 +0000 From: Jonathan Cameron To: Lothar Rubusch Cc: Krzysztof Kozlowski , lars@metafoo.de, Michael.Hennerich@analog.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, eraretuya@gmail.com Subject: Re: [PATCH v2 1/3] iio: accel: adxl345: Update adxl345 Message-ID: <20240324134835.56bd216c@jic23-huawei> In-Reply-To: References: <20240322003713.6918-1-l.rubusch@gmail.com> <20240322003713.6918-2-l.rubusch@gmail.com> <51e3683f-be53-4bb7-a994-ffd05744a745@linaro.org> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 23 Mar 2024 13:16:56 +0100 Lothar Rubusch wrote: > (...) > > > Signed-off-by: Lothar Rubusch > > > --- > > > drivers/iio/accel/adxl345.h | 44 +++++++++++- > > > drivers/iio/accel/adxl345_core.c | 117 +++++++++++++++++-------------- > > > drivers/iio/accel/adxl345_i2c.c | 30 ++++---- > > > drivers/iio/accel/adxl345_spi.c | 28 ++++---- > > > 4 files changed, 134 insertions(+), 85 deletions(-) > > > > > > diff --git a/drivers/iio/accel/adxl345.h b/drivers/iio/accel/adxl345.h > > > index 284bd387c..01493c999 100644 > > > --- a/drivers/iio/accel/adxl345.h > > > +++ b/drivers/iio/accel/adxl345.h > > > @@ -8,6 +8,39 @@ > > > #ifndef _ADXL345_H_ > > > #define _ADXL345_H_ > > > > > > +#include > > > + > > > +/* ADXL345 register definitions */ > > > +#define ADXL345_REG_DEVID 0x00 > > > +#define ADXL345_REG_OFSX 0x1E > > > +#define ADXL345_REG_OFSY 0x1F > > > +#define ADXL345_REG_OFSZ 0x20 > > > +#define ADXL345_REG_OFS_AXIS(index) (ADXL345_REG_OFSX + (index)) > > > +#define ADXL345_REG_BW_RATE 0x2C > > > +#define ADXL345_REG_POWER_CTL 0x2D > > > +#define ADXL345_REG_DATA_FORMAT 0x31 > > > +#define ADXL345_REG_DATAX0 0x32 > > > +#define ADXL345_REG_DATAY0 0x34 > > > +#define ADXL345_REG_DATAZ0 0x36 > > > +#define ADXL345_REG_DATA_AXIS(index) \ > > > + (ADXL345_REG_DATAX0 + (index) * sizeof(__le16)) > > > + > > > +#define ADXL345_BW_RATE GENMASK(3, 0) > > > +#define ADXL345_BASE_RATE_NANO_HZ 97656250LL > > > + > > > +#define ADXL345_POWER_CTL_MEASURE BIT(3) > > > +#define ADXL345_POWER_CTL_STANDBY 0x00 > > > + > > > +#define ADXL345_DATA_FORMAT_FULL_RES BIT(3) /* Up to 13-bits resolution */ > > > +#define ADXL345_DATA_FORMAT_SPI BIT(6) /* spi-3wire */ > > > +#define ADXL345_DATA_FORMAT_2G 0 > > > +#define ADXL345_DATA_FORMAT_4G 1 > > > +#define ADXL345_DATA_FORMAT_8G 2 > > > +#define ADXL345_DATA_FORMAT_16G 3 > > > +#define ADXL345_DATA_FORMAT_MSK ~((u8) BIT(6)) /* ignore spi-3wire */ > > > + > > > +#define ADXL345_DEVID 0xE5 > > > + > (...) > > I think I see your point. My patch has more noise and lacks a logic > structure in proceding. > I will resubmit, but may I ask one question in particular. I moved the > entire list of register > defines from the adxl345_core.c to the common adxl345.h. > For setting spi-3wire with my approach, only two of those defines are > needed. I think it is > nicer for readability to keep the defines together, though, in a > commonly shared header. > Nevertheless most of the defines are just used locally in the .._core.c > Should I move them for refactory? Move them as a block (which you did). It's confusing to have only a subset of defines in one place. > I feel there is no reason to move them. On the other hand I see many > drivers keep them in a common header. Hence, is there a best practice > which justifies moving them to a header?