Skip to contentSkip to conversation

nfc: st95hf: switch to using sleeping variants of gpiod API

PATCH In review Dmitry Torokhov 4 participants 6 messages Aug 20, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfc: st95hf: switch to using sleeping variants of gpiod API

The driver does not not use gpiod API calls in an atomic context. Switch to gpiod_set_value_cansleep() calls to allow using the driver with GPIO controllers that might need process context to operate.

---
 drivers/nfc/st95hf/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/nfc/st95hf/core.c +3 -3
index ffe5b4eab457..5b3451fc4491 100644
@@ -450,19 +450,19 @@ static int st95hf_select_protocol(struct st95hf_context *stcontext, int type)
 static void st95hf_send_st95enable_negativepulse(struct st95hf_context *st95con)
 {
 	/* First make irq_in pin high */
-	gpiod_set_value(st95con->enable_gpiod, HIGH);
+	gpiod_set_value_cansleep(st95con->enable_gpiod, HIGH);
 
 	/* wait for 1 milisecond */
 	usleep_range(1000, 2000);
 
 	/* Make irq_in pin low */
-	gpiod_set_value(st95con->enable_gpiod, LOW);
+	gpiod_set_value_cansleep(st95con->enable_gpiod, LOW);
 
 	/* wait for minimum interrupt pulse to make st95 active */
 	usleep_range(1000, 2000);
 
 	/* At end make it high */
-	gpiod_set_value(st95con->enable_gpiod, HIGH);
+	gpiod_set_value_cansleep(st95con->enable_gpiod, HIGH);
 }
 
 /*
Signature · 5 lines
2.46.0.184.g6999bdac58-goog


-- 
Dmitry
#1 lore raw
Quoted 1 line · Dmitry Torokhov

The driver does not not use gpiod API calls in an atomic context. Switch

please remove one "not"

Quoted 4 lines

to gpiod_set_value_cansleep() calls to allow using the driver with GPIO controllers that might need process context to operate.

Code is fine, but why not as a fix?

Quoted 31 lines
---
  drivers/nfc/st95hf/core.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/nfc/st95hf/core.c +3 -3
index ffe5b4eab457..5b3451fc4491 100644
@@ -450,19 +450,19 @@ static int st95hf_select_protocol(struct st95hf_context *stcontext, int type)
  static void st95hf_send_st95enable_negativepulse(struct st95hf_context *st95con)
  {
  	/* First make irq_in pin high */
-	gpiod_set_value(st95con->enable_gpiod, HIGH);
+	gpiod_set_value_cansleep(st95con->enable_gpiod, HIGH);
 
  	/* wait for 1 milisecond */
  	usleep_range(1000, 2000);
 
  	/* Make irq_in pin low */
-	gpiod_set_value(st95con->enable_gpiod, LOW);
+	gpiod_set_value_cansleep(st95con->enable_gpiod, LOW);
 
  	/* wait for minimum interrupt pulse to make st95 active */
  	usleep_range(1000, 2000);
 
  	/* At end make it high */
-	gpiod_set_value(st95con->enable_gpiod, HIGH);
+	gpiod_set_value_cansleep(st95con->enable_gpiod, HIGH);
  }
 
  /*
#2 lore raw
Quoted 11 lines · Przemek Kitszel
Quoted 1 line · Dmitry Torokhov

The driver does not not use gpiod API calls in an atomic context. Switch

please remove one "not"

Quoted 4 lines

to gpiod_set_value_cansleep() calls to allow using the driver with GPIO controllers that might need process context to operate.

Code is fine, but why not as a fix?

Why would this be a fix? What is broken?

Andrew

maintainer
#4 lore raw
In reply to Dmitry Torokhov
Quoted 3 lines · On Mon, 19 Aug 2024 18:10:32 -0700 Dmitry Torokhov wrote:

The driver does not not use gpiod API calls in an atomic context. Switch to gpiod_set_value_cansleep() calls to allow using the driver with GPIO controllers that might need process context to operate.

Could you explain why? Are you using this device? Is it part of some larger effort to remove an API?

#5 lore raw
Quoted 7 lines · Jakub Kicinski
Quoted 3 lines · On Mon, 19 Aug 2024 18:10:32 -0700 Dmitry Torokhov wrote:

The driver does not not use gpiod API calls in an atomic context. Switch to gpiod_set_value_cansleep() calls to allow using the driver with GPIO controllers that might need process context to operate.

Could you explain why? Are you using this device? Is it part of some larger effort to remove an API?

Because it is better to use sleeping variants of gpiod API unless the call is in atomic context, so it is basic code hygiene. We do not want other drivers to copy the behavior.

I was going through my WIP patches and decided to sent it out. Originally it was part of overall transition of the driver to gpiod API, but Andy Shevchenko beat me to it, so movement to gpiod_set_value_cansleep() is all that is left.

Thanks.

Signature · 1 line
Dmitry
#3 lore raw
In reply to Andrew Lunn
Quoted 6 lines · Andrew Lunn
Quoted 5 lines · Przemek Kitszel
Quoted 1 line · Dmitry Torokhov

The driver does not not use gpiod API calls in an atomic context. Switch

please remove one "not"

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

to gpiod_set_value_cansleep() calls to allow using the driver with GPIO controllers that might need process context to operate.

Code is fine, but why not as a fix?

Why would this be a fix? What is broken?

No, this is not a fix but a tiny enhancement. As far as I know no existing devices actually require it.

Thanks.

Signature · 1 line
Dmitry