Received: by 2002:ab2:f03:0:b0:1ef:ffd0:ce49 with SMTP id i3csp48672lqf; Tue, 26 Mar 2024 14:00:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWD15oihK3NEmpScgES0frg5v8Z2oWBOIfcuZyMKQ0MwP+LXP9gFdmSWYC4Y934VlhsibBtcSfhWhZ8cbkStPJwJ7r9BVpUSlor8wFBFA== X-Google-Smtp-Source: AGHT+IHjhn4+L08mRgpHHykWYZ2cXKlgni6+4BSpxJzaMlM9lAfiY7Nvy6hzphSjsoQhCnXmhlUC X-Received: by 2002:a2e:2e1a:0:b0:2d2:3fac:5fc7 with SMTP id u26-20020a2e2e1a000000b002d23fac5fc7mr488799lju.45.1711486848660; Tue, 26 Mar 2024 14:00:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711486848; cv=pass; d=google.com; s=arc-20160816; b=oMAduW2oC7UYOnmNshAX92kP7jw1D0k8d927JbZB5dNpakvC+VQJU8OEjSlt2dygVG ngP6zdZH0vZV4JAlz8twpXEmGhlRB0t+gvVtGJUcqpe5RaJG1e6azzU0K4rr2qB+Ohvf w5AmK8pEIVDVajAJmcXuGks7wl2cTtsZ1E2OW5v1W20KPfwQi+mPAFqamnRCg55qcJ8B 7PkPAZLZwF5kZK88awjOvAJfKU0kJpobm4V/QMlhOWouwSLr9b0xazhuCIf5iOAm1hwY LbBVBqeU2rJi5+/0k+/Jvok1E7uM+Jm1tGmDmGxSLVRxOrcDzHKpr08oNveUdTnzXDHc ifDA== 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=FGCp3Hdv4uExC/POBDKFeOwya+tu2FDjTleJp+1lj24=; fh=vDWOdrm187NG/AOD0DeTwU8SRd9qpg/jVW7mKKZzeJI=; b=QP48toVwiz2UF3l0DJIcNXsW8Ad5ba0peLYSpnxgvnlcEZlhwRCW4r6KYiarr+her9 X2oGD/zMpS9DoBlg5tTNzhzxTKd3qhbCYdk9v2JsKMngVvBBhR/1T8ibKo+VEyR5QEN3 HqcoegJn8sRhQiP9IQyOiJglM+4vRAAwhu0uYcRCx5qXdOouLS4eVPKWSU2OhVZn9TGC /8rtRAKj2Ub1NczpQdQZlTTjcYZKIEvOWD+bDx+LuCZD0C4Zn0+/mhip/acSCW1PLMD5 M6shTUWOwuPQFE+/in++gR4mc+ssXwewjJmt2U9mSzaCPvk2HN/zLozKmng1HbNlceOa L3Yg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bJ4ybbDM; 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-119968-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119968-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id i20-20020aa7c9d4000000b005683880130fsi4001586edt.530.2024.03.26.14.00.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 14:00:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119968-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bJ4ybbDM; 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-119968-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119968-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 393BB1F676DE for ; Tue, 26 Mar 2024 21:00:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5DC3313D60B; Tue, 26 Mar 2024 21:00:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bJ4ybbDM" Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) (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 DD60D12B157; Tue, 26 Mar 2024 21:00:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711486814; cv=none; b=ZETfweHHrpBaDZqNL2k9qaL1KIDjjWLMjTk16bkZmRfwctjI6VVPWCK8sIYiWMxUVN/VJXcEKGER2L2BxePf2XPiT4Os3Vo+csr22z6vDQeYTpqKy6YQaVWILgY4SlxS+uG0vm9tavSKrrMGZKDZap2l9GKEZcGSORnFBaeHFr0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711486814; c=relaxed/simple; bh=BMDy0xEWSqRLIBS7dqDM7r65pTCpIKpqHbzXnYc8qSg=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=FtV1nu8x5u4hEJLotwJnaNrnXHHX3BfcImGci7gg8c8lwSg6ETPWYGpkYO+IHDdWafGTcflQWBsHnnXn1ueZfuLd1kS83nMHulVQEJU5Z2eoGMN/DPDmm/x3SxmrG8iIOpcnqzlqJgH8/Zx6pmo4DTRaBqxuQQMCbgoC58GYMds= 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=bJ4ybbDM; arc=none smtp.client-ip=209.85.219.172 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-yb1-f172.google.com with SMTP id 3f1490d57ef6-dcc73148611so6699741276.3; Tue, 26 Mar 2024 14:00:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711486812; x=1712091612; 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=FGCp3Hdv4uExC/POBDKFeOwya+tu2FDjTleJp+1lj24=; b=bJ4ybbDMbnyN0AY01ONxvhRhwHZETgbrYY7ZqPMGCGMlHLOsGnkvKB9Wpk8itcGZ00 nSV2xLbOXgR1h3+nJOYAAMtt85gq1gmD19hAH2JYtWXExbkN/gLSacD9uLPrYJ4QcEet kKPVpHBStk3xGxDmaWchmGxbknJ+agLajtkmeqQzndEnclVFGulNcJAKYbX7xekZWMHh Pa8P3qgt0QqbyVnqVDYubYQEqIFmbhSmv7LI3mA+UT5UqhP6rl4x7Ef+BZalI08cB4DI MtUKnq/adVAEvwwOidmDwKkjzChte7RrxcCqaSicObwNiTXxVfqL2gzbS0JOzQlDsPQy 2Cqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711486812; x=1712091612; 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=FGCp3Hdv4uExC/POBDKFeOwya+tu2FDjTleJp+1lj24=; b=kqqtcOQc2R0YJeHLK6X+e55TcbCWHvZwR1KpU0KIXV7dp2gnix4OVD8KDxRCkILxt+ n3HIdYHTfDzqQixyylnHq5Va9byU06uKZYo3mrGkedhjXNZ5V7PmFMwIcxaG8mMqYaTj igd6zQEaKLM/3UHxKx6c+obRSM/w9frPPr9HpyuRGyWuy7qmLN4LtcSylborhlMf9lsA +JIlLex4NqkQ2vaHkazbIwg1nV+AUHxsDVXdg+O5FHgcAtpkC+qcNHKbm3bVVAEW81jA HeBCXdx3ouvIp1+xi7zp6TlHNgI3Mywua2rqK0o5Ek+pkm3xIrOpMeSqvV6/fwksvNEs nthw== X-Forwarded-Encrypted: i=1; AJvYcCU8O4KBhm9QEe+7qMMqqR4Qev44LAXWw63sdtCXrzf8z5HFuGFLDiIQKmfwiCTgG3h/zZ8DWTvnYJCwxtNsN6EoXMhWcFtMBoaZdAcgNqofrn7q9VWU6A5+RDkxQsf8ciPuRu+/Zu0Hu8St8WCpkGWA5PA+Xlj3O5fV+f/8OE/HM5xQOw== X-Gm-Message-State: AOJu0YxGLrNT1EYwihqpP3qPqQnTtVXPct1hFOGGQAGbb8kyiXb0Pa+a qfCzRpPtckfWH9eZ0qqmWGhsKU0XEfuDkN53mRk7Mzps4W9SdHORjkCo9V2aMrC6J6UgoQwDN7w Ybs3mBJ0Ds4p1xTZxjQ/Wb0NtM8Q= X-Received: by 2002:a25:dccd:0:b0:dcc:8d09:c7c4 with SMTP id y196-20020a25dccd000000b00dcc8d09c7c4mr2182951ybe.7.1711486810191; Tue, 26 Mar 2024 14:00:10 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240325153356.46112-1-l.rubusch@gmail.com> <20240325153356.46112-2-l.rubusch@gmail.com> <20240325203155.23ddfe3d@jic23-huawei> In-Reply-To: <20240325203155.23ddfe3d@jic23-huawei> From: Lothar Rubusch Date: Tue, 26 Mar 2024 21:59:34 +0100 Message-ID: Subject: Re: [PATCH v4 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 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: > > > 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/adxl3= 45_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)) /* ignore = spi-3wire */ > > 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. > 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? > > > > #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, 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) > > + 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; >