Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp783722lqh; Thu, 28 Mar 2024 17:04:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX49Zx9DaGgmT8CwkJ6GoIWKGHJC4J8TRk+f5bOKdchkMVxeFEqXunjSApim5uWCzl/uG9mBnYLzQ2yxlZtvhzJhaRLZWGHtgq/+7alIg== X-Google-Smtp-Source: AGHT+IF/NedlneZhygj2ahMO66MenXTF7Dvz9Ne8Hi89QByddH7oG3GL5La+PeBV0MsNIki0pGVf X-Received: by 2002:a50:c30b:0:b0:56b:cbb6:f12b with SMTP id a11-20020a50c30b000000b0056bcbb6f12bmr410583edb.41.1711670658319; Thu, 28 Mar 2024 17:04:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711670658; cv=pass; d=google.com; s=arc-20160816; b=teZAtZ+icKDayGlGJ2FAiHHZUFUOjJLrZiAFfn7DvIKPtwjK7GGIsYJEFkkvvK4AnE L4znsG+xutr35jZgOQH1ma8IYBAzPLjyEq4GOmFYg42k7Fn5ZAhLQOyCMTysoeUOlL98 HkFQqkxiO29gfp1OvwmHhH8IPYi1NC+qLCyhDYqBvV6EJxWzSvAoyKEhaXvvBvIZtf6K 36P3cs4O1yhs6UFrxs0NpK2Zt76KRzAbw+xEQGo9kD/lj+xS4awxdoOVPic17W4Palf8 K8luNsMaoK+PQBRHmLofOAh0m+wqV1TPwReZ05K82Tcw9mczSww1r9Fq7aBccKtLhXmz 0McA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=PKJflJe9SAvt41XpvEFgU1eczu3XFIziapyQDCRKyyM=; fh=6bUOy4XdtLKMcBB+H9TNnzpZGJhVT6FQFC6nt/Sc5JU=; b=KIlXTH9i3SiLNH5THLnP8qDlVfp96UKFaOMfvc8Hmbu/tJDFr/o6yRnZXKvSQ7A7Ew 0PAki7pTzS5ZDA6v/Ycfdaf7UU9oiXEnP51YiCeiADcN8mwQmQWpLpE55mtSVdmq40Xi 6MOcz1Dk1fsslhM2TOc+oWpivY9tSlmaEBWg3Rrz0Wks0h5E6ilf2Ac7v0kjFmlmvAe6 hP+BanMYO5D+8uX0muat67FcTyUU/Q0nj7/wuW74UJthdl+yXTE3gVjbtcyNhjhEZ23Z mFYKpHinWTTtA7o0Ps66akJi1q5MMAH23/Ny1EsBYvXepqx4ldSOytsAwtqiu6gm7SD6 NZ7w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FY2YYAMi; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-123849-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123849-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id bl21-20020a056402211500b0056c0d7e7a29si1328868edb.190.2024.03.28.17.04.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 17:04:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123849-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FY2YYAMi; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-123849-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123849-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id BFCB41F23864 for ; Fri, 29 Mar 2024 00:04:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E9AB846C; Fri, 29 Mar 2024 00:04:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FY2YYAMi" Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D56B23A8; Fri, 29 Mar 2024 00:04:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711670649; cv=none; b=uUJgfcNGWsk/QJWkC8FdHDF/c2wavSXtzZIT4maWEvrd/neqXhdVUKHV64+bVA77qV82bwdLt8CMOfWjxTDfHW20GfHSplVaro1JWEXhrS8CELyl0YdywRtg0IRLwxqa22FgRjRJG1LbL4YWoL2IrQa02meaTdjDax45bfhRhDc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711670649; c=relaxed/simple; bh=djpBvSxFpgiKVso1vC8eoz/ew1HepMaOFxyaEXBkZ+w=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=amLQiXZYtz+J+RFSivFzWN8WM+Bzl3tCSIhF18i+8sC94SoZdemedY3cXsWzpA0bkN7qE/K3yhcFWxfU6RyXjQQ/otATT8G4iKk3YzKBF3jqEtJU/nDu91cZc+1xTcp+cacuAPRetxBMFkywTsIbTO1T2n2uM82fJ0x1kDKLNaI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FY2YYAMi; arc=none smtp.client-ip=209.85.128.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-60a0a1bd04eso17247187b3.1; Thu, 28 Mar 2024 17:04:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711670646; x=1712275446; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=PKJflJe9SAvt41XpvEFgU1eczu3XFIziapyQDCRKyyM=; b=FY2YYAMim++bK/92SqLjDuF99hw/a6vjfI/WJTsE64TUb0xMFuMMQ8SzJGtfArN1vI Wu92lwq5nh2HXfXnznxcASUwLG8ha/Vkn4GFcZ+oBQk+kDRUv7O8V1Uam8zuOwtqihZC vDVtIZI6VSGF+TrZIQE6X23IN4asEd4FsKSjLiKjAYrsd4RlkYrAjDc+V9BRLWsfhYfw R6dAYKkWEIZWiFq7jQBjoLor7i1TKwYajsFXvu+6lGnq9UOR/2+/Md3S9rW2kSmBsHT2 hLanPFfpdds1XZUVjycLQhqKGmXwb2wT7Re5/qrXaDN2g4bzWgYJayMhzRQmLhOrGXRD kH1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711670646; x=1712275446; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PKJflJe9SAvt41XpvEFgU1eczu3XFIziapyQDCRKyyM=; b=G/omOjXmh0BSqhybVFygPq/MBfYbRhtVAaSxHYgMKtZx+rSvLGNdpxXB+u+1Vo4Q8M c5PGIg67du3sQ+rdPtJLrkUjz1MXMS59vpmfBSUwAMLFQ6dSNGaK7zaGv4E1jN/gm/oA IHkblMBDhKI2UxAmid+4KntnRyX+aX8gJg0iMGqzSed76Z6iDv20CzpbnUSdxiUi8i00 x/9UPQXdnl7yC144YEVI3xN5loenEd5a22HUecFKU4EQf6AYr8BTB1jeXgJ4ioXBzEI3 PsP/RX0bdSeTx3G+ZcuExJpYEhuhkWrP5iPTPyhZzhquegD49J0tf8dB+n7u+ciaexdi KXzQ== X-Forwarded-Encrypted: i=1; AJvYcCVE9+sLaOZrGTRf6ZbJ8CqQII7ilNmK5QeNrktWK7udzoaU+pb2nW6pmJh2XOi4EcT7xzasmi7cHYVQmghElScEdhE0t1leNKIowZyRQQTfJAoT3uKpKDJ9l0PqvIjh4BYhapSgPDP0aLkrc2QJwQw8ndVsH97xJGBo1s3VGBIagAavfw== X-Gm-Message-State: AOJu0YwVMlvzHNbsX09BdQW0VO3eYP0VXg0NuXdtSX/Edbgtg1K4gIGq lbSLTjAcUY+MAFRBQuMHFY+TyJF4yMOYdTa95Dmfm4LnGri/SpDg0vta/9AvwNh6wW6qnRW3kDj OV9/3SUdyoK4eAAEf3YRn7Sx55fw= X-Received: by 2002:a81:488f:0:b0:607:9102:c1b0 with SMTP id v137-20020a81488f000000b006079102c1b0mr1063365ywa.43.1711670646241; Thu, 28 Mar 2024 17:04:06 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240327220320.15509-1-l.rubusch@gmail.com> <20240327220320.15509-2-l.rubusch@gmail.com> <20240328133720.7dfd46b0@jic23-huawei> In-Reply-To: <20240328133720.7dfd46b0@jic23-huawei> From: Lothar Rubusch Date: Fri, 29 Mar 2024 01:03:29 +0100 Message-ID: Subject: Re: [PATCH v5 1/7] iio: accel: adxl345: Make data_range obsolete To: Jonathan Cameron 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Mar 28, 2024 at 2:37=E2=80=AFPM Jonathan Cameron = wrote: > > On Wed, 27 Mar 2024 22:03:14 +0000 > Lothar Rubusch wrote: > > > Replace write() data_format by regmap_update_bits(), because bus specif= ic > > pre-configuration may have happened before on the same register. For > > further updates to the data_format register then bus pre-configuration > > needs to be masked out. > > > > 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 | 18 ++++++++++++------ > > 1 file changed, 12 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl3= 45_core.c > > index 8bd30a23e..35df5e372 100644 > > --- a/drivers/iio/accel/adxl345_core.c > > +++ b/drivers/iio/accel/adxl345_core.c > > @@ -37,7 +37,15 @@ > > #define ADXL345_POWER_CTL_MEASURE BIT(3) > > #define ADXL345_POWER_CTL_STANDBY 0x00 > > > > +#define ADXL345_DATA_FORMAT_RANGE GENMASK(1, 0) /* Set the g range = */ > > +#define ADXL345_DATA_FORMAT_JUSTIFY BIT(2) /* Left-justified (MSB) mo= de */ > > #define ADXL345_DATA_FORMAT_FULL_RES BIT(3) /* Up to 13-bits resolutio= n */ > > +#define ADXL345_DATA_FORMAT_SELF_TEST BIT(7) /* Enable a self t= est */ > > +#define ADXL345_DATA_FORMAT_MSK (ADXL345_DATA_FORMAT_RANG= E | \ > > + ADXL345_DATA_FORMAT_JUSTIFY | \ > > + ADXL345_DATA_FORMAT_FULL_RES | \ > > + ADXL345_DATA_FORMAT_SELF_TEST) > This needs renaming. It's not a mask of everything in the register, or > even just of everything related to format. > > Actually I'd just not have this definition. Use the build up value > from all the submasks at the call site. Then we are just making it clear > only a subset of fields are being cleared. > I understand this solution was not very useful. I'm not sure, I understood you correctly. Please have a look into v6 if this matches your comment. Now, I remove the mask, instead I use a local variable in core's probe() for the update mask. I added a comment. Nevertheless, I keep the used flags for FORMAT_DATA. Does this go into the direction of using the build up value from the submasks at the call site? > Jonathan > > > + > > #define ADXL345_DATA_FORMAT_2G 0 > > #define ADXL345_DATA_FORMAT_4G 1 > > #define ADXL345_DATA_FORMAT_8G 2 > > @@ -48,7 +56,6 @@ > > struct adxl345_data { > > const struct adxl345_chip_info *info; > > struct regmap *regmap; > > - u8 data_range; > > }; > > > > #define ADXL345_CHANNEL(index, axis) { = \ > > @@ -218,15 +225,14 @@ int adxl345_core_probe(struct device *dev, struct= 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) > > + /* Enable full-resolution mode */ > > + ret =3D regmap_update_bits(regmap, ADXL345_REG_DATA_FORMAT, > > + ADXL345_DATA_FORMAT_MSK, ADXL345_DATA_FO= RMAT_FULL_RES); > > + if (ret) > > return dev_err_probe(dev, ret, "Failed to set data range\= n"); > > > > indio_dev->name =3D data->info->name; >