#include <sound/driver.h>
#include <linux/threads.h>
#include <linux/interrupt.h>
+#include <linux/smp_lock.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/time.h>
err = -EFAULT;
goto __error2;
}
- ctl = snd_magic_kcalloc(snd_ctl_file_t, 0, GFP_KERNEL);
+ ctl = kcalloc(1, sizeof(*ctl), GFP_KERNEL);
if (ctl == NULL) {
err = -ENOMEM;
goto __error;
snd_kcontrol_t *control;
unsigned int idx;
- ctl = snd_magic_cast(snd_ctl_file_t, file->private_data, return -ENXIO);
+ ctl = file->private_data;
fasync_helper(-1, file, 0, &ctl->fasync);
file->private_data = NULL;
card = ctl->card;
}
up_write(&card->controls_rwsem);
snd_ctl_empty_read_queue(ctl);
- snd_magic_kfree(ctl);
+ kfree(ctl);
module_put(card->module);
snd_card_file_remove(card, file);
return 0;
goto _found;
}
}
- ev = snd_kcalloc(sizeof(*ev), GFP_ATOMIC);
+ ev = kcalloc(1, sizeof(*ev), GFP_ATOMIC);
if (ev) {
ev->id = *id;
ev->mask = mask;
snd_runtime_check(control != NULL, return NULL);
snd_runtime_check(control->count > 0, return NULL);
- kctl = (snd_kcontrol_t *)snd_magic_kcalloc(snd_kcontrol_t,
- sizeof(snd_kcontrol_volatile_t) * control->count,
- GFP_KERNEL);
+ kctl = kcalloc(1, sizeof(*kctl) + sizeof(snd_kcontrol_volatile_t) * control->count, GFP_KERNEL);
if (kctl == NULL)
return NULL;
*kctl = *control;
if (kcontrol) {
if (kcontrol->private_free)
kcontrol->private_free(kcontrol);
- snd_magic_kfree(kcontrol);
+ kfree(kcontrol);
}
}
if (!(info.access & SNDRV_CTL_ELEM_ACCESS_DINDIRECT))
for (idx = 0; idx < 4 && info.dimen.d[idx]; idx++)
dimen_size += sizeof(unsigned short);
- ue = snd_kcalloc(sizeof(struct user_element) + dimen_size + private_size + extra_size, GFP_KERNEL);
+ ue = kcalloc(1, sizeof(struct user_element) + dimen_size + private_size + extra_size, GFP_KERNEL);
if (ue == NULL)
return -ENOMEM;
ue->type = info.type;
}
#endif
-static int snd_ctl_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+static inline int _snd_ctl_ioctl(struct inode *inode, struct file *file,
+ unsigned int cmd, unsigned long arg)
{
snd_ctl_file_t *ctl;
snd_card_t *card;
int __user *ip = argp;
int err;
- ctl = snd_magic_cast(snd_ctl_file_t, file->private_data, return -ENXIO);
+ ctl = file->private_data;
card = ctl->card;
snd_assert(card != NULL, return -ENXIO);
switch (cmd) {
return -ENOTTY;
}
+/* FIXME: need to unlock BKL to allow preemption */
+static int snd_ctl_ioctl(struct inode *inode, struct file *file,
+ unsigned int cmd, unsigned long arg)
+{
+ int err;
+ unlock_kernel();
+ err = _snd_ctl_ioctl(inode, file, cmd, arg);
+ lock_kernel();
+ return err;
+}
+
static ssize_t snd_ctl_read(struct file *file, char __user *buffer, size_t count, loff_t * offset)
{
snd_ctl_file_t *ctl;
int err = 0;
ssize_t result = 0;
- ctl = snd_magic_cast(snd_ctl_file_t, file->private_data, return -ENXIO);
+ ctl = file->private_data;
snd_assert(ctl != NULL && ctl->card != NULL, return -ENXIO);
if (!ctl->subscribed)
return -EBADFD;
wait_queue_t wait;
if ((file->f_flags & O_NONBLOCK) != 0 || result > 0) {
err = -EAGAIN;
- goto __end;
+ goto __end_lock;
}
init_waitqueue_entry(&wait, current);
add_wait_queue(&ctl->change_sleep, &wait);
kfree(kev);
if (copy_to_user(buffer, &ev, sizeof(snd_ctl_event_t))) {
err = -EFAULT;
- goto out;
+ goto __end;
}
spin_lock_irq(&ctl->read_lock);
buffer += sizeof(snd_ctl_event_t);
count -= sizeof(snd_ctl_event_t);
result += sizeof(snd_ctl_event_t);
}
-__end:
+ __end_lock:
spin_unlock_irq(&ctl->read_lock);
-out:
+ __end:
return result > 0 ? result : err;
}
unsigned int mask;
snd_ctl_file_t *ctl;
- ctl = snd_magic_cast(snd_ctl_file_t, file->private_data, return 0);
+ ctl = file->private_data;
if (!ctl->subscribed)
return 0;
poll_wait(file, &ctl->change_sleep, wait);
{
snd_kctl_ioctl_t *pn;
- pn = (snd_kctl_ioctl_t *)
- snd_kcalloc(sizeof(snd_kctl_ioctl_t), GFP_KERNEL);
+ pn = kcalloc(1, sizeof(snd_kctl_ioctl_t), GFP_KERNEL);
if (pn == NULL)
return -ENOMEM;
pn->fioctl = fcn;
{
snd_ctl_file_t *ctl;
int err;
- ctl = snd_magic_cast(snd_ctl_file_t, file->private_data, return -ENXIO);
+ ctl = file->private_data;
err = fasync_helper(fd, file, on, &ctl->fasync);
if (err < 0)
return err;