Building spi-nor.c for PBL breaks the sandbox build: the PBL only
provides get_time_ns() and is_timeout() with CONFIG_PBL_CLOCKSOURCE,
which sandbox only selects with COMPILE_TEST, and sandbox links the PBL
objects with --whole-archive:

  undefined reference to `get_time_ns'
  undefined reference to `is_timeout'

Use the read_poll_get_time_ns()/read_poll_is_timeout() wrappers from
<linux/iopoll.h>, which fall back to polling without timeout when there
is no PBL clocksource, like read_poll_timeout() already does.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Sascha Hauer <[email protected]>
---
 drivers/mtd/spi-nor/spi-nor.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 1acf124cd0..221fea774f 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -12,6 +12,7 @@
 #include <driver.h>
 #include <errno.h>
 #include <linux/err.h>
+#include <linux/iopoll.h>
 #include <linux/sizes.h>
 #include <linux/math64.h>
 #include <linux/mod_devicetable.h>
@@ -371,12 +372,12 @@ static int spi_nor_ready(struct spi_nor *nor)
 static int spi_nor_wait_till_ready_with_timeout(struct spi_nor *nor,
                                                uint64_t timeout_ns)
 {
-       uint64_t start = get_time_ns();
+       uint64_t start = read_poll_get_time_ns();
        int timeout = 0;
        int ret;
 
        while (!timeout) {
-               if (is_timeout(start, timeout_ns))
+               if (read_poll_is_timeout(start, timeout_ns))
                        timeout = 1;
 
                ret = spi_nor_ready(nor);
-- 
2.47.3


Reply via email to