public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [v2] media: i2c: mt9m114: use fsleep() in place of udelay()
@ 2023-12-13 11:23 Arnd Bergmann
  2023-12-13 11:36 ` Laurent Pinchart
  2023-12-13 11:40 ` Tomi Valkeinen
  0 siblings, 2 replies; 6+ messages in thread
From: Arnd Bergmann @ 2023-12-13 11:23 UTC (permalink / raw)
  To: Laurent Pinchart, Sakari Ailus, Mauro Carvalho Chehab,
	Nathan Chancellor, Jacopo Mondi, Hans Verkuil
  Cc: Arnd Bergmann, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Tomi Valkeinen, Shuah Khan, linux-media, linux-kernel, llvm

From: Arnd Bergmann <arnd@arndb.de>

With clang-16, building without COMMON_CLK triggers a range check on
udelay() because of a constant division-by-zero calculation:

ld.lld: error: undefined symbol: __bad_udelay
>>> referenced by mt9m114.c
>>>               drivers/media/i2c/mt9m114.o:(mt9m114_power_on) in archive vmlinux.a

In this configuration, the driver already fails to probe, before
this function gets called, so it's enough to suppress the assertion.

Do this by using fsleep(), which turns long delays into sleep() calls
in place of the link failure.

This is probably a good idea regardless to avoid overly long dynamic
udelay() calls on a slow clock.

Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Fixes: 24d756e914fc ("media: i2c: Add driver for onsemi MT9M114 camera sensor")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/media/i2c/mt9m114.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c
index 0a22f328981d..68adaecaf481 100644
--- a/drivers/media/i2c/mt9m114.c
+++ b/drivers/media/i2c/mt9m114.c
@@ -2116,7 +2116,7 @@ static int mt9m114_power_on(struct mt9m114 *sensor)
 		duration = DIV_ROUND_UP(2 * 50 * 1000000, freq);
 
 		gpiod_set_value(sensor->reset, 1);
-		udelay(duration);
+		fsleep(duration);
 		gpiod_set_value(sensor->reset, 0);
 	} else {
 		/*
-- 
2.39.2


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

end of thread, other threads:[~2023-12-13 12:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-13 11:23 [PATCH] [v2] media: i2c: mt9m114: use fsleep() in place of udelay() Arnd Bergmann
2023-12-13 11:36 ` Laurent Pinchart
2023-12-13 11:40 ` Tomi Valkeinen
2023-12-13 11:48   ` Laurent Pinchart
2023-12-13 11:56     ` Tomi Valkeinen
2023-12-13 12:09       ` Laurent Pinchart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox