From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF2B4C43217 for ; Wed, 24 Nov 2021 15:21:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234684AbhKXPYb (ORCPT ); Wed, 24 Nov 2021 10:24:31 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]:4159 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229866AbhKXPY3 (ORCPT ); Wed, 24 Nov 2021 10:24:29 -0500 Received: from fraeml739-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Hzl7x66WJz67x9G; Wed, 24 Nov 2021 23:20:45 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml739-chm.china.huawei.com (10.206.15.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Wed, 24 Nov 2021 16:21:16 +0100 Received: from localhost (10.52.122.252) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Wed, 24 Nov 2021 15:21:14 +0000 Date: Wed, 24 Nov 2021 15:21:12 +0000 From: Jonathan Cameron To: Geert Uytterhoeven CC: Tony Lindgren , Russell King , Rajendra Nayak , Paul Walmsley , Michael Turquette , Stephen Boyd , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , Tero Kristo , "Jonathan Cameron" , Lars-Peter Clausen , "Lorenzo Bianconi" , Benoit Parrot , Mauro Carvalho Chehab , Adrian Hunter , Andrew Jeffery , Ulf Hansson , Joel Stanley , Ping-Ke Shih , Kalle Valo , "David S . Miller" , Jakub Kicinski , Linus Walleij , Liam Girdwood , Mark Brown , Magnus Damm , Eduardo Valentin , Keerthy , "Rafael J . Wysocki" , Daniel Lezcano , "Amit Kucheria" , Zhang Rui , Jaroslav Kysela , Takashi Iwai , , , , , , , , , , , , , , , Subject: Re: [PATCH/RFC 08/17] iio: humidity: hts221: Use bitfield helpers Message-ID: <20211124152112.000078bf@Huawei.com> In-Reply-To: References: Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.29; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.52.122.252] X-ClientProxiedBy: lhreml733-chm.china.huawei.com (10.201.108.84) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 22 Nov 2021 16:54:01 +0100 Geert Uytterhoeven wrote: > Use the field_prep() helper, instead of open-coding the same operation. > > Signed-off-by: Geert Uytterhoeven Hi Geert, If this should got forwards, looks like a nice cleanup for the two IIO ones, so I'll be happy to pick them up once infrastructure in place (ideally have the infrastructure an immutable branch to save having to revisit in 3+ months time!) Jonathan > --- > Compile-tested only. > Marked RFC, as this depends on [PATCH 01/17], but follows a different > path to upstream. > --- > drivers/iio/humidity/hts221_core.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c > index 6a39615b696114cd..749aedc469ede5c1 100644 > --- a/drivers/iio/humidity/hts221_core.c > +++ b/drivers/iio/humidity/hts221_core.c > @@ -7,6 +7,7 @@ > * Lorenzo Bianconi > */ > > +#include > #include > #include > #include > @@ -171,7 +172,7 @@ static int hts221_update_avg(struct hts221_hw *hw, > u16 val) > { > const struct hts221_avg *avg = &hts221_avg_list[type]; > - int i, err, data; > + int i, err; > > for (i = 0; i < HTS221_AVG_DEPTH; i++) > if (avg->avg_avl[i] == val) > @@ -180,9 +181,8 @@ static int hts221_update_avg(struct hts221_hw *hw, > if (i == HTS221_AVG_DEPTH) > return -EINVAL; > > - data = ((i << __ffs(avg->mask)) & avg->mask); > - err = regmap_update_bits(hw->regmap, avg->addr, > - avg->mask, data); > + err = regmap_update_bits(hw->regmap, avg->addr, avg->mask, > + field_prep(avg->mask, i)); > if (err < 0) > return err; >