Skip to contentSkip to conversation

staging: fbtft: Change udelay() to usleep_range()

PATCH Superseded Gideon Adjei 2 participants 2 messages Jan 13

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: fbtft: Change udelay() to usleep_range()

Replace udelay() calls >= 100us with usleep_range() to avoid busy-waiting.

The delays are used in init_display() callbacks. These callbacks are invoked by fbtft_probe_common() during the driver's probe path. the probe path runs in process context which already uses sleeping APIs. This makes usleep_range() safe to use in these situations.

---
 drivers/staging/fbtft/fb_tinylcd.c   | 2 +-
 drivers/staging/fbtft/fb_upd161704.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/fbtft/fb_tinylcd.c +1 -1
index 9469248f2c50..ee8d6b10374a 100644
@@ -41,7 +41,7 @@ static int init_display(struct fbtft_par *par)
 		       0x00, 0x35, 0x33, 0x00, 0x00, 0x00);
 	write_reg(par, MIPI_DCS_SET_PIXEL_FORMAT, 0x55);
 	write_reg(par, MIPI_DCS_EXIT_SLEEP_MODE);
-	udelay(250);
+	usleep_range(250, 400);
 	write_reg(par, MIPI_DCS_SET_DISPLAY_ON);
 
 	return 0;
drivers/staging/fbtft/fb_upd161704.c +2 -2
index c680160d6380..aed5cc7cabde 100644
@@ -32,7 +32,7 @@ static int init_display(struct fbtft_par *par)
 
 	/* oscillator start */
 	write_reg(par, 0x003A, 0x0001);	/*Oscillator 0: stop, 1: operation */
-	udelay(100);
+	usleep_range(100, 200);
 
 	/* y-setting */
 	write_reg(par, 0x0024, 0x007B);	/* amplitude setting */
@@ -60,7 +60,7 @@ static int init_display(struct fbtft_par *par)
 
 	/* Power supply setting */
 	write_reg(par, 0x0019, 0x0000);	/* DC/DC output setting */
-	udelay(200);
+	usleep_range(200, 400);
 	write_reg(par, 0x001A, 0x1000);	/* DC/DC frequency setting */
 	write_reg(par, 0x001B, 0x0023);	/* DC/DC rising setting */
 	write_reg(par, 0x001C, 0x0C01);	/* Regulator voltage setting */
Signature · 1 line
2.34.1
#1 lore raw
Quoted 7 lines · Gideon Adjei

Replace udelay() calls >= 100us with usleep_range() to avoid busy-waiting.

The delays are used in init_display() callbacks. These callbacks are invoked by fbtft_probe_common() during the driver's probe path. the probe path runs in process context which already uses sleeping APIs. This makes usleep_range() safe to use in these situations.

Nice, now can we switch to modern API, i.e. fsleep()?

Signature · 2 lines
With Best Regards,
Andy Shevchenko