linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] pinctrl: bcm2835: persist_gpio_outputs follow-up
@ 2024-06-03 18:19 Stefan Wahren
  2024-06-03 18:19 ` [PATCH 1/2] pinctrl: bcm2835: Fix permissions of persist_gpio_outputs Stefan Wahren
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Stefan Wahren @ 2024-06-03 18:19 UTC (permalink / raw)
  To: Linus Walleij, Florian Fainelli
  Cc: bcm-kernel-feedback-list, Ray Jui, Scott Branden, linux-gpio,
	linux-arm-kernel, Bartosz Golaszewski, Phil Elwell, Kent Gibson,
	Andy Shevchenko, Stefan Wahren

After the patch "pinctrl: bcm2835: Make pin freeing behavior configurable"
has been applied for 6.10-rc1, Andy Shevchenko submitted two comments [1].
So this small series address them.

[1] - https://lore.kernel.org/linux-gpio/Zjk-C0nLmlynqLAE@surfacebook.localdomain/

Stefan Wahren (2):
  pinctrl: bcm2835: Fix permissions of persist_gpio_outputs
  pinctrl: bcm2835: Use string_choices API instead of ternary operator

 drivers/pinctrl/bcm/pinctrl-bcm2835.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

--
2.34.1


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

* [PATCH 1/2] pinctrl: bcm2835: Fix permissions of persist_gpio_outputs
  2024-06-03 18:19 [PATCH 0/2] pinctrl: bcm2835: persist_gpio_outputs follow-up Stefan Wahren
@ 2024-06-03 18:19 ` Stefan Wahren
  2024-06-04  7:57   ` Florian Fainelli
  2024-06-03 18:19 ` [PATCH 2/2] pinctrl: bcm2835: Use string_choices API instead of ternary operator Stefan Wahren
  2024-06-17  7:51 ` [PATCH 0/2] pinctrl: bcm2835: persist_gpio_outputs follow-up Linus Walleij
  2 siblings, 1 reply; 7+ messages in thread
From: Stefan Wahren @ 2024-06-03 18:19 UTC (permalink / raw)
  To: Linus Walleij, Florian Fainelli
  Cc: bcm-kernel-feedback-list, Ray Jui, Scott Branden, linux-gpio,
	linux-arm-kernel, Bartosz Golaszewski, Phil Elwell, Kent Gibson,
	Andy Shevchenko, Stefan Wahren

The commit 8ff05989b44e ("pinctrl: bcm2835: Make pin freeing behavior
configurable") unintentionally made the module parameter
persist_gpio_outputs changeable at runtime. So drop the write permission
in order to make the freeing behavior predictable for user applications.

Fixes: 8ff05989b44e ("pinctrl: bcm2835: Make pin freeing behavior configurable")
Reported-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Closes: https://lore.kernel.org/linux-gpio/Zjk-C0nLmlynqLAE@surfacebook.localdomain/
Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 drivers/pinctrl/bcm/pinctrl-bcm2835.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
index 7178a38475cc..27fd54795791 100644
--- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c
+++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
@@ -245,7 +245,7 @@ static const char * const irq_type_names[] = {
 };

 static bool persist_gpio_outputs;
-module_param(persist_gpio_outputs, bool, 0644);
+module_param(persist_gpio_outputs, bool, 0444);
 MODULE_PARM_DESC(persist_gpio_outputs, "Enable GPIO_OUT persistence when pin is freed");

 static inline u32 bcm2835_gpio_rd(struct bcm2835_pinctrl *pc, unsigned reg)
--
2.34.1


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

* [PATCH 2/2] pinctrl: bcm2835: Use string_choices API instead of ternary operator
  2024-06-03 18:19 [PATCH 0/2] pinctrl: bcm2835: persist_gpio_outputs follow-up Stefan Wahren
  2024-06-03 18:19 ` [PATCH 1/2] pinctrl: bcm2835: Fix permissions of persist_gpio_outputs Stefan Wahren
