Skip to content

Commit d886e87

Browse files
htejunperexg
authored andcommitted
sound: make OSS sound core optional
sound/sound_core.c implements soundcore.ko and contains two parts - sound_class which is shared by both ALSA and OSS and device redirection support for OSS. It's always compiled when any sound support is enabled although it's necessary only when OSS (the actual one or emulation) is enabled. This is slightly wasteful and as device redirection always registers character device region for major 14, it prevents alternative implementation. This patch introduces a new config SOUND_OSS_CORE which is selected iff OSS support is actually necessary and build the OSS core part conditionally. If OSS is disabled, soundcore merely contains sound_class but leaving it that way seems to be the simplest approach as otherwise sound_class should be in ALSA core file if OSS is disabled but should be in soundcore if OSS is enabled. Also, there's also the user confusion factor. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
1 parent 9f99a63 commit d886e87

5 files changed

Lines changed: 71 additions & 19 deletions

File tree

‎arch/um/Kconfig.char‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ config SOUND
203203
tristate
204204
default UML_SOUND
205205

206+
config SOUND_OSS_CORE
207+
bool
208+
default UML_SOUND
209+
206210
config HOSTAUDIO
207211
tristate
208212
default UML_SOUND

‎sound/Kconfig‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ menuconfig SOUND
2828

2929
if SOUND
3030

31+
config SOUND_OSS_CORE
32+
bool
33+
default n
34+
3135
source "sound/oss/dmasound/Kconfig"
3236

3337
if !M68K
@@ -80,6 +84,7 @@ endif # SND
8084

8185
menuconfig SOUND_PRIME
8286
tristate "Open Sound System (DEPRECATED)"
87+
select SOUND_OSS_CORE
8388
help
8489
Say 'Y' or 'M' to enable Open Sound System drivers.
8590

‎sound/core/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ config SND_SEQ_DUMMY
4444
will be called snd-seq-dummy.
4545

4646
config SND_OSSEMUL
47+
select SOUND_OSS_CORE
4748
bool
4849

4950
config SND_MIXER_OSS

‎sound/oss/dmasound/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ config DMASOUND_Q40
4242

4343
config DMASOUND
4444
tristate
45+
select SOUND_OSS_CORE

‎sound/sound_core.c‎

Lines changed: 60 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,61 @@
11
/*
2-
* Sound core handling. Breaks out sound functions to submodules
2+
* Sound core. This file is composed of two parts. sound_class
3+
* which is common to both OSS and ALSA and OSS sound core which
4+
* is used OSS or emulation of it.
5+
*/
6+
7+
/*
8+
* First, the common part.
9+
*/
10+
#include <linux/module.h>
11+
#include <linux/device.h>
12+
#include <linux/err.h>
13+
14+
#ifdef CONFIG_SOUND_OSS_CORE
15+
static int __init init_oss_soundcore(void);
16+
static void __exit cleanup_oss_soundcore(void);
17+
#else
18+
static inline int init_oss_soundcore(void) { return 0; }
19+
static inline void cleanup_oss_soundcore(void) { }
20+
#endif
21+
22+
struct class *sound_class;
23+
EXPORT_SYMBOL(sound_class);
24+
25+
MODULE_DESCRIPTION("Core sound module");
26+
MODULE_AUTHOR("Alan Cox");
27+
MODULE_LICENSE("GPL");
28+
29+
static int __init init_soundcore(void)
30+
{
31+
int rc;
32+
33+
rc = init_oss_soundcore();
34+
if (rc)
35+
return rc;
36+
37+
sound_class = class_create(THIS_MODULE, "sound");
38+
if (IS_ERR(sound_class)) {
39+
cleanup_oss_soundcore();
40+
return PTR_ERR(sound_class);
41+
}
42+
43+
return 0;
44+
}
45+
46+
static void __exit cleanup_soundcore(void)
47+
{
48+
cleanup_oss_soundcore();
49+
class_destroy(sound_class);
50+
}
51+
52+
module_init(init_soundcore);
53+
module_exit(cleanup_soundcore);
54+
55+
56+
#ifdef CONFIG_SOUND_OSS_CORE
57+
/*
58+
* OSS sound core handling. Breaks out sound functions to submodules
359
*
460
* Author: Alan Cox <alan.cox@linux.org>
561
*
@@ -34,21 +90,17 @@
3490
* locking at some point in 2.3.x.
3591
*/
3692

37-
#include <linux/module.h>
3893
#include <linux/init.h>
3994
#include <linux/slab.h>
4095
#include <linux/smp_lock.h>
4196
#include <linux/types.h>
4297
#include <linux/kernel.h>
43-
#include <linux/fs.h>
4498
#include <linux/sound.h>
4599
#include <linux/major.h>
46100
#include <linux/kmod.h>
47-
#include <linux/device.h>
48101

49102
#define SOUND_STEP 16
50103

51-
52104
struct sound_unit
53105
{
54106
int unit_minor;
@@ -64,9 +116,6 @@ extern int msnd_classic_init(void);
64116
extern int msnd_pinnacle_init(void);
65117
#endif
66118

67-
struct class *sound_class;
68-
EXPORT_SYMBOL(sound_class);
69-
70119
/*
71120
* Low level list operator. Scan the ordered list, find a hole and
72121
* join into it. Called with the lock asserted
@@ -523,31 +572,23 @@ int soundcore_open(struct inode *inode, struct file *file)
523572
return -ENODEV;
524573
}
525574

526-
MODULE_DESCRIPTION("Core sound module");
527-
MODULE_AUTHOR("Alan Cox");
528-
MODULE_LICENSE("GPL");
529575
MODULE_ALIAS_CHARDEV_MAJOR(SOUND_MAJOR);
530576

531-
static void __exit cleanup_soundcore(void)
577+
static void __exit cleanup_oss_soundcore(void)
532578
{
533579
/* We have nothing to really do here - we know the lists must be
534580
empty */
535581
unregister_chrdev(SOUND_MAJOR, "sound");
536-
class_destroy(sound_class);
537582
}
538583

539-
static int __init init_soundcore(void)
584+
static int __init init_oss_soundcore(void)
540585
{
541586
if (register_chrdev(SOUND_MAJOR, "sound", &soundcore_fops)==-1) {
542587
printk(KERN_ERR "soundcore: sound device already in use.\n");
543588
return -EBUSY;
544589
}
545-
sound_class = class_create(THIS_MODULE, "sound");
546-
if (IS_ERR(sound_class))
547-
return PTR_ERR(sound_class);
548590

549591
return 0;
550592
}
551593

552-
module_init(init_soundcore);
553-
module_exit(cleanup_soundcore);
594+
#endif /* CONFIG_SOUND_OSS_CORE */

0 commit comments

Comments
 (0)