2022-04-06 13:20:54

by Randy Dunlap

[permalink] [raw]
Subject: [PATCH v3] sound/oss/dmasound: fix build when drivers are mixed =y/=m

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 and dmasound.h so that dmasound_deinit() is
always available.

The mixed modes (=y/=m) also mean that several variables and structs
have to be declared in all cases.

Suggested-by: Arnd Bergmann <[email protected]>
Suggested-by: Geert Uytterhoeven <[email protected]>
Signed-off-by: Randy Dunlap <[email protected]>
Reported-by: kernel test robot <[email protected]>
Link: lore.kernel.org/r/[email protected]
Cc: Geert Uytterhoeven <[email protected]>
Cc: Jaroslav Kysela <[email protected]>
Cc: Takashi Iwai <[email protected]>
Cc: [email protected]
---
v3: Remove use of #ifdef MODULE/#endif since the conditional data & code
need to be there for some of the cases. (Geert)
v2: make dmasound_deinit() defined and available in all configs (Arnd)

@Geert: any way to test this?

#Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")

sound/oss/dmasound/dmasound.h | 6 ------
sound/oss/dmasound/dmasound_core.c | 24 +-----------------------
2 files changed, 1 insertion(+), 29 deletions(-)

--- a/sound/oss/dmasound/dmasound_core.c
+++ b/sound/oss/dmasound/dmasound_core.c
@@ -206,12 +206,10 @@ module_param(writeBufSize, int, 0);

MODULE_LICENSE("GPL");

-#ifdef MODULE
static int sq_unit = -1;
static int mixer_unit = -1;
static int state_unit = -1;
static int irq_installed;
-#endif /* MODULE */

/* control over who can modify resources shared between play/record */
static fmode_t shared_resource_owner;
@@ -391,9 +389,6 @@ static const struct file_operations mixe

