mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Rosin <peda@axentia.se>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/3] mux: gpio: Use bitmap API instead of direct assignment
Date: Tue, 30 Mar 2021 18:10:58 +0200	[thread overview]
Message-ID: <76ca2d4e-4c8a-45d2-94cb-77f0aa296daf@axentia.se> (raw)
In-Reply-To: <20210326172401.33685-1-andriy.shevchenko@linux.intel.com>

Hi!

On 2021-03-26 18:23, Andy Shevchenko wrote:
> Assigning bitmaps like it's done in the driver might be error prone.
> Fix this by using bitmap API.

A bit strongly worded perhaps, since the size of a mux chip with
anywhere near 31 inputs and 2^31 possible selections is a bit
ridiculous. Please send a photo of that HW if someone is producing
one :-)

But there's always the someone-borrows-code-factor, so I guess it's
fine as-is.

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/mux/gpio.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mux/gpio.c b/drivers/mux/gpio.c
> index 02c1f2c014e8..891ee0274733 100644
> --- a/drivers/mux/gpio.c
> +++ b/drivers/mux/gpio.c
> @@ -6,7 +6,7 @@
>   *
>   * Author: Peter Rosin <peda@axentia.se>
>   */
> -

Nit, please keep the empty line here. With that,

Acked-by: Peter Rosin <peda@axentia.se>

And please send directly to Greg, that would be excellent, thanks!

Cheers,
Peter

> +#include <linux/bitmap.h>
>  #include <linux/err.h>
>  #include <linux/gpio/consumer.h>
>  #include <linux/module.h>
> @@ -23,8 +23,9 @@ static int mux_gpio_set(struct mux_control *mux, int state)
>  {
>  	struct mux_gpio *mux_gpio = mux_chip_priv(mux->chip);
>  	DECLARE_BITMAP(values, BITS_PER_TYPE(state));
> +	u32 value = state;
>  
> -	values[0] = state;
> +	bitmap_from_arr32(values, &value, BITS_PER_TYPE(value));
>  
>  	gpiod_set_array_value_cansleep(mux_gpio->gpios->ndescs,
>  				       mux_gpio->gpios->desc,
> @@ -71,7 +72,7 @@ static int mux_gpio_probe(struct platform_device *pdev)
>  		return ret;
>  	}
>  	WARN_ON(pins != mux_gpio->gpios->ndescs);
> -	mux_chip->mux->states = 1 << pins;
> +	mux_chip->mux->states = BIT(pins);
>  
>  	ret = device_property_read_u32(dev, "idle-state", (u32 *)&idle_state);
>  	if (ret >= 0 && idle_state != MUX_IDLE_AS_IS) {
> 

      parent reply	other threads:[~2021-03-30 16:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-26 17:23 Andy Shevchenko
2021-03-26 17:24 ` [PATCH v1 2/3] mux: gpio: Make it OF independent Andy Shevchenko
2021-03-30 16:11   ` Peter Rosin
2021-03-26 17:24 ` [PATCH v1 3/3] mux: gpio: Simplify code by using dev_err_probe() Andy Shevchenko
2021-03-30 16:13   ` Peter Rosin
2021-03-29 12:37 ` [PATCH v1 1/3] mux: gpio: Use bitmap API instead of direct assignment Andy Shevchenko
2021-03-30 16:10 ` Peter Rosin [this message]

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=76ca2d4e-4c8a-45d2-94cb-77f0aa296daf@axentia.se \
    --to=peda@axentia.se \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®