[PATCH] virtio: console: Prepare for making REMOTEPROC modular

From: Uwe Kleine-König
Date: Thu Feb 13 2025 - 06:55:40 EST


virtio_console.c can make use of REMOTEPROC. Therefore it has several
tests evaluating

IS_ENABLED(CONFIG_REMOTEPROC)

. This currently only does the right thing because CONFIG_REMOTEPROC
cannot be modular. Otherwise the configuration

CONFIG_REMOTEPROC=m
CONFIG_VIRTIO_CONSOLE=y

would result in a build failure because then
IS_ENABLED(CONFIG_REMOTEPROC) evaluates to true but still the built-in
virtio_console.o must not use symbols from the remoteproc module.

To prepare for making REMOTEPROC modular change the tests to use
IS_REACHABLE() instead of IS_ENABLED() which copes correctly for the
above case as it evaluates to false then.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxx>
---
Hello,

I didn't check what else needs to be done to make CONFIG_REMOTEPROC
tristate but even if it stays a bool using IS_REACHABLE() is still the
better choice.

Best regards
Uwe

drivers/char/virtio_console.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 24442485e73e..7d7463d6f218 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -28,7 +28,7 @@
#include <linux/dma-mapping.h>
#include "../tty/hvc/hvc_console.h"

-#define is_rproc_enabled IS_ENABLED(CONFIG_REMOTEPROC)
+#define is_rproc_enabled IS_REACHABLE(CONFIG_REMOTEPROC)
#define VIRTCONS_MAX_PORTS 0x8000

/*
@@ -2078,7 +2078,7 @@ static const unsigned int features[] = {
};

static const struct virtio_device_id rproc_serial_id_table[] = {
-#if IS_ENABLED(CONFIG_REMOTEPROC)
+#if IS_REACHABLE(CONFIG_REMOTEPROC)
{ VIRTIO_ID_RPROC_SERIAL, VIRTIO_DEV_ANY_ID },
#endif
{ 0 },

base-commit: a64dcfb451e254085a7daee5fe51bf22959d52d3
--
2.47.1