X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fcore%2Fhwdep.c;h=cbd8eba6a35aea801820011ad29b70b2781893fd;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=d18e4769d1aa1d909f69240a3a505dcfad394dce;hpb=9213980e6a70d8473e0ffd4b39ab5b6caaba9ff5;p=linux-2.6.git diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index d18e4769d..cbd8eba6a 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -34,7 +35,7 @@ MODULE_AUTHOR("Jaroslav Kysela "); MODULE_DESCRIPTION("Hardware dependent layer"); MODULE_LICENSE("GPL"); -snd_hwdep_t *snd_hwdep_devices[SNDRV_CARDS * SNDRV_MINOR_HWDEPS]; +static snd_hwdep_t *snd_hwdep_devices[SNDRV_CARDS * SNDRV_MINOR_HWDEPS]; static DECLARE_MUTEX(register_mutex); @@ -49,7 +50,7 @@ static int snd_hwdep_dev_unregister(snd_device_t *device); 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; @@ -57,7 +58,7 @@ static loff_t snd_hwdep_llseek(struct file * file, loff_t offset, int orig) 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; @@ -65,7 +66,7 @@ static ssize_t snd_hwdep_read(struct file * file, char __user *buf, size_t count 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; @@ -157,7 +158,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file) 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); @@ -173,7 +174,7 @@ static int snd_hwdep_release(struct inode *inode, struct file * 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; @@ -231,10 +232,10 @@ static int snd_hwdep_dsp_load(snd_hwdep_t *hw, snd_hwdep_dsp_image_t __user *_in 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: @@ -251,9 +252,20 @@ static int snd_hwdep_ioctl(struct inode *inode, struct file * file, 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; @@ -352,7 +364,7 @@ int snd_hwdep_new(snd_card_t * card, char *id, int device, snd_hwdep_t ** rhwdep 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; @@ -378,19 +390,19 @@ static int snd_hwdep_free(snd_hwdep_t *hwdep) 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]; @@ -433,7 +445,7 @@ static int snd_hwdep_dev_register(snd_device_t *device) 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);