Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp436403lqh; Thu, 28 Mar 2024 06:39:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUTxJecSDhWTTJkMFmEnlWDzBFfIj7DmB5hosnDceDESLwL/B/1WESnPATo3Y1qTUU+Jb0Nexa964BELICqcnhfxGbID9V2VkcnmbvatA== X-Google-Smtp-Source: AGHT+IEP1ihWVPIxvpQAQi18jQgP2ySrWyinD9yrbqLUp0/EuaqefNgmtiPlmK6M0bPTeXTu+si5 X-Received: by 2002:a05:6a20:2583:b0:1a5:6aad:2e9d with SMTP id k3-20020a056a20258300b001a56aad2e9dmr2835009pzd.6.1711633160845; Thu, 28 Mar 2024 06:39:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711633160; cv=pass; d=google.com; s=arc-20160816; b=bebEgznKegstXQd2X6ZQHgSbwOLZGEWy4gUo8P7WYqSvFz2W/TGsAQEUeuWjvYr961 7vF+mtYZgMpZFiWaYZ5sZkXVt/opOg2B8T/JRR1rNuv3XB1DMItxKZZdU2wNyt8H71dl ziqzKb0KTkAJTU/sUbjZQWgEdRJtvUFRsx5jhIPgy3aFT6Xjzs5jgiFLDhfcFzekanvp bYYxiQSpH9cqJOiHXCTZpqT3rPvenP45qu/XXt97ZjJ+e8EbrngJFzWSLElXmT5b30v2 ZcY6kLi/p7RHIaDmxKUVftbvx564AQf0MysWO7tTdFgsnqG2BGJvdEgIhD+3a7vwh/io IWyw== 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=D+mkPZtbzzMs/JlhD2SCTAxVLo9Afm1K5r51wcc0+WU=; fh=aO7VwMzXorvFb/cjS7UqKL2BI3mnI34qIdePd4Zg25U=; b=S5NcGU6r74qH4ERvEgeWVoHSL0COy87LH53o+zSmknI9zf2DETAHA3GviNRWqrEni+ K1TmTOvni2FEuRLxmPP7d+MYDGEgj8bAtNtwZPtW3E+KbVuHloJep04Vc1GymY8/LAC8 OVC++uFiEDpVWmw/APlcOIULprS5tq3rNtjnOJphw2Ej5szo2emvSygyuEaX/WG1AS9S ajsaHJCVY0pyfkb8iQdD3HRoLZ9qNc8IgYPNoQbSjqZyUKrWia/LTpILIBPX9Q+a9qO+ SszTcQbDYxpMtq07bKadA8pgS401R4UdA6A0USWWFP+uaLhEKYbFnR8MuBBukeuE7ZPC wU3A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lWYLnBY6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-122963-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122963-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. [147.75.48.161]) by mx.google.com with ESMTPS id f36-20020a631024000000b005eb4d2501c7si1451421pgl.693.2024.03.28.06.39.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 06:39:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122963-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lWYLnBY6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-122963-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122963-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 75957B233E4 for ; Thu, 28 Mar 2024 13:38:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6984481748; Thu, 28 Mar 2024 13:37:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lWYLnBY6" 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 8AC0F1DFF2; Thu, 28 Mar 2024 13:37:36 +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=1711633056; cv=none; b=CIKCKY+Za+yX2adBiIw4juNUjrAyHUoi5iDYV7jPmSroy4/tzSjAdH5Rn2825Cw0SIGhzJmXYo78T2PPpbp3PSExKyRtaZlfZUlgB+X3oZ3TR0f9ElKOksaPC3EYPyENsiOGDjNmgzQonwLwYj548wLAeCeeCxpgy+2VvB7MrJI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711633056; c=relaxed/simple; bh=2wMQZUMDKyXYoSYDs721zMsZSef9FBC/jEz9Dy7RV3o=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D8MzBXRuS5VgBGMcWSaHGEMZ8fAkpmZZzZtKAdrPtQDso8fKkcR0mfRVOYHGt6dngnKSyJ49MYhYkQWsHOJsLiwGF9EMViPCNaLiptffShn2cBbEE74m6gB152sZaW4BdtINs6ccs+UtljB+5jjAzF8XdbNJVA+ssQ8TfBMoKJg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lWYLnBY6; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8E83C433C7; Thu, 28 Mar 2024 13:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711633056; bh=2wMQZUMDKyXYoSYDs721zMsZSef9FBC/jEz9Dy7RV3o=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=lWYLnBY6ZFpm71DWI7mSZV/kRZWK6TGyKJhQku59LxVf9R42TCo8fSEwYsbB1g3xr pjD0m+rm6iTA9EoUQSfWp6pwBAmrtN+0otczQ8kF9fkMHcdxrlaTOh2eCFy6KGaV3f t6DPxwYZyIdBeXP43/eBbB2I+T+tVBKjgux8HW21c0oqLJmekQV4XqKzNzy4pJIbGP hNVtdhCEJiqKtEEMcnk33uHzMKXFDL7E/Lxf5GAwXpwnPX4zZ/r3bBXZ/HX8PaUPeV LRq0EAdpcYHxzl82+PkSbpXH3aH3p+g4+YXTt0+mFuJhVbiTUTUobZ7ocvYxw+eW9Z WZvEHhbZRGuXQ== Date: Thu, 28 Mar 2024 13:37:20 +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 v5 1/7] iio: accel: adxl345: Make data_range obsolete Message-ID: <20240328133720.7dfd46b0@jic23-huawei> In-Reply-To: <20240327220320.15509-2-l.rubusch@gmail.com> References: <20240327220320.15509-1-l.rubusch@gmail.com> <20240327220320.15509-2-l.rubusch@gmail.com> 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 Wed, 27 Mar 2024 22:03:14 +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. 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/adxl345_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) mode */ > #define ADXL345_DATA_FORMAT_FULL_RES BIT(3) /* Up to 13-bits resolution */ > +#define ADXL345_DATA_FORMAT_SELF_TEST BIT(7) /* Enable a self test */ > +#define ADXL345_DATA_FORMAT_MSK (ADXL345_DATA_FORMAT_RANGE | \ > + 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. 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 = iio_priv(indio_dev); > data->regmap = regmap; > - /* Enable full-resolution mode */ > - data->data_range = ADXL345_DATA_FORMAT_FULL_RES; > data->info = device_get_match_data(dev); > if (!data->info) > return -ENODEV; > > - ret = regmap_write(data->regmap, ADXL345_REG_DATA_FORMAT, > - data->data_range); > - if (ret < 0) > + /* Enable full-resolution mode */ > + ret = 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 range\n"); > > indio_dev->name = data->info->name;