static void mixer_init(void)
{
-#ifndef MODULE
- int mixer_unit;
-#endif
mixer_unit = register_sound_mixer(&mixer_fops, -1);
if (mixer_unit < 0)
return;
@@ -1171,9 +1166,6 @@ static const struct file_operations sq_f
static int sq_init(void)
{
const struct file_operations *fops = &sq_fops;
-#ifndef MODULE
- int sq_unit;
-#endif

sq_unit = register_sound_dsp(fops, -1);
if (sq_unit < 0) {
@@ -1366,9 +1358,6 @@ static const struct file_operations stat

static int state_init(void)
{
-#ifndef MODULE
- int state_unit;
-#endif
state_unit = register_sound_special(&state_fops, SND_DEV_STATUS);
if (state_unit < 0)
return state_unit ;
@@ -1386,10 +1375,9 @@ static int state_init(void)
int dmasound_init(void)
{
int res ;
-#ifdef MODULE
+
if (irq_installed)
return -EBUSY;
-#endif

/* Set up sound queue, /dev/audio and /dev/dsp. */

@@ -1408,9 +1396,7 @@ int dmasound_init(void)
printk(KERN_ERR "DMA sound driver: Interrupt initialization failed\n");
return -ENODEV;
}
-#ifdef MODULE
irq_installed = 1;
-#endif

printk(KERN_INFO "%s DMA sound driver rev %03d installed\n",
dmasound.mach.name, (DMASOUND_CORE_REVISION<<4) +
@@ -1424,8 +1410,6 @@ int dmasound_init(void)
return 0;
}

-#ifdef MODULE
-
void dmasound_deinit(void)
{
if (irq_installed) {
@@ -1444,8 +1428,6 @@ void dmasound_deinit(void)
unregister_sound_dsp(sq_unit);
}

-#else /* !MODULE */
-
static int dmasound_setup(char *str)
{
int ints[6], size;
@@ -1489,8 +1471,6 @@ static int dmasound_setup(char *str)

__setup("dmasound=", dmasound_setup);

-#endif /* !MODULE */
-
/*
* Conversion tables
*/
@@ -1577,9 +1557,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
--- a/sound/oss/dmasound/dmasound.h
+++ b/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 */

@@ -114,9 +110,7 @@ typedef struct {
void *(*dma_alloc)(unsigned int, gfp_t);
void (*dma_free)(void *, unsigned int);
int (*irqinit)(void);
-#ifdef MODULE
void (*irqcleanup)(void);
-#endif
void (*init)(void);
void (*silence)(void);
int (*setFormat)(int);


2022-04-07 19:53:15

by Takashi Iwai

[permalink] [raw]
Subject: Re: [PATCH v3] sound/oss/dmasound: fix build when drivers are mixed =y/=m

On Wed, 06 Apr 2022 01:41:18 +0200,
Randy Dunlap wrote:
>
> 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 and dmasound.h so that dmasound_deinit() is
> always available.
>
> The mixed modes (=y/=m) also mean that several variables and structs
> have to be declared in all cases.
>
> Suggested-by: Arnd Bergmann <[email protected]>
> Suggested-by: Geert Uytterhoeven <[email protected]>
> Signed-off-by: Randy Dunlap <[email protected]>
> Reported-by: kernel test robot <[email protected]>
> Link: lore.kernel.org/r/[email protected]
> Cc: Geert Uytterhoeven <[email protected]>
> Cc: Jaroslav Kysela <[email protected]>
> Cc: Takashi Iwai <[email protected]>
> Cc: [email protected]

Thanks, applied now.


Takashi

2022-04-16 01:26:59

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH v3] sound/oss/dmasound: fix build when drivers are mixed =y/=m

On Tue, Apr 05, 2022 at 04:41:18PM -0700, Randy Dunlap wrote:
> 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 and dmasound.h so that dmasound_deinit() is
> always available.
>
> The mixed modes (=y/=m) also mean that several variables and structs
> have to be declared in all cases.
>
> Suggested-by: Arnd Bergmann <[email protected]>
> Suggested-by: Geert Uytterhoeven <[email protected]>
> Signed-off-by: Randy Dunlap <[email protected]>
> Reported-by: kernel test robot <[email protected]>
> Link: lore.kernel.org/r/[email protected]
> Cc: Geert Uytterhoeven <[email protected]>
> Cc: Jaroslav Kysela <[email protected]>
> Cc: Takashi Iwai <[email protected]>
> Cc: [email protected]
> ---

m68k:allmodconfig fails to build with this patch in the tree.

Error log:
sound/oss/dmasound/dmasound_core.c:1431:12: error: 'dmasound_setup' defined but not used

... because __setup() is empty if MODULE is defined.

Guenter

2022-04-16 02:28:20

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH v3] sound/oss/dmasound: fix build when drivers are mixed =y/=m



On 4/15/22 06:48, Guenter Roeck wrote:
> On Tue, Apr 05, 2022 at 04:41:18PM -0700, Randy Dunlap wrote:
>> 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 and dmasound.h so that dmasound_deinit() is
>> always available.
>>
>> The mixed modes (=y/=m) also mean that several variables and structs
>> have to be declared in all cases.
>>
>> Suggested-by: Arnd Bergmann <[email protected]>
>> Suggested-by: Geert Uytterhoeven <[email protected]>
>> Signed-off-by: Randy Dunlap <[email protected]>
>> Reported-by: kernel test robot <[email protected]>
>> Link: lore.kernel.org/r/[email protected]
>> Cc: Geert Uytterhoeven <[email protected]>
>> Cc: Jaroslav Kysela <[email protected]>
>> Cc: Takashi Iwai <[email protected]>
>> Cc: [email protected]
>> ---
>
> m68k:allmodconfig fails to build with this patch in the tree.
>
> Error log:
> sound/oss/dmasound/dmasound_core.c:1431:12: error: 'dmasound_setup' defined but not used
>
> ... because __setup() is empty if MODULE is defined.
>
> Guenter

Takashi has already merged a patch for this from Miles Chen.

thanks.

--
~Randy