@ 2024-06-03 18:19 ` Stefan Wahren
  2024-06-04  7:28   ` Florian Fainelli
  2024-06-17  7:51 ` [PATCH 0/2] pinctrl: bcm2835: persist_gpio_outputs follow-up Linus Walleij
  2 siblings, 1 reply; 7+ messages in thread
From: Stefan Wahren @ 2024-06-03 18:19 UTC (permalink / raw)
  To: Linus Walleij, Florian Fainelli
  Cc: bcm-kernel-feedback-list, Ray Jui, Scott Branden, linux-gpio,
	linux-arm-kernel, Bartosz Golaszewski, Phil Elwell, Kent Gibson,
	Andy Shevchenko, Stefan Wahren

Use modern string_choices API instead of manually determining the
output using ternary operator.

Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 drivers/pinctrl/bcm/pinctrl-bcm2835.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
index 27fd54795791..184641e221d4 100644
--- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c
+++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
@@ -34,6 +34,7 @@
 #include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/string_choices.h>
 #include <linux/types.h>
 #include <dt-bindings/pinctrl/bcm2835.h>

@@ -752,7 +753,7 @@ static void bcm2835_pctl_pin_dbg_show(struct pinctrl_dev *pctldev,
 	int irq = irq_find_mapping(chip->irq.domain, offset);

 	seq_printf(s, "function %s in %s; irq %d (%s)",
-		fname, value ? "hi" : "lo",
+		fname, str_hi_lo(value),
 		irq, irq_type_names[pc->irq_type[offset]]);
 }

@@ -1428,7 +1429,7 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
 	}

 	dev_info(dev, "GPIO_OUT persistence: %s\n",
-		 persist_gpio_outputs ? "yes" : "no");
+		 str_yes_no(persist_gpio_outputs));

 	return 0;

--
2.34.1


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

* Re: [PATCH 2/2] pinctrl: bcm2835: Use string_choices API instead of ternary operator
  2024-06-03 18:19 ` [PATCH 2/2] pinctrl: bcm2835: Use string_choices API instead of ternary operator Stefan Wahren
@ 2024-06-04  7:28   ` Florian Fainelli
  2024-06-04  7:33     ` Andy Shevchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Florian Fainelli @ 2024-06-04  7:28 UTC (permalink / raw)
  To: Stefan Wahren, Linus Walleij
  Cc: bcm-kernel-feedback-list, Ray Jui, Scott Branden, linux-gpio,
	linux-arm-kernel, Bartosz Golaszewski, Phil Elwell, Kent Gibson,
	Andy Shevchenko

[-- Attachment #1: Type: text/plain, Size: 420 bytes --]



On 6/3/2024 8:19 PM, Stefan Wahren wrote:
> Use modern string_choices API instead of manually determining the
> output using ternary operator.
> 
> Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>

LGTM but sometimes I really wonder to what degree should we invent a 
helper function...

Acked-by: Florian Fainelli <florian.fainelli@broadcom.com>
-- 
Florian

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4221 bytes --]

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

* Re: [PATCH 2/2] pinctrl: bcm2835: Use string_choices API instead of ternary operator
  2024-06-04  7:28   ` Florian Fainelli
@ 2024-06-04  7:33     ` Andy Shevchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-06-04  7:33 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Stefan Wahren, Linus Walleij, bcm-kernel-feedback-list, Ray Jui,
	Scott Branden, linux-gpio, linux-arm-kernel, Bartosz Golaszewski,
	Phil Elwell, Kent Gibson

On Tue, Jun 4, 2024 at 10:28 AM Florian Fainelli
<florian.fainelli@broadcom.com> wrote:
> On 6/3/2024 8:19 PM, Stefan Wahren wrote:

...

> LGTM but sometimes I really wonder to what degree should we invent a
> helper function...

