All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Trevor Gamblin <tgamblin@baylibre.com>
Cc: "Lucas Stankus" <lucas.p.stankus@gmail.com>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"Dmitry Rokosov" <ddrokosov@sberdevices.ru>,
	"Cosmin Tanislav" <cosmin.tanislav@analog.com>,
	"Chen-Yu Tsai" <wens@csie.org>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Ray Jui" <rjui@broadcom.com>,
	"Scott Branden" <sbranden@broadcom.com>,
	"Broadcom internal kernel review list"
	<bcm-kernel-feedback-list@broadcom.com>,
	"Shawn Guo" <shawnguo@kernel.org>,
	"Sascha Hauer" <s.hauer@pengutronix.de>,
	"Pengutronix Kernel Team" <kernel@pengutronix.de>,
	"Fabio Estevam" <festevam@gmail.com>,
	"Neil Armstrong" <neil.armstrong@linaro.org>,
	"Kevin Hilman" <khilman@baylibre.com>,
	"Jerome Brunet" <jbrunet@baylibre.com>,
	"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>,
	"Saravanan Sekar" <sravanhome@gmail.com>,
	"Orson Zhai" <orsonzhai@gmail.com>,
	"Baolin Wang" <baolin.wang@linux.alibaba.com>,
	"Chunyan Zhang" <zhang.lyra@gmail.com>,
	"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
	"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Jean-Baptiste Maneyrol" <jmaneyrol@invensense.com>,
	"Crt Mori" <cmo@melexis.com>,
	"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	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
Subject: Re: [RESEND][PATCH] iio: simplify with regmap_set_bits(), regmap_clear_bits()
Date: Thu, 13 Jun 2024 18:20:21 +0100	[thread overview]
Message-ID: <20240613182021.00005072@Huawei.com> (raw)
In-Reply-To: <20240611165214.4091591-1-tgamblin@baylibre.com>

On Tue, 11 Jun 2024 12:52:06 -0400
Trevor Gamblin <tgamblin@baylibre.com> 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 <u.kleine-koenig@baylibre.com>
> Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
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 *msa311)
>  				     "failed to unmap map0/map1 interrupts\n");
>  
>  	/* Disable all axes by default */
> -	err = 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 = 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 = 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 = regmap_clear_bits(ddata->reg, CPCAP_REG_ADCC2,
> +				  CPCAP_BIT_ATOX_PS_FACTOR | CPCAP_BIT_ADC_PS_FACTOR1 | CPCAP_BIT_ADC_PS_FACTOR0);
That one is over 100!  
>  	if (error)

> diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.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 = true;
>  			/* Reset and enable the FIFO */
> -			ret = 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 = 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 = 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 = 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;
>  

WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Trevor Gamblin <tgamblin@baylibre.com>
Cc: "Lucas Stankus" <lucas.p.stankus@gmail.com>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"Dmitry Rokosov" <ddrokosov@sberdevices.ru>,
	"Cosmin Tanislav" <cosmin.tanislav@analog.com>,
	"Chen-Yu Tsai" <wens@csie.org>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Ray Jui" <rjui@broadcom.com>,
	"Scott Branden" <sbranden@broadcom.com>,
	"Broadcom internal kernel review list"
	<bcm-kernel-feedback-list@broadcom.com>,
	"Shawn Guo" <shawnguo@kernel.org>,
	"Sascha Hauer" <s.hauer@pengutronix.de>,
	"Pengutronix Kernel Team" <kernel@pengutronix.de>,
	"Fabio Estevam" <festevam@gmail.com>,
	"Neil Armstrong" <neil.armstrong@linaro.org>,
	"Kevin Hilman" <khilman@baylibre.com>,
	"Jerome Brunet" <jbrunet@baylibre.com>,
	"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>,
	"Saravanan Sekar" <sravanhome@gmail.com>,
	"Orson Zhai" <orsonzhai@gmail.com>,
	"Baolin Wang" <baolin.wang@linux.alibaba.com>,
	"Chunyan Zhang" <zhang.lyra@gmail.com>,
	"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
	"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Jean-Baptiste Maneyrol" <jmaneyrol@invensense.com>,
	"Crt Mori" <cmo@melexis.com>,
	"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	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
Subject: Re: [RESEND][PATCH] iio: simplify with regmap_set_bits(), regmap_clear_bits()
Date: Thu, 13 Jun 2024 18:20:21 +0100	[thread overview]
Message-ID: <20240613182021.00005072@Huawei.com> (raw)
In-Reply-To: <20240611165214.4091591-1-tgamblin@baylibre.com>

On Tue, 11 Jun 2024 12:52:06 -0400
Trevor Gamblin <tgamblin@baylibre.com> 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 <u.kleine-koenig@baylibre.com>
> Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
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 *msa311)
>  				     "failed to unmap map0/map1 interrupts\n");
>  
>  	/* Disable all axes by default */
> -	err = 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 = 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 = 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 = regmap_clear_bits(ddata->reg, CPCAP_REG_ADCC2,
> +				  CPCAP_BIT_ATOX_PS_FACTOR | CPCAP_BIT_ADC_PS_FACTOR1 | CPCAP_BIT_ADC_PS_FACTOR0);
That one is over 100!  
>  	if (error)

> diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.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 = true;
>  			/* Reset and enable the FIFO */
> -			ret = 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 = 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 = 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 = 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

  parent reply	other threads:[~2024-06-13 17:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-11 16:52 [RESEND][PATCH] iio: simplify with regmap_set_bits(), regmap_clear_bits() Trevor Gamblin
2024-06-11 16:52 ` Trevor Gamblin
2024-06-11 16:52 ` Trevor Gamblin
2024-06-12  8:09 ` Uwe Kleine-König
2024-06-12  8:09   ` Uwe Kleine-König
2024-06-12  8:33 ` Crt Mori
2024-06-12  8:33   ` Crt Mori
2024-06-13  9:24 ` Baolin Wang
2024-06-13  9:24   ` Baolin Wang
2024-06-13 17:20 ` Jonathan Cameron [this message]
2024-06-13 17:20   ` Jonathan Cameron
2024-06-13 17:59   ` Trevor Gamblin
2024-06-13 17:59     ` Trevor Gamblin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240613182021.00005072@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=cmo@melexis.com \
    --cc=cosmin.tanislav@analog.com \
    --cc=ddrokosov@sberdevices.ru \
    --cc=festevam@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=imx@lists.linux.dev \
    --cc=jbrunet@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=jmaneyrol@invensense.com \
    --cc=kernel@pengutronix.de \
    --cc=khilman@baylibre.com \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=lucas.p.stankus@gmail.com \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=neil.armstrong@linaro.org \
    --cc=nuno.sa@analog.com \
    --cc=orsonzhai@gmail.com \
    --cc=rjui@broadcom.com \
    --cc=s.hauer@pengutronix.de \
    --cc=sbranden@broadcom.com \
    --cc=shawnguo@kernel.org \
    --cc=sravanhome@gmail.com \
    --cc=tgamblin@baylibre.com \
    --cc=u.kleine-koenig@baylibre.com \
    --cc=wens@csie.org \
    --cc=zhang.lyra@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.