mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-17 01:04:19 +08:00
5a0e3ad6af
percpu.h is included by sched.h and module.h and thus ends up being included when building most .c files. percpu.h includes slab.h which in turn includes gfp.h making everything defined by the two files universally available and complicating inclusion dependencies. percpu.h -> slab.h dependency is about to be removed. Prepare for this change by updating users of gfp and slab facilities include those headers directly instead of assuming availability. As this conversion needs to touch large number of source files, the following script is used as the basis of conversion. http://userweb.kernel.org/~tj/misc/slabh-sweep.py The script does the followings. * Scan files for gfp and slab usages and update includes such that only the necessary includes are there. ie. if only gfp is used, gfp.h, if slab is used, slab.h. * When the script inserts a new include, it looks at the include blocks and try to put the new include such that its order conforms to its surrounding. It's put in the include block which contains core kernel includes, in the same order that the rest are ordered - alphabetical, Christmas tree, rev-Xmas-tree or at the end if there doesn't seem to be any matching order. * If the script can't find a place to put a new include (mostly because the file doesn't have fitting include block), it prints out an error message indicating which .h file needs to be added to the file. The conversion was done in the following steps. 1. The initial automatic conversion of all .c files updated slightly over 4000 files, deleting around 700 includes and adding ~480 gfp.h and ~3000 slab.h inclusions. The script emitted errors for ~400 files. 2. Each error was manually checked. Some didn't need the inclusion, some needed manual addition while adding it to implementation .h or embedding .c file was more appropriate for others. This step added inclusions to around 150 files. 3. The script was run again and the output was compared to the edits from #2 to make sure no file was left behind. 4. Several build tests were done and a couple of problems were fixed. e.g. lib/decompress_*.c used malloc/free() wrappers around slab APIs requiring slab.h to be added manually. 5. The script was run on all .h files but without automatically editing them as sprinkling gfp.h and slab.h inclusions around .h files could easily lead to inclusion dependency hell. Most gfp.h inclusion directives were ignored as stuff from gfp.h was usually wildly available and often used in preprocessor macros. Each slab.h inclusion directive was examined and added manually as necessary. 6. percpu.h was updated not to include slab.h. 7. Build test were done on the following configurations and failures were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my distributed build env didn't work with gcov compiles) and a few more options had to be turned off depending on archs to make things build (like ipr on powerpc/64 which failed due to missing writeq). * x86 and x86_64 UP and SMP allmodconfig and a custom test config. * powerpc and powerpc64 SMP allmodconfig * sparc and sparc64 SMP allmodconfig * ia64 SMP allmodconfig * s390 SMP allmodconfig * alpha SMP allmodconfig * um on x86_64 SMP allmodconfig 8. percpu.h modifications were reverted so that it could be applied as a separate patch and serve as bisection point. Given the fact that I had only a couple of failures from tests on step 6, I'm fairly confident about the coverage of this conversion patch. If there is a breakage, it's likely to be something in one of the arch headers which should be easily discoverable easily on most builds of the specific arch. Signed-off-by: Tejun Heo <tj@kernel.org> Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
207 lines
4.3 KiB
C
207 lines
4.3 KiB
C
/*
|
|
* sound/oss/sb_midi.c
|
|
*
|
|
* The low level driver for the Sound Blaster DS chips.
|
|
*
|
|
*
|
|
* Copyright (C) by Hannu Savolainen 1993-1997
|
|
*
|
|
* OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
|
|
* Version 2 (June 1991). See the "COPYING" file distributed with this software
|
|
* for more info.
|
|
*/
|
|
|
|
#include <linux/spinlock.h>
|
|
#include <linux/slab.h>
|
|
|
|
#include "sound_config.h"
|
|
|
|
#include "sb.h"
|
|
#undef SB_TEST_IRQ
|
|
|
|
/*
|
|
* The DSP channel can be used either for input or output. Variable
|
|
* 'sb_irq_mode' will be set when the program calls read or write first time
|
|
* after open. Current version doesn't support mode changes without closing
|
|
* and reopening the device. Support for this feature may be implemented in a
|
|
* future version of this driver.
|
|
*/
|
|
|
|
|
|
static int sb_midi_open(int dev, int mode,
|
|
void (*input) (int dev, unsigned char data),
|
|
void (*output) (int dev)
|
|
)
|
|
{
|
|
sb_devc *devc = midi_devs[dev]->devc;
|
|
unsigned long flags;
|
|
|
|
if (devc == NULL)
|
|
return -ENXIO;
|
|
|
|
spin_lock_irqsave(&devc->lock, flags);
|
|
if (devc->opened)
|
|
{
|
|
spin_unlock_irqrestore(&devc->lock, flags);
|
|
return -EBUSY;
|
|
}
|
|
devc->opened = 1;
|
|
spin_unlock_irqrestore(&devc->lock, flags);
|
|
|
|
devc->irq_mode = IMODE_MIDI;
|
|
devc->midi_broken = 0;
|
|
|
|
sb_dsp_reset(devc);
|
|
|
|
if (!sb_dsp_command(devc, 0x35)) /* Start MIDI UART mode */
|
|
{
|
|
devc->opened = 0;
|
|
return -EIO;
|
|
}
|
|
devc->intr_active = 1;
|
|
|
|
if (mode & OPEN_READ)
|
|
{
|
|
devc->input_opened = 1;
|
|
devc->midi_input_intr = input;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static void sb_midi_close(int dev)
|
|
{
|
|
sb_devc *devc = midi_devs[dev]->devc;
|
|
unsigned long flags;
|
|
|
|
if (devc == NULL)
|
|
return;
|
|
|
|
spin_lock_irqsave(&devc->lock, flags);
|
|
sb_dsp_reset(devc);
|
|
devc->intr_active = 0;
|
|
devc->input_opened = 0;
|
|
devc->opened = 0;
|
|
spin_unlock_irqrestore(&devc->lock, flags);
|
|
}
|
|
|
|
static int sb_midi_out(int dev, unsigned char midi_byte)
|
|
{
|
|
sb_devc *devc = midi_devs[dev]->devc;
|
|
|
|
if (devc == NULL)
|
|
return 1;
|
|
|
|
if (devc->midi_broken)
|
|
return 1;
|
|
|
|
if (!sb_dsp_command(devc, midi_byte))
|
|
{
|
|
devc->midi_broken = 1;
|
|
return 1;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
static int sb_midi_start_read(int dev)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static int sb_midi_end_read(int dev)
|
|
{
|
|
sb_devc *devc = midi_devs[dev]->devc;
|
|
|
|
if (devc == NULL)
|
|
return -ENXIO;
|
|
|
|
sb_dsp_reset(devc);
|
|
devc->intr_active = 0;
|
|
return 0;
|
|
}
|
|
|
|
static int sb_midi_ioctl(int dev, unsigned cmd, void __user *arg)
|
|
{
|
|
return -EINVAL;
|
|
}
|
|
|
|
void sb_midi_interrupt(sb_devc * devc)
|
|
{
|
|
unsigned long flags;
|
|
unsigned char data;
|
|
|
|
if (devc == NULL)
|
|
return;
|
|
|
|
spin_lock_irqsave(&devc->lock, flags);
|
|
|
|
data = inb(DSP_READ);
|
|
if (devc->input_opened)
|
|
devc->midi_input_intr(devc->my_mididev, data);
|
|
|
|
spin_unlock_irqrestore(&devc->lock, flags);
|
|
}
|
|
|
|
#define MIDI_SYNTH_NAME "Sound Blaster Midi"
|
|
#define MIDI_SYNTH_CAPS 0
|
|
#include "midi_synth.h"
|
|
|
|
static struct midi_operations sb_midi_operations =
|
|
{
|
|
.owner = THIS_MODULE,
|
|
.info = {"Sound Blaster", 0, 0, SNDCARD_SB},
|
|
.converter = &std_midi_synth,
|
|
.in_info = {0},
|
|
.open = sb_midi_open,
|
|
.close = sb_midi_close,
|
|
.ioctl = sb_midi_ioctl,
|
|
.outputc = sb_midi_out,
|
|
.start_read = sb_midi_start_read,
|
|
.end_read = sb_midi_end_read,
|
|
};
|
|
|
|
void sb_dsp_midi_init(sb_devc * devc, struct module *owner)
|
|
{
|
|
int dev;
|
|
|
|
if (devc->model < 2) /* No MIDI support for SB 1.x */
|
|
return;
|
|
|
|
dev = sound_alloc_mididev();
|
|
|
|
if (dev == -1)
|
|
{
|
|
printk(KERN_ERR "sb_midi: too many MIDI devices detected\n");
|
|
return;
|
|
}
|
|
std_midi_synth.midi_dev = devc->my_mididev = dev;
|
|
midi_devs[dev] = kmalloc(sizeof(struct midi_operations), GFP_KERNEL);
|
|
if (midi_devs[dev] == NULL)
|
|
{
|
|
printk(KERN_WARNING "Sound Blaster: failed to allocate MIDI memory.\n");
|
|
sound_unload_mididev(dev);
|
|
return;
|
|
}
|
|
memcpy((char *) midi_devs[dev], (char *) &sb_midi_operations,
|
|
sizeof(struct midi_operations));
|
|
|
|
if (owner)
|
|
midi_devs[dev]->owner = owner;
|
|
|
|
midi_devs[dev]->devc = devc;
|
|
|
|
|
|
midi_devs[dev]->converter = kmalloc(sizeof(struct synth_operations), GFP_KERNEL);
|
|
if (midi_devs[dev]->converter == NULL)
|
|
{
|
|
printk(KERN_WARNING "Sound Blaster: failed to allocate MIDI memory.\n");
|
|
kfree(midi_devs[dev]);
|
|
sound_unload_mididev(dev);
|
|
return;
|
|
}
|
|
memcpy((char *) midi_devs[dev]->converter, (char *) &std_midi_synth,
|
|
sizeof(struct synth_operations));
|
|
|
|
midi_devs[dev]->converter->id = "SBMIDI";
|
|
sequencer_init();
|
|
}
|