linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/3] mux: gpio: Use bitmap API instead of direct assignment
@ 2021-03-30 19:33 Andy Shevchenko
  2021-03-30 19:33 ` [PATCH v2 2/3] mux: gpio: Make it OF independent Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andy Shevchenko @ 2021-03-30 19:33 UTC (permalink / raw)
  To: Andy Shevchenko, linux-kernel; +Cc: Peter Rosin, Greg Kroah-Hartman

Assigning bitmaps like it's done in the driver might be error prone.
Fix this by using bitmap API.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Peter Rosin <peda@axentia.se>
---
v2: left blank line untouched (Peter)
 drivers/mux/gpio.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mux/gpio.c b/drivers/mux/gpio.c
index 02c1f2c014e8..d1b4aa923657 100644
--- a/drivers/mux/gpio.c
+++ b/drivers/mux/gpio.c
@@ -7,6 +7,7 @@
  * Author: Peter Rosin <peda@axentia.se>
  */
 
+#include <linux/bitmap.h>
 #include <linux/err.h>
 #include <linux/gpio/consumer.h>
 #include <linux/module.h>
@@ -23,8 +24,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 +73,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) {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-04-02 14:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-30 19:33 [PATCH v2 1/3] mux: gpio: Use bitmap API instead of direct assignment Andy Shevchenko
2021-03-30 19:33 ` [PATCH v2 2/3] mux: gpio: Make it OF independent Andy Shevchenko
2021-03-30 19:33 ` [PATCH v2 3/3] mux: gpio: Simplify code by using dev_err_probe() Andy Shevchenko
2021-03-31  7:12 ` [PATCH v2 1/3] mux: gpio: Use bitmap API instead of direct assignment Peter Rosin
2021-04-02 14:29   ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).