Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp420002lqh; Thu, 28 Mar 2024 06:15:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW5MrdRELgwyswKP9CN9EqAyJGK/IMNWtaYSBo7S3617azYld/uGACMvWMXqxbRBNiw01o5UvSZmATaVNTkWiFQa2lhcFoo2w2rxRuzZw== X-Google-Smtp-Source: AGHT+IHFknqy32DnRuDqb+4+Y8mW0H6V5rD9RUeKfdPwzpcOrDTLdWB95+SMNwvFkHMVDajneusd X-Received: by 2002:a05:620a:16d6:b0:78b:c1ee:d7e6 with SMTP id a22-20020a05620a16d600b0078bc1eed7e6mr852323qkn.52.1711631724469; Thu, 28 Mar 2024 06:15:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711631724; cv=pass; d=google.com; s=arc-20160816; b=k14VRoIEfiIn3IE+Gvh4QVtDTCquHOEfjqe3cb1lBSYrXR0ixKNB1Fp/37TyOKxzqt XG2ApTF/PSynaMQu8rNVacNuctJhZsArjGoLs4X3ear6qk9xqrQMObX/9c1c/eV2F9DJ hv8ZUR3tP6ij6GeUAsioiUIVlDFkVrvVpRY5x5iw8mmsmxpBsLrDwOiNDPGiiaSvPBWt m6yKGHUa1M8LQvRGKeX8WcqRrY47C1R0JdOeqJScmJYlKgqKbYNPIdoMebVWzmkYpE8i lD8qB1gED6VdCqmq1zWp7mavOxsbAoRwBwgx8d3v5ysQbJYMamprHFDGRPnhLwneH+hP eiYg== 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=dX7EcA+uYITgmy7QvYdKr1x/yZlMVwzA3FldtOyf3ro=; fh=aO7VwMzXorvFb/cjS7UqKL2BI3mnI34qIdePd4Zg25U=; b=uq/YhguvW+w0BRChqWPliUSee93Ntrvmg9DDY3Sm1tbi0szahfcQ16Emmh7EjjG8SV fnJLMgEw5gX3GzHULvWLSHf6aNwXyy6EnkdCZjcspZ32nk0qfW0cRUt+JiCADwMpdUGL 59iZuH7GkzBddPsx5rK8DZWcwUJEaqd0GGgI9wSx1fB2AQDZPmPO99jPtHD1Arhd6bqO 1z7DZHTWryjW2gFKqgVYuuUFCTpyQqp3VcIQgpfnTYWW5aitwXMRawxb2a18qU78N22s oPcPduoNARKagXzUwCwk989bipXePfHaT7HXK8MVy2pB3zrfbTPoLYH2q6bu42P3/BHb 4h5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=McOYBOmO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-122942-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122942-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t5-20020a05620a0b0500b00789ecdbf325si1422440qkg.629.2024.03.28.06.15.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 06:15:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122942-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=McOYBOmO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-122942-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122942-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 316F91C283AE for ; Thu, 28 Mar 2024 13:15:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB61B80028; Thu, 28 Mar 2024 13:15:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="McOYBOmO" 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 E7A00847C; Thu, 28 Mar 2024 13:15:17 +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=1711631718; cv=none; b=VsBr2rD2oSdTdMxypNXwavpD5lWguNvzsM/LVDGapD8nblXp0wnRwefkXXph90ZC6ZtoInSAkXK0onBntJ6U5M0sjGIOpiSzrQwRFKG+r2/eYpcrQ9wkrQk0Ts4dTzogH72l6QFuak125c1P3HxcgdUVexenneSa+s0qcHhDhkE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711631718; c=relaxed/simple; bh=6TWeWcjSh/g81Ig8RxxLjk0o2Q11JmZ1utPGtly2dYU=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bIMK8AaKTmDhj7g8kbK0XTvsw33ChoGfl6UvU+C4kN4g8RElIBw2ETSwZvGaY2YqCHpqTOJBP2EDgugq/LiCKt9AiINundAY9wWmRK6q+DTbgQzJXQpSZsdVYFx/ZVXlqgvpFFsAL/3OE9PNxAG4xe+7Qm/VC06lJ9F1cU1v8Ys= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=McOYBOmO; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C906C433C7; Thu, 28 Mar 2024 13:15:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711631717; bh=6TWeWcjSh/g81Ig8RxxLjk0o2Q11JmZ1utPGtly2dYU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=McOYBOmOxr/4SJ6wInhGNN/Dwf766g0iIc7OaU4hNurqwBGkOrkfPACbNRk6uwwGn JJb8eZuQo2YKEcHgQY9Z0l0qEvHQ/lSne2WjHvKhsZhJD4d8b+MGgk0+AUhkkTQjh5 Dy6iokvGsIvTrkA/+pK6GPSLcxeJ5oSOmVFWgwhUVHduxJjW8r9QbKTVpIDES3YFDa lD7OWQVY33gb+DDQVc5fgBP65U7mc523IqlWbkuYlC8T4tUNz/slrT/e4+J07mv6tB cx0Rx9t4M4PeGOnGZMRr6mgNhiEjZasUWEvB/+ZX/CQ6UcN3EX0EddKMRaVcTbXJd3 HN/TqpYU+QzRA== Date: Thu, 28 Mar 2024 13:15:00 +0000 From: Jonathan Cameron To: Lothar Rubusch Cc: 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 v4 1/7] iio: accel: adxl345: Make data_range obsolete Message-ID: <20240328131500.068c82c3@jic23-huawei> In-Reply-To: References: <20240325153356.46112-1-l.rubusch@gmail.com> <20240325153356.46112-2-l.rubusch@gmail.com> <20240325203155.23ddfe3d@jic23-huawei> 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=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, 26 Mar 2024 21:59:34 +0100 Lothar Rubusch wrote: > On Mon, Mar 25, 2024 at 9:32=E2=80=AFPM Jonathan Cameron wrote: > > > > On Mon, 25 Mar 2024 15:33:50 +0000 > > Lothar Rubusch wrote: > > =20 > > > Replace write() data_format by regmap_update_bits(), because > > > bus specific pre-configuration may have happened before on > > > the same register. Changes then need to be masked. > > > > > > Remove the data_range field from the struct adxl345_data, > > > because it is not used anymore. > > > > > > Signed-off-by: Lothar Rubusch > > > --- > > > drivers/iio/accel/adxl345_core.c | 9 ++++----- > > > 1 file changed, 4 insertions(+), 5 deletions(-) > > > > > > diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adx= l345_core.c > > > index 8bd30a23e..be6758015 100644 > > > --- a/drivers/iio/accel/adxl345_core.c > > > +++ b/drivers/iio/accel/adxl345_core.c > > > @@ -42,13 +42,13 @@ > > > #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)) /* ignor= e spi-3wire */ =20 > > > > I'm not keen on seeing masking of a bit we don't yet > > handle done by value. Can we instead build this up by what we 'want' to > > write rather than don't. Will need a few more defines perhaps to cover > > the masks of SELF_TEST, INT_INVERT, FULL_RES, Justify and Range. > > =20 >=20 > Good point. Anyway, there is also an input driver implementation for > the adxl345, mainly dealing with the interrupt feature as input > device. Thus, for the iio implementation I would suggest to reduce the > mask just to cover SELF_TEST and FULL_RES and leave INT_INVERT out. Is > this ok? yes, that sounds fine >=20 > > > > > > #define ADXL345_DEVID 0xE5 > > > > > > struct adxl345_data { > > > const struct adxl345_chip_info *info; > > > struct regmap *regmap; > > > - u8 data_range; > > > }; > > > > > > #define ADXL345_CHANNEL(index, axis) { = \ > > > @@ -219,14 +219,13 @@ int adxl345_core_probe(struct device *dev, stru= ct regmap *regmap) > > > data =3D iio_priv(indio_dev); > > > data->regmap =3D regmap; > > > /* Enable full-resolution mode */ > > > - data->data_range =3D ADXL345_DATA_FORMAT_FULL_RES; > > > data->info =3D device_get_match_data(dev); > > > if (!data->info) > > > return -ENODEV; > > > > > > - ret =3D regmap_write(data->regmap, ADXL345_REG_DATA_FORMAT, > > > - data->data_range); > > > - if (ret < 0) > > > + ret =3D regmap_update_bits(regmap, ADXL345_REG_DATA_FORMAT, > > > + ADXL345_DATA_FORMAT_MSK, ADXL345_DATA_= FORMAT_FULL_RES); > > > + if (ret) > > > return dev_err_probe(dev, ret, "Failed to set data rang= e\n"); > > > > > > indio_dev->name =3D data->info->name; =20 > > =20