Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp17802lqs; Thu, 13 Jun 2024 02:24:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUa51qyWqAwsVMWY2l7Cdvu2753fQk7tOFxu6zVKiPyf98owliccK6R87OH11h2UL/Xn8tfe8suv3Pa5gAN2/8puiu4uvqh8KDo2fcsjA== X-Google-Smtp-Source: AGHT+IHQ6D8uG5WwV/2Umv+k1v5mDGyxA+KRQgEPD9JE54G0Ou4t8lhpm52szWPDhPe4W1xIoVo0 X-Received: by 2002:a17:907:6d11:b0:a6e:372f:5783 with SMTP id a640c23a62f3a-a6f523f2c1cmr205584766b.4.1718270681855; Thu, 13 Jun 2024 02:24:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718270681; cv=pass; d=google.com; s=arc-20160816; b=uwzBM2U1W8utdTHHPbKZ9whFP7zv/DlIrNQ+DlrzxnFloLY9rtK+yH1Ikqkxk7dlIs asninkxVUSjk7qUgkxFANFVC2ezKG2AYd+L1f145rUbY6SjEMA/WwOe66CUc/6SakABa BlcHVMsmkeRimTy16rWFwIs8Zj/UdLUM1X2Wq0MGUHmFyTmuvaM4US3N62Jxsg3SOP+6 Ov4wQgVaWF7FaH5VRhjiQGNRUtmMxhDqjjN0DrrU3NLAhA1SymCAtWMsZYBxjI8wk/HF s1wgOQPkhTgS00SNwN0z55xVv84GwKuOKg8xKMp4d27ABxPCqNBfBHRaYreA0L4oj9uW EenQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=KbWX8Db8CbQXtBeXWc2CukpLYCDdNStf9N0SgO0PdS0=; fh=m65B/tvPIYjKYSL7GvDzdz5K5SYXyQNYI0uD8Cf0RNc=; b=OwMMUIfYWIQeGrE8SC5+j24gbtqWItiWGmUTsXmtXRlcLAJYv7f3eUrW50ngj/Bi9C +8wqVOw2ZlwFgjZxsQJ+iVfYorohTwFpt/zCXh1g93Lyn0dvCw/b2MF/1ik7pGI5ahD/ LsHraVDa1XQvmCNFvU62WjcFgejJChTT0t3sVXgEZuh42oXoB7sqe4QD/c3ededgLdRg 4lhEQuV7q5Rrob14SUJtxQd3bo1WpCw+PlJpp5q/CCIGJyAr5BEhjx+20GQUk8diDX8c M3mBEExEmiFwu3NHgzgus+JCMW6aTAYoemTBDwR2WxgZ/D1pERxz5FY1kkbCYMd8pLjr an9A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=KFeBY6C6; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-212943-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212943-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f576f5d4asi50617066b.110.2024.06.13.02.24.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 02:24:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212943-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=@linux.alibaba.com header.s=default header.b=KFeBY6C6; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-212943-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212943-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.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 672A01F2231E for ; Thu, 13 Jun 2024 09:24:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 80E1913E3EF; Thu, 13 Jun 2024 09:24:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="KFeBY6C6" Received: from out30-101.freemail.mail.aliyun.com (out30-101.freemail.mail.aliyun.com [115.124.30.101]) (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 F3FC313D891; Thu, 13 Jun 2024 09:24:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.101 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718270671; cv=none; b=oDd3A9qeHbbmbRFGeeuiJ5kfmYku8Gux/B+wrG8lSg7zTckZm2jD/64M8pGtsFe2KdDtLkgh7yVjXTR1SETVRUEhVaQZXXpoipAy946gwe5Huxlo7SmsK2y4fnB7WoPlSlTDm2OaZ8/SdyJHfj0/fTB+ekCIutq9Q4paY6MWrio= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718270671; c=relaxed/simple; bh=+vQn3HjO/YchQui9IJ3APLcbMNH88nHBloO+VGQCjaA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=e6b41LVsJ6n4kYV5WorSeTWYhj/0QkdFum0K2tGuy1YDxNB+IIvVtn6zsc79a6IdgxhG6+PrsNUUsKOxw/tuHTqO9M7OakY61F16NcEEPJsbdZag0re+rMGFK6ZkMycIHFmbWKSw/ZX8MnuKLVB6y0CO2+LdMb2DQg35eGx+Dwk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=KFeBY6C6; arc=none smtp.client-ip=115.124.30.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1718270660; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=KbWX8Db8CbQXtBeXWc2CukpLYCDdNStf9N0SgO0PdS0=; b=KFeBY6C66rgRfcshfoD1qIC0xD18OCFhWQMpAMiLpD1rtbeBeOnn8L+4w6pXxEWYJM0AM2ut9kz55DJ9IqjXCa4mODPmGblXCIx1IJZcxME3/tlr9FcuwTBjZs3ceA0gVsAgKCC+4nmyxr3L4Obvyw2nuKRyzay6ZCnIDTwzd5I= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R541e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033032014031;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=37;SR=0;TI=SMTPD_---0W8NgDjm_1718270656; Received: from 30.97.56.57(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W8NgDjm_1718270656) by smtp.aliyun-inc.com; Thu, 13 Jun 2024 17:24:18 +0800 Message-ID: <3b7950db-bde8-407e-b568-51cacee93ad8@linux.alibaba.com> Date: Thu, 13 Jun 2024 17:24:14 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RESEND][PATCH] iio: simplify with regmap_set_bits(), regmap_clear_bits() To: Trevor Gamblin , Lucas Stankus , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Dmitry Rokosov , Cosmin Tanislav , Chen-Yu Tsai , Hans de Goede , Ray Jui , Scott Branden , Broadcom internal kernel review list , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Saravanan Sekar , Orson Zhai , Chunyan Zhang , Maxime Coquelin , Alexandre Torgue , =?UTF-8?Q?Nuno_S=C3=A1?= , Linus Walleij , Jean-Baptiste Maneyrol , Crt Mori Cc: =?UTF-8?Q?Uwe_Kleine-K=C3=B6nig?= , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, linux-amlogic@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com References: <20240611165214.4091591-1-tgamblin@baylibre.com> From: Baolin Wang In-Reply-To: <20240611165214.4091591-1-tgamblin@baylibre.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024/6/12 00:52, Trevor Gamblin wrote: > Simplify the way regmap is accessed in iio drivers. > > Instead of using regmap_update_bits() and passing the mask twice, use > regmap_set_bits(). > > Instead of using regmap_update_bits() and passing val = 0, use > regmap_clear_bits(). > > Suggested-by: Uwe Kleine-König > Signed-off-by: Trevor Gamblin > --- [...] > diff --git a/drivers/iio/adc/sc27xx_adc.c b/drivers/iio/adc/sc27xx_adc.c > index b4a2e057d80f..2535c2c3e60b 100644 > --- a/drivers/iio/adc/sc27xx_adc.c > +++ b/drivers/iio/adc/sc27xx_adc.c > @@ -508,13 +508,13 @@ static int sc27xx_adc_read(struct sc27xx_adc_data *data, int channel, > } > } > > - ret = regmap_update_bits(data->regmap, data->base + SC27XX_ADC_CTL, > - SC27XX_ADC_EN, SC27XX_ADC_EN); > + ret = regmap_set_bits(data->regmap, data->base + SC27XX_ADC_CTL, > + SC27XX_ADC_EN); > if (ret) > goto regulator_restore; > > - ret = regmap_update_bits(data->regmap, data->base + SC27XX_ADC_INT_CLR, > - SC27XX_ADC_IRQ_CLR, SC27XX_ADC_IRQ_CLR); > + ret = regmap_set_bits(data->regmap, data->base + SC27XX_ADC_INT_CLR, > + SC27XX_ADC_IRQ_CLR); > if (ret) > goto disable_adc; > > @@ -537,8 +537,8 @@ static int sc27xx_adc_read(struct sc27xx_adc_data *data, int channel, > if (ret) > goto disable_adc; > > - ret = regmap_update_bits(data->regmap, data->base + SC27XX_ADC_CTL, > - SC27XX_ADC_CHN_RUN, SC27XX_ADC_CHN_RUN); > + ret = regmap_set_bits(data->regmap, data->base + SC27XX_ADC_CTL, > + SC27XX_ADC_CHN_RUN); > if (ret) > goto disable_adc; > > @@ -559,8 +559,8 @@ static int sc27xx_adc_read(struct sc27xx_adc_data *data, int channel, > value &= SC27XX_ADC_DATA_MASK; > > disable_adc: > - regmap_update_bits(data->regmap, data->base + SC27XX_ADC_CTL, > - SC27XX_ADC_EN, 0); > + regmap_clear_bits(data->regmap, data->base + SC27XX_ADC_CTL, > + SC27XX_ADC_EN); > regulator_restore: > if ((data->var_data->set_volref) && (channel == 30 || channel == 31)) { > ret_volref = regulator_set_voltage(data->volref, > @@ -765,15 +765,14 @@ static int sc27xx_adc_enable(struct sc27xx_adc_data *data) > { > int ret; > > - ret = regmap_update_bits(data->regmap, data->var_data->module_en, > - SC27XX_MODULE_ADC_EN, SC27XX_MODULE_ADC_EN); > + ret = regmap_set_bits(data->regmap, data->var_data->module_en, > + SC27XX_MODULE_ADC_EN); > if (ret) > return ret; > > /* Enable ADC work clock and controller clock */ > - ret = regmap_update_bits(data->regmap, data->var_data->clk_en, > - SC27XX_CLK_ADC_EN | SC27XX_CLK_ADC_CLK_EN, > - SC27XX_CLK_ADC_EN | SC27XX_CLK_ADC_CLK_EN); > + ret = regmap_set_bits(data->regmap, data->var_data->clk_en, > + SC27XX_CLK_ADC_EN | SC27XX_CLK_ADC_CLK_EN); > if (ret) > goto disable_adc; > > @@ -789,11 +788,11 @@ static int sc27xx_adc_enable(struct sc27xx_adc_data *data) > return 0; > > disable_clk: > - regmap_update_bits(data->regmap, data->var_data->clk_en, > - SC27XX_CLK_ADC_EN | SC27XX_CLK_ADC_CLK_EN, 0); > + regmap_clear_bits(data->regmap, data->var_data->clk_en, > + SC27XX_CLK_ADC_EN | SC27XX_CLK_ADC_CLK_EN); > disable_adc: > - regmap_update_bits(data->regmap, data->var_data->module_en, > - SC27XX_MODULE_ADC_EN, 0); > + regmap_clear_bits(data->regmap, data->var_data->module_en, > + SC27XX_MODULE_ADC_EN); > > return ret; > } > @@ -803,11 +802,11 @@ static void sc27xx_adc_disable(void *_data) > struct sc27xx_adc_data *data = _data; > > /* Disable ADC work clock and controller clock */ > - regmap_update_bits(data->regmap, data->var_data->clk_en, > - SC27XX_CLK_ADC_EN | SC27XX_CLK_ADC_CLK_EN, 0); > + regmap_clear_bits(data->regmap, data->var_data->clk_en, > + SC27XX_CLK_ADC_EN | SC27XX_CLK_ADC_CLK_EN); > > - regmap_update_bits(data->regmap, data->var_data->module_en, > - SC27XX_MODULE_ADC_EN, 0); > + regmap_clear_bits(data->regmap, data->var_data->module_en, > + SC27XX_MODULE_ADC_EN); > } > > static const struct sc27xx_adc_variant_data sc2731_data = { For SPRD sc27xx parts, looks good to me. Thanks. Reviewed-by: Baolin Wang