[PATCH v2] sound/oss/dmasound: fix build when drivers are mixed =y/=m

From: Randy Dunlap
Date: Sun Apr 03 2022 - 18:25:25 EST


When CONFIG_DMASOUND_ATARI=m and CONFIG_DMASOUND_Q40=y (or vice versa),
dmasound_core.o can be built without dmasound_deinit() being defined,
causing a build error:

ERROR: modpost: "dmasound_deinit" [sound/oss/dmasound/dmasound_atari.ko] undefined!

Modify dmasound_core.c so that dmasound_deinit() is always available.

Suggested-by: Arnd Bergmann <arnd@xxxxxxxx>
Signed-off-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Link: lore.kernel.org/r/202204032138.EFT9qGEd-lkp@xxxxxxxxx
Cc: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
Cc: Jaroslav Kysela <perex@xxxxxxxx>
Cc: Takashi Iwai <tiwai@xxxxxxxx>
Cc: alsa-devel@xxxxxxxxxxxxxxxx
---
#Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") # "forever, but backport not important"

sound/oss/dmasound/dmasound.h | 4 ----
sound/oss/dmasound/dmasound_core.c | 10 +++++-----
2 files changed, 5 insertions(+), 9 deletions(-)

--- linux-next-20220401.orig/sound/oss/dmasound/dmasound_core.c
+++ linux-next-20220401/sound/oss/dmasound/dmasound_core.c
@@ -1424,27 +1424,29 @@ int dmasound_init(void)
return 0;
}

-#ifdef MODULE
-
void dmasound_deinit(void)
{
+#ifdef MODULE
if (irq_installed) {
sound_silence();
dmasound.mach.irqcleanup();
irq_installed = 0;
}
+#endif

write_sq_release_buffers();

+#ifdef MODULE
if (mixer_unit >= 0)
unregister_sound_mixer(mixer_unit);
if (state_unit >= 0)
unregister_sound_special(state_unit);
if (sq_unit >= 0)
unregister_sound_dsp(sq_unit);
+#endif
}

-#else /* !MODULE */
+#ifndef MODULE

static int dmasound_setup(char *str)
{
@@ -1577,9 +1579,7 @@ char dmasound_alaw2dma8[] = {

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
--- linux-next-20220401.orig/sound/oss/dmasound/dmasound.h
+++ linux-next-20220401/sound/oss/dmasound/dmasound.h
@@ -88,11 +88,7 @@ static inline int ioctl_return(int __use
*/

extern int dmasound_init(void);
-#ifdef MODULE
extern void dmasound_deinit(void);
-#else
-#define dmasound_deinit() do { } while (0)
-#endif

/* description of the set-up applies to either hard or soft settings */