X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=sound%2Fsound_core.c;h=2b302bbffe7361c6faccc1eb84099f2e1c5b1baf;hb=e32740d9786b8a6c54f6e3d670567d9ef57b3b8c;hp=1b04259a4328486357059acfd892bb3015285203;hpb=89409211ff97bf82295d1fb98ab18302a03e9199;p=safe%2Fjmp%2Flinux-2.6 diff --git a/sound/sound_core.c b/sound/sound_core.c index 1b04259..2b302bb 100644 --- a/sound/sound_core.c +++ b/sound/sound_core.c @@ -1,7 +1,64 @@ /* - * Sound core handling. Breaks out sound functions to submodules + * Sound core. This file is composed of two parts. sound_class + * which is common to both OSS and ALSA and OSS sound core which + * is used OSS or emulation of it. + */ + +/* + * First, the common part. + */ +#include +#include +#include +#include + +#ifdef CONFIG_SOUND_OSS_CORE +static int __init init_oss_soundcore(void); +static void cleanup_oss_soundcore(void); +#else +static inline int init_oss_soundcore(void) { return 0; } +static inline void cleanup_oss_soundcore(void) { } +#endif + +struct class *sound_class; +EXPORT_SYMBOL(sound_class); + +MODULE_DESCRIPTION("Core sound module"); +MODULE_AUTHOR("Alan Cox"); +MODULE_LICENSE("GPL"); + +static int __init init_soundcore(void) +{ + int rc; + + rc = init_oss_soundcore(); + if (rc) + return rc; + + sound_class = class_create(THIS_MODULE, "sound"); + if (IS_ERR(sound_class)) { + cleanup_oss_soundcore(); + return PTR_ERR(sound_class); + } + + return 0; +} + +static void __exit cleanup_soundcore(void) +{ + cleanup_oss_soundcore(); + class_destroy(sound_class); +} + +module_init(init_soundcore); +module_exit(cleanup_soundcore); + + +#ifdef CONFIG_SOUND_OSS_CORE +/* + * OSS sound core handling. Breaks out sound functions to submodules * - * Author: Alan Cox + * Author: Alan Cox * * Fixes: * @@ -34,21 +91,17 @@ * locking at some point in 2.3.x. */ -#include #include #include #include #include #include -#include #include #include #include -#include #define SOUND_STEP 16 - struct sound_unit { int unit_minor; @@ -64,9 +117,6 @@ extern int msnd_classic_init(void); extern int msnd_pinnacle_init(void); #endif -struct class *sound_class; -EXPORT_SYMBOL(sound_class); - /* * Low level list operator. Scan the ordered list, find a hole and * join into it. Called with the lock asserted @@ -171,9 +221,8 @@ static int sound_insert_unit(struct sound_unit **list, const struct file_operati else sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP); - device_create_drvdata(sound_class, dev, - MKDEV(SOUND_MAJOR, s->unit_minor), - NULL, s->name+6); + device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor), + NULL, s->name+6); return r; fail: @@ -409,7 +458,7 @@ EXPORT_SYMBOL(unregister_sound_mixer); void unregister_sound_midi(int unit) { - return sound_remove_unit(&chains[2], unit); + sound_remove_unit(&chains[2], unit); } EXPORT_SYMBOL(unregister_sound_midi); @@ -426,7 +475,7 @@ EXPORT_SYMBOL(unregister_sound_midi); void unregister_sound_dsp(int unit) { - return sound_remove_unit(&chains[3], unit); + sound_remove_unit(&chains[3], unit); } @@ -459,7 +508,7 @@ static struct sound_unit *__look_for_unit(int chain, int unit) return NULL; } -int soundcore_open(struct inode *inode, struct file *file) +static int soundcore_open(struct inode *inode, struct file *file) { int chain; int unit = iminor(inode); @@ -523,31 +572,23 @@ int soundcore_open(struct inode *inode, struct file *file) return -ENODEV; } -MODULE_DESCRIPTION("Core sound module"); -MODULE_AUTHOR("Alan Cox"); -MODULE_LICENSE("GPL"); MODULE_ALIAS_CHARDEV_MAJOR(SOUND_MAJOR); -static void __exit cleanup_soundcore(void) +static void cleanup_oss_soundcore(void) { /* We have nothing to really do here - we know the lists must be empty */ unregister_chrdev(SOUND_MAJOR, "sound"); - class_destroy(sound_class); } -static int __init init_soundcore(void) +static int __init init_oss_soundcore(void) { if (register_chrdev(SOUND_MAJOR, "sound", &soundcore_fops)==-1) { printk(KERN_ERR "soundcore: sound device already in use.\n"); return -EBUSY; } - sound_class = class_create(THIS_MODULE, "sound"); - if (IS_ERR(sound_class)) - return PTR_ERR(sound_class); return 0; } -module_init(init_soundcore); -module_exit(cleanup_soundcore); +#endif /* CONFIG_SOUND_OSS_CORE */