From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (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 5D70F1494D1 for ; Thu, 13 Jun 2024 17:20:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718299232; cv=none; b=XfU//VCFQWI4txXJ7GEO3fgMEHzBy427zSf+WCmujxlLUzWgzRv7nVVbdwlyFROvrAbo0b2TVgDVofROEG0xDnlt6YCYamZnD3AMr5wvp90opGoctOGGxP3QeFlBIS8NrCoqreWTWLqVEAqZ9Txwg/FuCra1/LcYDrNHulcJ/P8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718299232; c=relaxed/simple; bh=bcTlQCZmkD/Xi9pbAhyUanFMXK8HrG7tkMYcoDGGb+g=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rbkqfY1FTiwNUN0V9IMTKqGDT8nxarzkKcE6wDUZdzUySgn5H+HKdHcdBfOx/XmCYpbHhRx4/tHgJQNZkcTQRqOtMoRV+PcE1N4VyIM4A1u3CAm1HqADqwlJCUH1nDNRHQnMFHeIIJZ8dCONHaPAasiRxWz1cUDYgQqz9yfFRgk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4W0TfD3Fs8z6K91P; Fri, 14 Jun 2024 01:19:00 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 8267F1400CB; Fri, 14 Jun 2024 01:20:23 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 13 Jun 2024 18:20:22 +0100 Date: Thu, 13 Jun 2024 18:20:21 +0100 From: Jonathan Cameron To: Trevor Gamblin CC: 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 , Baolin Wang , Chunyan Zhang , Maxime Coquelin , Alexandre Torgue , Nuno =?ISO-8859-1?Q?S=E1?= , Linus Walleij , Jean-Baptiste Maneyrol , Crt Mori , Uwe =?ISO-8859-1?Q?Kleine-K=F6nig?= , , , , , , , Subject: Re: [RESEND][PATCH] iio: simplify with regmap_set_bits(), regmap_clear_bits() Message-ID: <20240613182021.00005072@Huawei.com> In-Reply-To: <20240611165214.4091591-1-tgamblin@baylibre.com> References: <20240611165214.4091591-1-tgamblin@baylibre.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: lhrpeml500004.china.huawei.com (7.191.163.9) To lhrpeml500005.china.huawei.com (7.191.163.240) On Tue, 11 Jun 2024 12:52:06 -0400 Trevor Gamblin wrote: > Simplify the way regmap is accessed in iio drivers. >=20 > Instead of using regmap_update_bits() and passing the mask twice, use > regmap_set_bits(). >=20 > Instead of using regmap_update_bits() and passing val =3D 0, use > regmap_clear_bits(). >=20 > Suggested-by: Uwe Kleine-K=F6nig > Signed-off-by: Trevor Gamblin Looks like a good change in general. However... The problem with a change like this is it results in non trivial backporting if we need to due to a fix in related code. As such, whilst it will obviously generate a lot of patches, I'd like this split up into a series so each patch touches only one driver. Fine to keep a single patch for the multiple module for a single device cases though. Also some very long lines that need the line breaks put back. Jonathan > diff --git a/drivers/iio/accel/msa311.c b/drivers/iio/accel/msa311.c > index b8ddbfd98f11..40e605c57adb 100644 > --- a/drivers/iio/accel/msa311.c > +++ b/drivers/iio/accel/msa311.c > @@ -1034,10 +1034,8 @@ static int msa311_chip_init(struct msa311_priv *ms= a311) > "failed to unmap map0/map1 interrupts\n"); > =20 > /* Disable all axes by default */ > - err =3D regmap_update_bits(msa311->regs, MSA311_ODR_REG, > - MSA311_GENMASK(F_X_AXIS_DIS) | > - MSA311_GENMASK(F_Y_AXIS_DIS) | > - MSA311_GENMASK(F_Z_AXIS_DIS), 0); > + err =3D regmap_clear_bits(msa311->regs, MSA311_ODR_REG, > + MSA311_GENMASK(F_X_AXIS_DIS) | MSA311_GENMASK(F_Y_AXIS_DIS) | MSA311= _GENMASK(F_Z_AXIS_DIS)); Too long > diff --git a/drivers/iio/adc/cpcap-adc.c b/drivers/iio/adc/cpcap-adc.c > index b6c4ef70484e..8fabf748c36b 100644 > --- a/drivers/iio/adc/cpcap-adc.c > +++ b/drivers/iio/adc/cpcap-adc.c > @@ -385,9 +385,8 @@ static irqreturn_t cpcap_adc_irq_thread(int irq, void= *data) > @@ -424,23 +423,17 @@ static void cpcap_adc_setup_calibrate(struct cpcap_= adc *ddata, > if (error) > return; > =20 > - error =3D regmap_update_bits(ddata->reg, CPCAP_REG_ADCC2, > - CPCAP_BIT_ATOX_PS_FACTOR | > - CPCAP_BIT_ADC_PS_FACTOR1 | > - CPCAP_BIT_ADC_PS_FACTOR0, > - 0); > + error =3D regmap_clear_bits(ddata->reg, CPCAP_REG_ADCC2, > + CPCAP_BIT_ATOX_PS_FACTOR | CPCAP_BIT_ADC_PS_FACTOR1 | CPCAP_BIT_AD= C_PS_FACTOR0); That one is over 100! =20 > if (error) > diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-c= ore.c > index a791ba3a693a..ff1c81553045 100644 > --- a/drivers/iio/gyro/mpu3050-core.c > +++ b/drivers/iio/gyro/mpu3050-core.c > =20 > @@ -513,12 +513,8 @@ static irqreturn_t mpu3050_trigger_handler(int irq, = void *p) > "FIFO overflow! Emptying and resetting FIFO\n"); > fifo_overflow =3D true; > /* Reset and enable the FIFO */ > - ret =3D regmap_update_bits(mpu3050->map, > - MPU3050_USR_CTRL, > - MPU3050_USR_CTRL_FIFO_EN | > - MPU3050_USR_CTRL_FIFO_RST, > - MPU3050_USR_CTRL_FIFO_EN | > - MPU3050_USR_CTRL_FIFO_RST); > + ret =3D regmap_set_bits(mpu3050->map, MPU3050_USR_CTRL, > + MPU3050_USR_CTRL_FIFO_EN | MPU3050_USR_CTRL_FIFO_RST); Keep the line break to stay under 80 chars. > @@ -997,11 +991,8 @@ static int mpu3050_drdy_trigger_set_state(struct iio= _trigger *trig, > return ret; > =20 > /* Reset and enable the FIFO */ > - ret =3D regmap_update_bits(mpu3050->map, MPU3050_USR_CTRL, > - MPU3050_USR_CTRL_FIFO_EN | > - MPU3050_USR_CTRL_FIFO_RST, > - MPU3050_USR_CTRL_FIFO_EN | > - MPU3050_USR_CTRL_FIFO_RST); > + ret =3D regmap_set_bits(mpu3050->map, MPU3050_USR_CTRL, > + MPU3050_USR_CTRL_FIFO_EN | MPU3050_USR_CTRL_FIFO_RST); For IIO stuff try and stay under 80 chars unless there is a strong readability argument for going longer. Here there isn't one. > if (ret) > return ret; > =20 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A1311C27C4F for ; Thu, 13 Jun 2024 17:20:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:CC:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=R3N2wMwvomuo5XppgtoHc0M7RPQWd48EpXcki/gUIO8=; b=iWTa6+ip+7GpyT 6l7UmExdxgDEDD7nkiO8RC0by7nBRKB+O9RNbrg+sSWeGt2avMhWJqfTm2XU2cbd9TmSacPaM7pK8 HKWpUo15vxV37pARfaDgmczkbdpQor8VgieGTR2ueWq22l6leD1GavmKM8sHkh8lcHJDzrTBgU6bU iXEMYEgZavmy1FqPaJ+D6Pq6+SuyvcqSi9AkG4x8rODcajVK7DvqsPsLdl/naY7BDD3l4tO5vpfb5 HTEiOGiP34iSwXcCrE/nN6sAwKSiUxI+gyOaH12gXxHP8VHHXMK1HVYDLKt+EIA63OLt645EiGeVb iePymVzcsXDXBUTnu+5w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHo7n-0000000HVLI-0vhN; Thu, 13 Jun 2024 17:20:35 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHo7j-0000000HVIu-1D2J; Thu, 13 Jun 2024 17:20:33 +0000 Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4W0TfD3Fs8z6K91P; Fri, 14 Jun 2024 01:19:00 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 8267F1400CB; Fri, 14 Jun 2024 01:20:23 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 13 Jun 2024 18:20:22 +0100 Date: Thu, 13 Jun 2024 18:20:21 +0100 From: Jonathan Cameron To: Trevor Gamblin CC: 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 , Baolin Wang , Chunyan Zhang , Maxime Coquelin , Alexandre Torgue , Nuno =?ISO-8859-1?Q?S=E1?= , Linus Walleij , Jean-Baptiste Maneyrol , Crt Mori , Uwe =?ISO-8859-1?Q?Kleine-K=F6nig?= , , , , , , , Subject: Re: [RESEND][PATCH] iio: simplify with regmap_set_bits(), regmap_clear_bits() Message-ID: <20240613182021.00005072@Huawei.com> In-Reply-To: <20240611165214.4091591-1-tgamblin@baylibre.com> References: <20240611165214.4091591-1-tgamblin@baylibre.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml500004.china.huawei.com (7.191.163.9) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240613_102031_651501_29E43475 X-CRM114-Status: GOOD ( 15.65 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org On Tue, 11 Jun 2024 12:52:06 -0400 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 =3D 0, use > regmap_clear_bits(). > = > Suggested-by: Uwe Kleine-K=F6nig > Signed-off-by: Trevor Gamblin Looks like a good change in general. However... The problem with a change like this is it results in non trivial backporting if we need to due to a fix in related code. As such, whilst it will obviously generate a lot of patches, I'd like this split up into a series so each patch touches only one driver. Fine to keep a single patch for the multiple module for a single device cases though. Also some very long lines that need the line breaks put back. Jonathan > diff --git a/drivers/iio/accel/msa311.c b/drivers/iio/accel/msa311.c > index b8ddbfd98f11..40e605c57adb 100644 > --- a/drivers/iio/accel/msa311.c > +++ b/drivers/iio/accel/msa311.c > @@ -1034,10 +1034,8 @@ static int msa311_chip_init(struct msa311_priv *ms= a311) > "failed to unmap map0/map1 interrupts\n"); > = > /* Disable all axes by default */ > - err =3D regmap_update_bits(msa311->regs, MSA311_ODR_REG, > - MSA311_GENMASK(F_X_AXIS_DIS) | > - MSA311_GENMASK(F_Y_AXIS_DIS) | > - MSA311_GENMASK(F_Z_AXIS_DIS), 0); > + err =3D regmap_clear_bits(msa311->regs, MSA311_ODR_REG, > + MSA311_GENMASK(F_X_AXIS_DIS) | MSA311_GENMASK(F_Y_AXIS_DIS) | MSA311= _GENMASK(F_Z_AXIS_DIS)); Too long > diff --git a/drivers/iio/adc/cpcap-adc.c b/drivers/iio/adc/cpcap-adc.c > index b6c4ef70484e..8fabf748c36b 100644 > --- a/drivers/iio/adc/cpcap-adc.c > +++ b/drivers/iio/adc/cpcap-adc.c > @@ -385,9 +385,8 @@ static irqreturn_t cpcap_adc_irq_thread(int irq, void= *data) > @@ -424,23 +423,17 @@ static void cpcap_adc_setup_calibrate(struct cpcap_= adc *ddata, > if (error) > return; > = > - error =3D regmap_update_bits(ddata->reg, CPCAP_REG_ADCC2, > - CPCAP_BIT_ATOX_PS_FACTOR | > - CPCAP_BIT_ADC_PS_FACTOR1 | > - CPCAP_BIT_ADC_PS_FACTOR0, > - 0); > + error =3D regmap_clear_bits(ddata->reg, CPCAP_REG_ADCC2, > + CPCAP_BIT_ATOX_PS_FACTOR | CPCAP_BIT_ADC_PS_FACTOR1 | CPCAP_BIT_AD= C_PS_FACTOR0); That one is over 100! = > if (error) > diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-c= ore.c > index a791ba3a693a..ff1c81553045 100644 > --- a/drivers/iio/gyro/mpu3050-core.c > +++ b/drivers/iio/gyro/mpu3050-core.c > = > @@ -513,12 +513,8 @@ static irqreturn_t mpu3050_trigger_handler(int irq, = void *p) > "FIFO overflow! Emptying and resetting FIFO\n"); > fifo_overflow =3D true; > /* Reset and enable the FIFO */ > - ret =3D regmap_update_bits(mpu3050->map, > - MPU3050_USR_CTRL, > - MPU3050_USR_CTRL_FIFO_EN | > - MPU3050_USR_CTRL_FIFO_RST, > - MPU3050_USR_CTRL_FIFO_EN | > - MPU3050_USR_CTRL_FIFO_RST); > + ret =3D regmap_set_bits(mpu3050->map, MPU3050_USR_CTRL, > + MPU3050_USR_CTRL_FIFO_EN | MPU3050_USR_CTRL_FIFO_RST); Keep the line break to stay under 80 chars. > @@ -997,11 +991,8 @@ static int mpu3050_drdy_trigger_set_state(struct iio= _trigger *trig, > return ret; > = > /* Reset and enable the FIFO */ > - ret =3D regmap_update_bits(mpu3050->map, MPU3050_USR_CTRL, > - MPU3050_USR_CTRL_FIFO_EN | > - MPU3050_USR_CTRL_FIFO_RST, > - MPU3050_USR_CTRL_FIFO_EN | > - MPU3050_USR_CTRL_FIFO_RST); > + ret =3D regmap_set_bits(mpu3050->map, MPU3050_USR_CTRL, > + MPU3050_USR_CTRL_FIFO_EN | MPU3050_USR_CTRL_FIFO_RST); For IIO stuff try and stay under 80 chars unless there is a strong readability argument for going longer. Here there isn't one. > if (ret) > return ret; > = _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic