sandbox: fix a compilation error
authorSergei Antonov <saproj@gmail.com>
Mon, 12 Jun 2023 21:19:04 +0000 (00:19 +0300)
committerSimon Glass <sjg@chromium.org>
Thu, 20 Jul 2023 20:10:57 +0000 (14:10 -0600)
With sandbox and sandbox64 configurations:

In file included from .../u-boot/include/test/test.h:156,
                 from .../u-boot/include/test/lib.h:9,
                 from .../u-boot/test/lib/test_crc8.c:8:
.../u-boot/arch/sandbox/include/asm/test.h: In function ‘sandbox_sdl_set_bpp’:
.../u-boot/arch/sandbox/include/asm/test.h:323:17: error: ‘ENOSYS’ undeclared (first use in this function)
  323 |         return -ENOSYS;
      |                 ^~~~~~

Per Tom Rini's suggestion:
move that function prototype over to arch/sandbox/include/asm/sdl.h
and make test/dm/video.c include <asm/sdl.h>

Cc: Simon Glass <sjg@chromium.org>
Suggested-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Sergei Antonov <saproj@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/sandbox/include/asm/sdl.h
arch/sandbox/include/asm/test.h
test/dm/video.c

index 56dcb84..ee4991f 100644 (file)
@@ -7,6 +7,7 @@
 #define __SANDBOX_SDL_H
 
 #include <errno.h>
+#include <video.h>
 
 #ifdef CONFIG_SANDBOX_SDL
 
@@ -87,6 +88,22 @@ int sandbox_sdl_sound_stop(void);
  */
 int sandbox_sdl_sound_init(int rate, int channels);
 
+/**
+ * sandbox_sdl_set_bpp() - Set the depth of the sandbox display
+ *
+ * The device must not be active when this function is called. It activiates it
+ * before returning.
+ *
+ * This updates the depth value and adjusts a few other settings accordingly.
+ * It must be called before the display is probed.
+ *
+ * @dev: Device to adjust
+ * @l2bpp: depth to set
+ * Return: 0 if the device was already active, other error if it fails to probe
+ * after the change
+ */
+int sandbox_sdl_set_bpp(struct udevice *dev, enum video_log2_bpp l2bpp);
+
 #else
 static inline int sandbox_sdl_init_display(int width, int height, int log2_bpp,
                                           bool double_size)
@@ -134,6 +151,12 @@ static inline int sandbox_sdl_sound_init(int rate, int channels)
        return -ENODEV;
 }
 
+static inline int sandbox_sdl_set_bpp(struct udevice *dev,
+                                     enum video_log2_bpp l2bpp)
+{
+       return -ENOSYS;
+}
+
 #endif
 
 #endif
index e482271..17159f8 100644 (file)
@@ -8,7 +8,6 @@
 #ifndef __ASM_TEST_H
 #define __ASM_TEST_H
 
-#include <video.h>
 #include <pci_ids.h>
 
 struct unit_test_state;
@@ -300,30 +299,6 @@ void sandbox_cros_ec_set_test_flags(struct udevice *dev, uint flags);
  */
 int sandbox_cros_ec_get_pwm_duty(struct udevice *dev, uint index, uint *duty);
 
-#if IS_ENABLED(CONFIG_SANDBOX_SDL)
-/**
- * sandbox_sdl_set_bpp() - Set the depth of the sandbox display
- *
- * The device must not be active when this function is called. It activiates it
- * before returning.
- *
- * This updates the depth value and adjusts a few other settings accordingly.
- * It must be called before the display is probed.
- *
- * @dev: Device to adjust
- * @l2bpp: depth to set
- * Return: 0 if the device was already active, other error if it fails to probe
- * after the change
- */
-int sandbox_sdl_set_bpp(struct udevice *dev, enum video_log2_bpp l2bpp);
-#else
-static inline int sandbox_sdl_set_bpp(struct udevice *dev,
-                                     enum video_log2_bpp l2bpp)
-{
-       return -ENOSYS;
-}
-#endif
-
 /**
  * sandbox_set_fake_efi_mgr_dev() - Control EFI bootmgr producing valid bootflow
  *
index 0534ee9..d907f68 100644 (file)
@@ -15,6 +15,7 @@
 #include <video.h>
 #include <video_console.h>
 #include <asm/test.h>
+#include <asm/sdl.h>
 #include <dm/test.h>
 #include <dm/uclass-internal.h>
 #include <test/test.h>