summaryrefslogtreecommitdiffstats
path: root/sound/oss/emu10k1/midi.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/oss/emu10k1/midi.c')
-rw-r--r--sound/oss/emu10k1/midi.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/sound/oss/emu10k1/midi.c b/sound/oss/emu10k1/midi.c
index b40b5f97aac..25ae8e4a488 100644
--- a/sound/oss/emu10k1/midi.c
+++ b/sound/oss/emu10k1/midi.c
@@ -65,7 +65,8 @@ static int midiin_add_buffer(struct emu10k1_mididevice *midi_dev, struct midi_hd
init_midi_hdr(midihdr);
- if ((midihdr->data = (u8 *) kmalloc(MIDIIN_BUFLEN, GFP_KERNEL)) == NULL) {
+ midihdr->data = kmalloc(MIDIIN_BUFLEN, GFP_KERNEL);
+ if (!midihdr->data) {
ERROR();
kfree(midihdr);
return -1;
@@ -110,21 +111,21 @@ match:
#endif
/* Wait for device to become free */
- down(&card->open_sem);
+ mutex_lock(&card->open_sem);
while (card->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) {
if (file->f_flags & O_NONBLOCK) {
- up(&card->open_sem);
+ mutex_unlock(&card->open_sem);
return -EBUSY;
}
- up(&card->open_sem);
+ mutex_unlock(&card->open_sem);
interruptible_sleep_on(&card->open_wait);
if (signal_pending(current)) {
return -ERESTARTSYS;
}
- down(&card->open_sem);
+ mutex_lock(&card->open_sem);
}
if ((midi_dev = (struct emu10k1_mididevice *) kmalloc(sizeof(*midi_dev), GFP_KERNEL)) == NULL)
@@ -183,7 +184,7 @@ match:
card->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE);
- up(&card->open_sem);
+ mutex_unlock(&card->open_sem);
return nonseekable_open(inode, file);
}
@@ -234,9 +235,9 @@ static int emu10k1_midi_release(struct inode *inode, struct file *file)
kfree(midi_dev);
- down(&card->open_sem);
+ mutex_lock(&card->open_sem);
card->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE));
- up(&card->open_sem);
+ mutex_unlock(&card->open_sem);
wake_up_interruptible(&card->open_wait);
unlock_kernel();
@@ -334,7 +335,8 @@ static ssize_t emu10k1_midi_write(struct file *file, const char __user *buffer,
midihdr->bytesrecorded = 0;
midihdr->flags = 0;
- if ((midihdr->data = (u8 *) kmalloc(count, GFP_KERNEL)) == NULL) {
+ midihdr->data = kmalloc(count, GFP_KERNEL);
+ if (!midihdr->data) {
ERROR();
kfree(midihdr);
return -EINVAL;
@@ -545,7 +547,8 @@ int emu10k1_seq_midi_out(int dev, unsigned char midi_byte)
midihdr->bytesrecorded = 0;
midihdr->flags = 0;
- if ((midihdr->data = (u8 *) kmalloc(1, GFP_KERNEL)) == NULL) {
+ midihdr->data = kmalloc(1, GFP_KERNEL);
+ if (!midihdr->data) {
ERROR();
kfree(midihdr);
return -EINVAL;