* [PATCH v5 0/3] bus: ts-nbus: use gpiod_multi_set_value_cansleep
@ 2025-06-13 18:55 David Lechner
2025-06-13 18:55 ` [PATCH v5 1/3] bus: ts-nbus: validate ts,data-gpios array size David Lechner
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: David Lechner @ 2025-06-13 18:55 UTC (permalink / raw)
To: Arnd Bergmann, linux-arm-kernel
Cc: Linus Walleij, Bartosz Golaszewski, linux-gpio, linux-kernel,
David Lechner, Andy Shevchenko
This is what remains from "gpiolib: add gpiod_multi_set_value_cansleep"
that didn't get applied yet for the bus subsystem. So I have changed
the subject line accordingly.
Arnd,
There was no maintainer listed in MAINTAINERS for the ts-nbus driver
and it looks like you have picked up patches for it in the past. Could
you please pick up these as well?
---
Changes in v5:
- Fix undeclared variable in ts_nbus_reset_bus()
- Link to v4: https://lore.kernel.org/r/20250611-gpio-set-array-helper-v4-0-fb86a9b499ab@baylibre.com
Changes in v4:
- Dropped all non-ts-nbus patches.
- Fixed a reported issue with uninitialized variables.
- Link to v3: https://lore.kernel.org/r/20250210-gpio-set-array-helper-v3-0-d6a673674da8@baylibre.com
Changes in v3:
- Added IS_ERR_OR_NULL() check to gpiod_multi_set_value_cansleep()
- Added new patches to clean up accessing bitmap directly (ts-nbus, ad2s1210).
- Added function prefix for max3191x.
- Removed unnecessary braces in ad7606 patch.
- Picked up additional trailers.
- Link to v2: https://lore.kernel.org/r/20250206-gpio-set-array-helper-v2-0-1c5f048f79c3@baylibre.com
Changes in v2:
- Renamed new function from gpiods_multi_set_value_cansleep() to
gpiod_multi_set_value_cansleep()
- Fixed typo in name of replaced function in all commit messages.
- Picked up trailers.
- Link to v1: https://lore.kernel.org/r/20250131-gpio-set-array-helper-v1-0-991c8ccb4d6e@baylibre.com
---
David Lechner (3):
bus: ts-nbus: validate ts,data-gpios array size
bus: ts-nbus: use gpiod_multi_set_value_cansleep
bus: ts-nbus: use bitmap_set_value8()
drivers/bus/ts-nbus.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
---
base-commit: 19a60293b9925080d97f22f122aca3fc46dadaf9
change-id: 20250131-gpio-set-array-helper-bd4a328370d3
Best regards,
--
David Lechner <dlechner@baylibre.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v5 1/3] bus: ts-nbus: validate ts,data-gpios array size
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 ` David Lechner
2025-06-13 18:55 ` [PATCH v5 2/3] bus: ts-nbus: use gpiod_multi_set_value_cansleep David Lechner
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: David Lechner @ 2025-06-13 18:55 UTC (permalink / raw)
To: Arnd Bergmann, linux-arm-kernel
Cc: Linus Walleij, Bartosz Golaszewski, linux-gpio, linux-kernel,
David Lechner
Add validation of ts,data-gpios array size during probe. The driver
later hard-codes 8 as the size of the array when using it, so we should
be validating that the array is actually that big to prevent possible
out of bounds accesses.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/bus/ts-nbus.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/bus/ts-nbus.c b/drivers/bus/ts-nbus.c
index 2328c48b9b1260e805c631f2aa7379d620084537..d3ee102a13893c83c50e41f7298821f4d7ae3487 100644
--- a/drivers/bus/ts-nbus.c
+++ b/drivers/bus/ts-nbus.c
@@ -48,6 +48,10 @@ static int ts_nbus_init_pdata(struct platform_device *pdev,
return dev_err_probe(&pdev->dev, PTR_ERR(ts_nbus->data),
"failed to retrieve ts,data-gpio from dts\n");
+ if (ts_nbus->data->ndescs != 8)
+ return dev_err_probe(&pdev->dev, -EINVAL,
+ "invalid number of ts,data-gpios\n");
+
ts_nbus->csn = devm_gpiod_get(&pdev->dev, "ts,csn", GPIOD_OUT_HIGH);
if (IS_ERR(ts_nbus->csn))
return dev_err_probe(&pdev->dev, PTR_ERR(ts_nbus->csn),
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v5 2/3] bus: ts-nbus: use gpiod_multi_set_value_cansleep
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 ` David Lechner
2025-06-13 18:55 ` [PATCH v5 3/3] bus: ts-nbus: use bitmap_set_value8() David Lechner
2025-06-13 20:37 ` [PATCH v5 0/3] bus: ts-nbus: use gpiod_multi_set_value_cansleep Arnd Bergmann
3 siblings, 0 replies; 6+ messages in thread
From: David Lechner @ 2025-06-13 18:55 UTC (permalink / raw)
To: Arnd Bergmann, linux-arm-kernel
Cc: Linus Walleij, Bartosz Golaszewski, linux-gpio, linux-kernel,
David Lechner
Reduce verbosity by using gpiod_multi_set_value_cansleep() instead of
gpiod_set_array_value_cansleep().
ts_nbus->data->ndescs is validated to be 8 during probe, so will have
the same value as the hard-coded 8 that is removed by this change.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/bus/ts-nbus.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/bus/ts-nbus.c b/drivers/bus/ts-nbus.c
index d3ee102a13893c83c50e41f7298821f4d7ae3487..b4c9308caf0647a3261071d9527fffce77784af2 100644
--- a/drivers/bus/ts-nbus.c
+++ b/drivers/bus/ts-nbus.c
@@ -109,8 +109,7 @@ static void ts_nbus_reset_bus(struct ts_nbus *ts_nbus)
values[0] = 0;
- gpiod_set_array_value_cansleep(8, ts_nbus->data->desc,
- ts_nbus->data->info, values);
+ gpiod_multi_set_value_cansleep(ts_nbus->data, values);
gpiod_set_value_cansleep(ts_nbus->csn, 0);
gpiod_set_value_cansleep(ts_nbus->strobe, 0);
gpiod_set_value_cansleep(ts_nbus->ale, 0);
@@ -150,12 +149,11 @@ 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)
{
- struct gpio_descs *gpios = ts_nbus->data;
DECLARE_BITMAP(values, 8);
values[0] = byte;
- gpiod_set_array_value_cansleep(8, gpios->desc, gpios->info, values);
+ gpiod_multi_set_value_cansleep(ts_nbus->data, values);
}
/*
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v5 3/3] bus: ts-nbus: use bitmap_set_value8()
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
2025-06-13 20:37 ` [PATCH v5 0/3] bus: ts-nbus: use gpiod_multi_set_value_cansleep Arnd Bergmann
3 siblings, 0 replies; 6+ messages in thread
From: David Lechner @ 2025-06-13 18:55 UTC (permalink / raw)
To: Arnd Bergmann, linux-arm-kernel
Cc: Linus Walleij, Bartosz Golaszewski, linux-gpio, linux-kernel,
Andy Shevchenko, David Lechner
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v5 0/3] bus: ts-nbus: use gpiod_multi_set_value_cansleep
2025-06-13 18:55 [PATCH v5 0/3] bus: ts-nbus: use gpiod_multi_set_value_cansleep David Lechner
` (2 preceding siblings ...)
2025-06-13 18:55 ` [PATCH v5 3/3] bus: ts-nbus: use bitmap_set_value8() David Lechner
@ 2025-06-13 20:37 ` Arnd Bergmann
2025-06-13 21:00 ` David Lechner
3 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2025-06-13 20:37 UTC (permalink / raw)
To: David Lechner, linux-arm-kernel
Cc: Linus Walleij, Bartosz Golaszewski, open list:GPIO SUBSYSTEM,
linux-kernel, Andy Shevchenko, Sebastien Bourdelin
On Fri, Jun 13, 2025, at 20:55, David Lechner wrote:
> This is what remains from "gpiolib: add gpiod_multi_set_value_cansleep"
> that didn't get applied yet for the bus subsystem. So I have changed
> the subject line accordingly.
>
> Arnd,
>
> There was no maintainer listed in MAINTAINERS for the ts-nbus driver
> and it looks like you have picked up patches for it in the past. Could
> you please pick up these as well?
Sure, no problem, just a few things:
- These are all cleanups that can wait until 6.17, right?
- I see the driver has no in-tree users, and apparently never
were. There is a imx28-ts4600.dts file that should reference
it but doesn't. Do we have any indication that the driver works?
Added Sebastien to Cc as well for clarification.
- it would help me if you can send the patches to soc@kernel.org
for me to pick up, as that ensures I don't forget them.
Arnd
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v5 0/3] bus: ts-nbus: use gpiod_multi_set_value_cansleep
2025-06-13 20:37 ` [PATCH v5 0/3] bus: ts-nbus: use gpiod_multi_set_value_cansleep Arnd Bergmann
@ 2025-06-13 21:00 ` David Lechner
0 siblings, 0 replies; 6+ messages in thread
From: David Lechner @ 2025-06-13 21:00 UTC (permalink / raw)
To: Arnd Bergmann, linux-arm-kernel
Cc: Linus Walleij, Bartosz Golaszewski, open list:GPIO SUBSYSTEM,
linux-kernel, Andy Shevchenko, Sebastien Bourdelin
On 6/13/25 3:37 PM, Arnd Bergmann wrote:
> On Fri, Jun 13, 2025, at 20:55, David Lechner wrote:
>> This is what remains from "gpiolib: add gpiod_multi_set_value_cansleep"
>> that didn't get applied yet for the bus subsystem. So I have changed
>> the subject line accordingly.
>>
>> Arnd,
>>
>> There was no maintainer listed in MAINTAINERS for the ts-nbus driver
>> and it looks like you have picked up patches for it in the past. Could
>> you please pick up these as well?
>
> Sure, no problem, just a few things:
>
> - These are all cleanups that can wait until 6.17, right?
yes
> - I see the driver has no in-tree users, and apparently never
> were. There is a imx28-ts4600.dts file that should reference
> it but doesn't. Do we have any indication that the driver works?
> Added Sebastien to Cc as well for clarification.
I dropped Sebastien in v5 because the emails bounced in v4, so I
don't expect we will get a response. I'm not familiar with this
driver or related hardware myself.
> - it would help me if you can send the patches to soc@kernel.org
> for me to pick up, as that ensures I don't forget them.
>
> Arnd
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-06-13 21:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH v5 3/3] bus: ts-nbus: use bitmap_set_value8() David Lechner
2025-06-13 20:37 ` [PATCH v5 0/3] bus: ts-nbus: use gpiod_multi_set_value_cansleep Arnd Bergmann
2025-06-13 21:00 ` David Lechner
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).