#include <sound/driver.h>
#include <linux/major.h>
#include <linux/init.h>
+#include <linux/smp_lock.h>
#include <linux/slab.h>
#include <linux/time.h>
#include <sound/core.h>
static loff_t snd_hwdep_llseek(struct file * file, loff_t offset, int orig)
{
- snd_hwdep_t *hw = snd_magic_cast(snd_hwdep_t, file->private_data, return -ENXIO);
+ snd_hwdep_t *hw = file->private_data;
if (hw->ops.llseek)
return hw->ops.llseek(hw, file, offset, orig);
return -ENXIO;
static ssize_t snd_hwdep_read(struct file * file, char __user *buf, size_t count, loff_t *offset)
{
- snd_hwdep_t *hw = snd_magic_cast(snd_hwdep_t, file->private_data, return -ENXIO);
+ snd_hwdep_t *hw = file->private_data;
if (hw->ops.read)
return hw->ops.read(hw, buf, count, offset);
return -ENXIO;
static ssize_t snd_hwdep_write(struct file * file, const char __user *buf, size_t count, loff_t *offset)
{
- snd_hwdep_t *hw = snd_magic_cast(snd_hwdep_t, file->private_data, return -ENXIO);
+ snd_hwdep_t *hw = file->private_data;
if (hw->ops.write)
return hw->ops.write(hw, buf, count, offset);
return -ENXIO;
static int snd_hwdep_release(struct inode *inode, struct file * file)
{
int err = -ENXIO;
- snd_hwdep_t *hw = snd_magic_cast(snd_hwdep_t, file->private_data, return -ENXIO);
+ snd_hwdep_t *hw = file->private_data;
down(&hw->open_mutex);
if (hw->ops.release) {
err = hw->ops.release(hw, file);
static unsigned int snd_hwdep_poll(struct file * file, poll_table * wait)
{
- snd_hwdep_t *hw = snd_magic_cast(snd_hwdep_t, file->private_data, return 0);
+ snd_hwdep_t *hw = file->private_data;
if (hw->ops.poll)
return hw->ops.poll(hw, file, wait);
return 0;
return 0;
}
-static int snd_hwdep_ioctl(struct inode *inode, struct file * file,
- unsigned int cmd, unsigned long arg)
+static inline int _snd_hwdep_ioctl(struct inode *inode, struct file * file,
+ unsigned int cmd, unsigned long arg)
{
- snd_hwdep_t *hw = snd_magic_cast(snd_hwdep_t, file->private_data, return -ENXIO);
+ snd_hwdep_t *hw = file->private_data;
void __user *argp = (void __user *)arg;
switch (cmd) {
case SNDRV_HWDEP_IOCTL_PVERSION:
return -ENOTTY;
}
+/* FIXME: need to unlock BKL to allow preemption */
+static int snd_hwdep_ioctl(struct inode *inode, struct file * file,
+ unsigned int cmd, unsigned long arg)
+{
+ int err;
+ unlock_kernel();
+ err = _snd_hwdep_ioctl(inode, file, cmd, arg);
+ lock_kernel();
+ return err;
+}
+
static int snd_hwdep_mmap(struct file * file, struct vm_area_struct * vma)
{
- snd_hwdep_t *hw = snd_magic_cast(snd_hwdep_t, file->private_data, return -ENXIO);
+ snd_hwdep_t *hw = file->private_data;
if (hw->ops.mmap)
return hw->ops.mmap(hw, file, vma);
return -ENXIO;
snd_assert(rhwdep != NULL, return -EINVAL);
*rhwdep = NULL;
snd_assert(card != NULL, return -ENXIO);
- hwdep = snd_magic_kcalloc(snd_hwdep_t, 0, GFP_KERNEL);
+ hwdep = kcalloc(1, sizeof(*hwdep), GFP_KERNEL);
if (hwdep == NULL)
return -ENOMEM;
hwdep->card = card;
snd_assert(hwdep != NULL, return -ENXIO);
if (hwdep->private_free)
hwdep->private_free(hwdep);
- snd_magic_kfree(hwdep);
+ kfree(hwdep);
return 0;
}
static int snd_hwdep_dev_free(snd_device_t *device)
{
- snd_hwdep_t *hwdep = snd_magic_cast(snd_hwdep_t, device->device_data, return -ENXIO);
+ snd_hwdep_t *hwdep = device->device_data;
return snd_hwdep_free(hwdep);
}
static int snd_hwdep_dev_register(snd_device_t *device)
{
- snd_hwdep_t *hwdep = snd_magic_cast(snd_hwdep_t, device->device_data, return -ENXIO);
+ snd_hwdep_t *hwdep = device->device_data;
int idx, err;
char name[32];
static int snd_hwdep_dev_unregister(snd_device_t *device)
{
- snd_hwdep_t *hwdep = snd_magic_cast(snd_hwdep_t, device->device_data, return -ENXIO);
+ snd_hwdep_t *hwdep = device->device_data;
int idx;
snd_assert(hwdep != NULL, return -ENXIO);