The rationale for the messaging is unification, that's why helpers
like dev_err_probe() (for known non-deferred error codes), str_*()
choices, and %pt (to have time and date be printed) are good to have.
In general I agree that we should't become fanatics of hiding
everything behind the macros and helpers.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 1/2] pinctrl: bcm2835: Fix permissions of persist_gpio_outputs
  2024-06-03 18:19 ` [PATCH 1/2] pinctrl: bcm2835: Fix permissions of persist_gpio_outputs Stefan Wahren
@ 2024-06-04  7:57   ` Florian Fainelli
  0 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2024-06-04  7:57 UTC (permalink / raw)
  To: Stefan Wahren, Linus Walleij
  Cc: bcm-kernel-feedback-list, Ray Jui, Scott Branden, linux-gpio,
	linux-arm-kernel, Bartosz Golaszewski, Phil Elwell, Kent Gibson,
	Andy Shevchenko

[-- Attachment #1: Type: text/plain, Size: 679 bytes --]



On 6/3/2024 8:19 PM, Stefan Wahren wrote:
> The commit 8ff05989b44e ("pinctrl: bcm2835: Make pin freeing behavior
> configurable") unintentionally made the module parameter
> persist_gpio_outputs changeable at runtime. So drop the write permission
> in order to make the freeing behavior predictable for user applications.
> 
> Fixes: 8ff05989b44e ("pinctrl: bcm2835: Make pin freeing behavior configurable")
> Reported-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Closes: https://lore.kernel.org/linux-gpio/Zjk-C0nLmlynqLAE@surfacebook.localdomain/
> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>

Acked-by: Florian Fainelli <florian.fainelli@broadcom.com>
-- 
Florian

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4221 bytes --]

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

* Re: [PATCH 0/2] pinctrl: bcm2835: persist_gpio_outputs follow-up
  2024-06-03 18:19 [PATCH 0/2] pinctrl: bcm2835: persist_gpio_outputs follow-up Stefan Wahren
  2024-06-03 18:19 ` [PATCH 1/2] pinctrl: bcm2835: Fix permissions of persist_gpio_outputs Stefan Wahren
  2024-06-03 18:19 ` [PATCH 2/2] pinctrl: bcm2835: Use string_choices API instead of ternary operator Stefan Wahren
@ 2024-06-17  7:51 ` Linus Walleij
  2 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2024-06-17  7:51 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Florian Fainelli, bcm-kernel-feedback-list, Ray Jui,
	Scott Branden, linux-gpio, linux-arm-kernel, Bartosz Golaszewski,
	Phil Elwell, Kent Gibson, Andy Shevchenko

On Mon, Jun 3, 2024 at 8:20 PM Stefan Wahren <wahrenst@gmx.net> wrote:

> After the patch "pinctrl: bcm2835: Make pin freeing behavior configurable"
> has been applied for 6.10-rc1, Andy Shevchenko submitted two comments [1].
> So this small series address them.
>
> [1] - https://lore.kernel.org/linux-gpio/Zjk-C0nLmlynqLAE@surfacebook.localdomain/
>
> Stefan Wahren (2):
>   pinctrl: bcm2835: Fix permissions of persist_gpio_outputs

Applied for fixes.

>   pinctrl: bcm2835: Use string_choices API instead of ternary operator

Applied for next.

Yours,
Linus Walleij

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

end of thread, other threads:[~2024-06-17  7:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-03 18:19 [PATCH 0/2] pinctrl: bcm2835: persist_gpio_outputs follow-up Stefan Wahren
2024-06-03 18:19 ` [PATCH 1/2] pinctrl: bcm2835: Fix permissions of persist_gpio_outputs Stefan Wahren
2024-06-04  7:57   ` Florian Fainelli
2024-06-03 18:19 ` [PATCH 2/2] pinctrl: bcm2835: Use string_choices API instead of ternary operator Stefan Wahren
2024-06-04  7:28   ` Florian Fainelli
2024-06-04  7:33     ` Andy Shevchenko
2024-06-17  7:51 ` [PATCH 0/2] pinctrl: bcm2835: persist_gpio_outputs follow-up Linus Walleij

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).