From: David Lechner <dlechner@baylibre.com>
To: Arnd Bergmann <arnd@arndb.de>, linux-arm-kernel@lists.infradead.org
Cc: Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Andy Shevchenko <andy.shevchenko@gmail.com>,
David Lechner <dlechner@baylibre.com>
Subject: [PATCH v5 3/3] bus: ts-nbus: use bitmap_set_value8()
Date: Fri, 13 Jun 2025 13:55:30 -0500 [thread overview]
Message-ID: <20250613-gpio-set-array-helper-v5-3-273fab50cc8e@baylibre.com> (raw)
In-Reply-To: <20250613-gpio-set-array-helper-v5-0-273fab50cc8e@baylibre.com>
Use bitmap_set_value8() instead of accessing the bitmap directly.
Accessing the bitmap directly is not considered good practice. We now
have a helper function that can be used instead, so let's use it.
The bitmap has to be zero-initialized now to avoid a compiler warning
since bitmap_set_value8() does read/modify/write rather than just the
write that this is replacing. In ts_nbus_reset_bus(), this zero-
initialization is enough and we don't need to replace the array
access with bitmap_clear().
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
v5 changes:
- Fix undeclared variable in ts_nbus_reset_bus()
v4 changes:
- Fix typo s/get/set/ in commit message
- Zero-initialize the bitmap to avoid compiler warning
---
drivers/bus/ts-nbus.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/bus/ts-nbus.c b/drivers/bus/ts-nbus.c
index b4c9308caf0647a3261071d9527fffce77784af2..371fa83ad0db424ea48cd7c23e3070f56162d7ad 100644
--- a/drivers/bus/ts-nbus.c
+++ b/drivers/bus/ts-nbus.c
@@ -10,6 +10,7 @@
* TS-4600 SoM.
*/
+#include <linux/bitmap.h>
#include <linux/bitops.h>
#include <linux/gpio/consumer.h>
#include <linux/kernel.h>
@@ -105,9 +106,7 @@ static void ts_nbus_set_direction(struct ts_nbus *ts_nbus, int direction)
*/
static void ts_nbus_reset_bus(struct ts_nbus *ts_nbus)
{
- DECLARE_BITMAP(values, 8);
-
- values[0] = 0;
+ DECLARE_BITMAP(values, 8) = { };
gpiod_multi_set_value_cansleep(ts_nbus->data, values);
gpiod_set_value_cansleep(ts_nbus->csn, 0);
@@ -149,9 +148,9 @@ static int ts_nbus_read_byte(struct ts_nbus *ts_nbus, u8 *val)
*/
static void ts_nbus_write_byte(struct ts_nbus *ts_nbus, u8 byte)
{
- DECLARE_BITMAP(values, 8);
+ DECLARE_BITMAP(values, 8) = { };
- values[0] = byte;
+ bitmap_set_value8(values, byte, 8);
gpiod_multi_set_value_cansleep(ts_nbus->data, values);
}
--
2.43.0
next prev parent reply other threads:[~2025-06-13 19:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-13 18:55 [PATCH v5 0/3] bus: ts-nbus: use gpiod_multi_set_value_cansleep David Lechner
2025-06-13 18:55 ` [PATCH v5 1/3] bus: ts-nbus: validate ts,data-gpios array size David Lechner
2025-06-13 18:55 ` [PATCH v5 2/3] bus: ts-nbus: use gpiod_multi_set_value_cansleep David Lechner
2025-06-13 18:55 ` David Lechner [this message]
2025-06-13 20:37 ` [PATCH v5 0/3] " Arnd Bergmann
2025-06-13 21:00 ` David Lechner
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=20250613-gpio-set-array-helper-v5-3-273fab50cc8e@baylibre.com \
--to=dlechner@baylibre.com \
--cc=andy.shevchenko@gmail.com \
--cc=arnd@arndb.de \
--cc=brgl@bgdev.pl \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).