[PATCH] sound/oss/dmasound: fix build when some drivers are =m and others are =y

From: Randy Dunlap
Date: Thu Nov 18 2021 - 01:22:05 EST


When CONFIG_DMASOUND_ATARI=y and CONFIG_DMASOUND_Q40=m,
dmasound_atari.o is built first (listed first in the Makefile),
so dmasound_core.o is built as builtin, not for use by loadable
modules. Then dmasound_q40.o is built and linked with the
already-built dmasound_core.o, but the latter does not support
use by loadable modules. This causes the missing symbol to be
undefined.

Fixes this build error:
ERROR: modpost: "dmasound_deinit" [sound/oss/dmasound/dmasound_q40.ko] undefined!

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") # "forever"
Signed-off-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Cc: Arnd Bergmann <arnd@xxxxxxxx>
Cc: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
Cc: Jaroslav Kysela <perex@xxxxxxxx>
Cc: Takashi Iwai <tiwai@xxxxxxxx>
Cc: alsa-devel@xxxxxxxxxxxxxxxx
---
There may be some Makefile solution to this but I don't know what
it is. I didn't want to spend lots of time on these old drivers.

sound/oss/dmasound/Makefile | 6 +++---
sound/oss/dmasound/dmasound_atari.c | 2 +-
sound/oss/dmasound/dmasound_core.c | 16 ----------------
sound/oss/dmasound/dmasound_paula.c | 2 +-
sound/oss/dmasound/dmasound_q40.c | 2 +-
5 files changed, 6 insertions(+), 22 deletions(-)

--- linux-next-20211117.orig/sound/oss/dmasound/dmasound_atari.c
+++ linux-next-20211117/sound/oss/dmasound/dmasound_atari.c
@@ -27,7 +27,7 @@
#include <asm/atariints.h>
#include <asm/atari_stram.h>

-#include "dmasound.h"
+#include "dmasound_core.c"

#define DMASOUND_ATARI_REVISION 0
#define DMASOUND_ATARI_EDITION 3
--- linux-next-20211117.orig/sound/oss/dmasound/dmasound_paula.c
+++ linux-next-20211117/sound/oss/dmasound/dmasound_paula.c
@@ -30,7 +30,7 @@
#include <asm/amigaints.h>
#include <asm/machdep.h>

-#include "dmasound.h"
+#include "dmasound_core.c"

#define DMASOUND_PAULA_REVISION 0
#define DMASOUND_PAULA_EDITION 4
--- linux-next-20211117.orig/sound/oss/dmasound/dmasound_q40.c
+++ linux-next-20211117/sound/oss/dmasound/dmasound_q40.c
@@ -25,7 +25,7 @@
#include <asm/q40ints.h>
#include <asm/q40_master.h>

-#include "dmasound.h"
+#include "dmasound_core.c"

#define DMASOUND_Q40_REVISION 0
#define DMASOUND_Q40_EDITION 3
--- linux-next-20211117.orig/sound/oss/dmasound/Makefile
+++ linux-next-20211117/sound/oss/dmasound/Makefile
@@ -3,6 +3,6 @@
# Makefile for the DMA sound driver
#

-obj-$(CONFIG_DMASOUND_ATARI) += dmasound_core.o dmasound_atari.o
-obj-$(CONFIG_DMASOUND_PAULA) += dmasound_core.o dmasound_paula.o
-obj-$(CONFIG_DMASOUND_Q40) += dmasound_core.o dmasound_q40.o
+obj-$(CONFIG_DMASOUND_ATARI) += dmasound_atari.o
+obj-$(CONFIG_DMASOUND_PAULA) += dmasound_paula.o
+obj-$(CONFIG_DMASOUND_Q40) += dmasound_q40.o
--- linux-next-20211117.orig/sound/oss/dmasound/dmasound_core.c
+++ linux-next-20211117/sound/oss/dmasound/dmasound_core.c
@@ -1570,19 +1570,3 @@ char dmasound_alaw2dma8[] = {
3, 3, 3, 3, 3, 3, 3, 3
};
#endif /* HAS_8BIT_TABLES */
-
- /*
- * Visible symbols for modules
- */
-
-EXPORT_SYMBOL(dmasound);
-EXPORT_SYMBOL(dmasound_init);
-#ifdef MODULE
-EXPORT_SYMBOL(dmasound_deinit);
-#endif
-EXPORT_SYMBOL(dmasound_write_sq);
-EXPORT_SYMBOL(dmasound_catchRadius);
-#ifdef HAS_8BIT_TABLES
-EXPORT_SYMBOL(dmasound_ulaw2dma8);
-EXPORT_SYMBOL(dmasound_alaw2dma8);
-#endif