Conversion to compat_ioctl for ALSA drivers
cover Conversion to compat_ioctl for ALSA drivers
Hi,
the following three patches convert the 32bit ioctl layer of ALSA to the new compat_ioctl (and unlocked_ioctl for native ioctls).
The first patch covers the basic entries and control API. The second patch is for PCM API.
The last one is for other APIs including OSS-emulation modules.
After these patches are applied, remove the whole subtree in sound/core/ioctl32. The files in this directory are no longer necessary.
Takashi
PATCH 1/3 Conversion to compat_ioctl for ALSA drivers
This patch modifies Kconfig and Makefile to remove snd-ioctl32. It convers to unlocked_ioctl, and adds the compat_ioctl entries. New register/unregister functions for compat ioctl are added.
sound/core/Kconfig +0 -14
@@ -81,20 +81,6 @@ To compile this driver as a module, choose M here: the module will be called snd-seq-oss. -config SND_BIT32_EMUL - tristate "Emulation for 32-bit applications" - depends on SND && COMPAT - select SND_PCM - select SND_RAWMIDI - select SND_TIMER - select SND_HWDEP - help - Say Y here to enable the emulation for 32-bit ALSA-native - applications. - - To compile this driver as a module, choose M here: the module - will be called snd-ioctl32. - config SND_RTCTIMER tristate "RTC Timer support" depends on SND && RTC
sound/core/Makefile +0 -1
@@ -31,4 +31,3 @@ obj-$(CONFIG_SND_OSSEMUL) += oss/ obj-$(CONFIG_SND_SEQUENCER) += seq/ -obj-$(CONFIG_SND_BIT32_EMUL) += ioctl32/
sound/core/control.c +95 -81
346 lines not on this page · raw message
sound/core/control_compat.c new file +412 -0
412 lines not on this page · raw message
sound/core/sound.c +4 -0
@@ -467,6 +467,10 @@EXPORT_SYMBOL (snd_ctl_notify);EXPORT_SYMBOL (snd_ctl_register_ioctl);EXPORT_SYMBOL (snd_ctl_unregister_ioctl); +#ifdef CONFIG_COMPAT +EXPORT_SYMBOL (snd_ctl_register_ioctl_compat); +EXPORT_SYMBOL (snd_ctl_unregister_ioctl_compat); +#endif EXPORT_SYMBOL (snd_ctl_elem_read);EXPORT_SYMBOL (snd_ctl_elem_write);/* misc.c */
include/sound/control.h +7 -0
@@ -119,6 +119,13 @@int snd_ctl_register_ioctl (snd_kctl_ioctl_func_t fcn);int snd_ctl_unregister_ioctl (snd_kctl_ioctl_func_t fcn); +#ifdef CONFIG_COMPAT +int snd_ctl_register_ioctl_compat (snd_kctl_ioctl_func_t fcn); +int snd_ctl_unregister_ioctl_compat (snd_kctl_ioctl_func_t fcn); +#else +#define snd_ctl_register_ioctl_compat (fcn) +#define snd_ctl_unregister_ioctl_compat (fcn) +#endif int snd_ctl_elem_read (snd_card_t *card,snd_ctl_elem_value_t *control);int snd_ctl_elem_write (snd_card_t *card,snd_ctl_file_t *file,snd_ctl_elem_value_t *control);
PATCH 2/3 Conversion to compat_ioctl for ALSA drivers
This patch converts to unlocked_ioctl and adds the compat ioctl layer for ALSA PCM API.
sound/core/pcm.c +2 -0
@@ -1004,6 +1004,7 @@snd_info_entry_t *entry;snd_ctl_register_ioctl (snd_pcm_control_ioctl); +snd_ctl_register_ioctl_compat (snd_pcm_control_ioctl);if ((entry =snd_info_create_module_entry (THIS_MODULE ,"pcm" ,NULL )) !=NULL ) {snd_info_set_text_ops (entry,NULL ,SNDRV_CARDS *SNDRV_PCM_DEVICES *128 , snd_pcm_proc_read);if (snd_info_register (entry) <0 ) {
@@ -1018,6 +1019,7 @@ static void __exit alsa_pcm_exit(void) {snd_ctl_unregister_ioctl (snd_pcm_control_ioctl); +snd_ctl_unregister_ioctl_compat (snd_pcm_control_ioctl);if (snd_pcm_proc_entry) {snd_info_unregister (snd_pcm_proc_entry); snd_pcm_proc_entry =NULL ;
sound/core/pcm_compat.c new file +513 -0
513 lines not on this page · raw message
sound/core/pcm_native.c +18 -19
@@ -65,7 +65,7 @@* */ -rwlock_t snd_pcm_link_rwlock =RW_LOCK_UNLOCKED ; +DEFINE_RWLOCK (snd_pcm_link_rwlock);static DECLARE_RWSEM (snd_pcm_link_rwsem);
@@ -2640,40 +2640,28 @@return snd_pcm_common_ioctl1 (substream, cmd, arg); } -static int snd_pcm_playback_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) +static long snd_pcm_playback_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {snd_pcm_file_t *pcm_file; -int err; pcm_file = file->private_data;if (((cmd >>8 ) &0xff ) !='A' )return -ENOTTY ; -/* FIXME: need to unlock BKL to allow preemption */ -unlock_kernel (); - err =snd_pcm_playback_ioctl1 (pcm_file->substream, cmd, (void __user *)arg); -lock_kernel (); -return err; +return snd_pcm_playback_ioctl1 (pcm_file->substream, cmd, (void __user *)arg); } -static int snd_pcm_capture_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) +static long snd_pcm_capture_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {snd_pcm_file_t *pcm_file; -int err; pcm_file = file->private_data;if (((cmd >>8 ) &0xff ) !='A' )return -ENOTTY ; -/* FIXME: need to unlock BKL to allow preemption */ -unlock_kernel (); - err =snd_pcm_capture_ioctl1 (pcm_file->substream, cmd, (void __user *)arg); -lock_kernel (); -return err; +return snd_pcm_capture_ioctl1 (pcm_file->substream, cmd, (void __user *)arg); } int snd_pcm_kernel_playback_ioctl(snd_pcm_substream_t *substream,
@@ -3198,6 +3186,15 @@ }/* +* ioctl32 compat +*/ +#ifdef CONFIG_COMPAT +#include "pcm_compat.c" +#else +#define snd_pcm_ioctl_compat NULL +#endif + +/* * To be removed helpers to keep binary compatibility */
@@ -3318,7 +3315,8 @@ .open = snd_pcm_open, .release = snd_pcm_release, .poll = snd_pcm_playback_poll, - .ioctl = snd_pcm_playback_ioctl, + .unlocked_ioctl = snd_pcm_playback_ioctl, + .compat_ioctl = snd_pcm_ioctl_compat, .mmap = snd_pcm_mmap, .fasync = snd_pcm_fasync, };
@@ -3330,7 +3328,8 @@ .open = snd_pcm_open, .release = snd_pcm_release, .poll = snd_pcm_capture_poll, - .ioctl = snd_pcm_capture_ioctl, + .unlocked_ioctl = snd_pcm_capture_ioctl, + .compat_ioctl = snd_pcm_ioctl_compat, .mmap = snd_pcm_mmap, .fasync = snd_pcm_fasync, };
PATCH 3/3 Conversion to compat_ioctl for ALSA drivers
The last patch covers the rest of ALSA APIs: hwdep, rawmidi, timer and seq. Also it covers the OSS emulation modules.
sound/core/hwdep.c +11 -14
@@ -232,8 +232,7 @@return 0 ; } -static inline int _snd_hwdep_ioctl (struct inode *inode,struct file * file, -unsigned int cmd,unsigned long arg) +static long snd_hwdep_ioctl (struct file * file,unsigned int cmd,unsigned long arg) {snd_hwdep_t *hw = file->private_data;void __user *argp = (void __user *)arg;
@@ -252,17 +251,6 @@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 = file->private_data;
@@ -315,6 +303,12 @@return -ENOIOCTLCMD ; } +#ifdef CONFIG_COMPAT +#include "hwdep_compat.c" +#else +#define snd_hwdep_ioctl_compat NULL +#endif +/* */
@@ -328,7 +322,8 @@ .open = snd_hwdep_open, .release = snd_hwdep_release, .poll = snd_hwdep_poll, - .ioctl = snd_hwdep_ioctl, + .unlocked_ioctl = snd_hwdep_ioctl, + .compat_ioctl = snd_hwdep_ioctl_compat, .mmap = snd_hwdep_mmap, };
@@ -509,12 +504,14 @@ } snd_hwdep_proc_entry = entry;snd_ctl_register_ioctl (snd_hwdep_control_ioctl); +snd_ctl_register_ioctl_compat (snd_hwdep_control_ioctl);return 0 ; } static void __exit alsa_hwdep_exit(void) {snd_ctl_unregister_ioctl (snd_hwdep_control_ioctl); +snd_ctl_unregister_ioctl_compat (snd_hwdep_control_ioctl);if (snd_hwdep_proc_entry) {snd_info_unregister (snd_hwdep_proc_entry); snd_hwdep_proc_entry =NULL ;
sound/core/hwdep_compat.c new file +77 -0
77 lines not on this page · raw message
sound/core/rawmidi.c +13 -14
@@ -673,8 +673,7 @@return 0 ; } -static inline int _snd_rawmidi_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) +static long snd_rawmidi_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {snd_rawmidi_file_t *rfile;void __user *argp = (void __user *)arg;
@@ -784,17 +783,6 @@return -ENOTTY ; } -/* FIXME: need to unlock BKL to allow preemption */ -static int snd_rawmidi_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) -{ -int err; -unlock_kernel (); - err =_snd_rawmidi_ioctl (inode, file, cmd, arg); -lock_kernel (); -return err; -} - static int snd_rawmidi_control_ioctl(snd_card_t * card, snd_ctl_file_t * control, unsigned int cmd,
@@ -1278,6 +1266,14 @@ }/* +*/ +#ifdef CONFIG_COMPAT +#include "rawmidi_compat.c" +#else +#define snd_rawmidi_ioctl_comapt NULL +#endif + +/* */
@@ -1347,7 +1343,8 @@ .open = snd_rawmidi_open, .release = snd_rawmidi_release, .poll = snd_rawmidi_poll, - .ioctl = snd_rawmidi_ioctl, + .unlocked_ioctl = snd_rawmidi_ioctl, + .compat_ioctl = snd_rawmidi_ioctl_compat, }; static snd_minor_t snd_rawmidi_reg =
@@ -1628,6 +1625,7 @@ {snd_ctl_register_ioctl (snd_rawmidi_control_ioctl); +snd_ctl_register_ioctl_compat (snd_rawmidi_control_ioctl);#ifdef CONFIG_SND_OSSEMUL {int i;/* check device map table */
@@ -1649,6 +1647,7 @@ static void __exit alsa_rawmidi_exit(void) {snd_ctl_unregister_ioctl (snd_rawmidi_control_ioctl); +snd_ctl_unregister_ioctl_compat (snd_rawmidi_control_ioctl); }module_init (alsa_rawmidi_init)
sound/core/rawmidi_compat.c new file +120 -0
120 lines not on this page · raw message
sound/core/timer.c +10 -15
@@ -76,7 +76,7 @@static LIST_HEAD (snd_timer_slave_list);/* lock for slave active lists */ -static spinlock_t slave_active_lock =SPIN_LOCK_UNLOCKED ; +static DEFINE_SPINLOCK (slave_active_lock);static DECLARE_MUTEX (register_mutex);
@@ -1653,8 +1653,7 @@return (err =snd_timer_continue (tu->timeri)) <0 ? err :0 ; } -static inline int _snd_timer_user_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) +static long snd_timer_user_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {snd_timer_user_t *tu;void __user *argp = (void __user *)arg;
@@ -1701,17 +1700,6 @@return -ENOTTY ; } -/* FIXME: need to unlock BKL to allow preemption */ -static int snd_timer_user_ioctl (struct inode *inode,struct file * file, -unsigned int cmd,unsigned long arg) -{ -int err; -unlock_kernel (); - err =_snd_timer_user_ioctl (inode, file, cmd, arg); -lock_kernel (); -return err; -} -static int snd_timer_user_fasync (int fd,struct file * file,int on) {snd_timer_user_t *tu;
@@ -1803,6 +1791,12 @@return mask; } +#ifdef CONFIG_COMPAT +#include "timer_compat.c" +#else +#define snd_timer_user_ioctl_compat NULL +#endif +static struct file_operations snd_timer_f_ops = { .owner =THIS_MODULE ,
@@ -1810,7 +1804,8 @@ .open = snd_timer_user_open, .release = snd_timer_user_release, .poll = snd_timer_user_poll, - .ioctl = snd_timer_user_ioctl, + .unlocked_ioctl = snd_timer_user_ioctl, + .compat_ioctl = snd_timer_user_ioctl_compat, .fasync = snd_timer_user_fasync, };
sound/core/timer_compat.c new file +119 -0
119 lines not on this page · raw message
sound/core/oss/mixer_oss.c +11 -10
@@ -359,16 +359,9 @@return -ENXIO ; } -/* FIXME: need to unlock BKL to allow preemption */ -static int snd_mixer_oss_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) +static long snd_mixer_oss_ioctl (struct file *file,unsigned int cmd,unsigned long arg) { -int err; -/* FIXME: need to unlock BKL to allow preemption */ -unlock_kernel (); - err =snd_mixer_oss_ioctl1 ((snd_mixer_oss_file_t *) file->private_data, cmd, arg); -lock_kernel (); -return err; +return snd_mixer_oss_ioctl1 ((snd_mixer_oss_file_t *) file->private_data, cmd, arg); }int snd_mixer_oss_ioctl_card (snd_card_t *card,unsigned int cmd,unsigned long arg)
@@ -384,6 +377,13 @@return snd_mixer_oss_ioctl1 (&fmixer, cmd, arg); } +#ifdef CONFIG_COMPAT +/* all compatible */ +#define snd_mixer_oss_ioctl_compat snd_mixer_oss_ioctl +#else +#define snd_mixer_oss_ioctl_compat NULL +#endif +/* * REGISTRATION PART */
@@ -393,7 +393,8 @@ .owner = THIS_MODULE, .open = snd_mixer_oss_open, .release = snd_mixer_oss_release, - .ioctl = snd_mixer_oss_ioctl, + .unlocked_ioctl = snd_mixer_oss_ioctl, + .compat_ioctl = snd_mixer_oss_ioctl_compat, }; static snd_minor_t snd_mixer_oss_reg =
sound/core/oss/pcm_oss.c +9 -13
@@ -1913,8 +1913,7 @@return 0 ; } -static inline int _snd_pcm_oss_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) +static long snd_pcm_oss_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {snd_pcm_oss_file_t *pcm_oss_file;int __user *p = (int __user *)arg;
@@ -2073,16 +2072,12 @@return -EINVAL ; } -/* FIXME: need to unlock BKL to allow preemption */ -static int snd_pcm_oss_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) -{ -int err; -unlock_kernel (); - err =_snd_pcm_oss_ioctl (inode, file, cmd, arg); -lock_kernel (); -return err; -} +#ifdef CONFIG_COMPAT +/* all compatible */ +#define snd_pcm_oss_ioctl_compat snd_pcm_oss_ioctl +#else +#define snd_pcm_oss_ioctl_compat NULL +#endif static ssize_t snd_pcm_oss_read (struct file *file,char __user *buf,size_t count,loff_t *offset) {
@@ -2410,7 +2405,8 @@ .open = snd_pcm_oss_open, .release = snd_pcm_oss_release, .poll = snd_pcm_oss_poll, - .ioctl = snd_pcm_oss_ioctl, + .unlocked_ioctl = snd_pcm_oss_ioctl, + .compat_ioctl = snd_pcm_oss_ioctl_compat, .mmap = snd_pcm_oss_mmap, };
sound/core/seq/seq_clientmgr.c +10 -10
@@ -51,7 +51,7 @@#define SNDRV_SEQ_LFLG_OUTPUT 0x0002#define SNDRV_SEQ_LFLG_OPEN (SNDRV_SEQ_LFLG_INPUT|SNDRV_SEQ_LFLG_OUTPUT) -static spinlock_t clients_lock =SPIN_LOCK_UNLOCKED ; +static DEFINE_SPINLOCK (clients_lock);static DECLARE_MUTEX (register_mutex);/*
@@ -2131,21 +2131,20 @@ } -static int snd_seq_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) +static long snd_seq_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {client_t *client = (client_t *) file->private_data; -int err;snd_assert (client !=NULL , return -ENXIO ); -/* FIXME: need to unlock BKL to allow preemption */ -unlock_kernel (); - err =snd_seq_do_ioctl (client, cmd, (void __user *) arg); -lock_kernel (); -return err; +return snd_seq_do_ioctl (client, cmd, (void __user *) arg); } +#ifdef CONFIG_COMPAT +#include "seq_compat.c" +#else +#define snd_seq_ioctl_compat NULL +#endif /* -------------------------------------------------------- */
@@ -2462,7 +2461,8 @@ .open = snd_seq_open, .release = snd_seq_release, .poll = snd_seq_poll, - .ioctl = snd_seq_ioctl, + .unlocked_ioctl = snd_seq_ioctl, + .compat_ioctl = snd_seq_ioctl_compat, }; static snd_minor_t snd_seq_reg =
sound/core/seq/seq_compat.c new file +137 -0
137 lines not on this page · raw message
sound/core/seq/oss/seq_oss.c +11 -10
@@ -59,7 +59,7 @@static int odev_release (struct inode *inode,struct file *file);static ssize_t odev_read (struct file *file,char __user *buf,size_t count,loff_t *offset);static ssize_t odev_write (struct file *file,const char __user *buf,size_t count,loff_t *offset); -static int odev_ioctl (struct inode *inode,struct file *file,unsigned int cmd,unsigned long arg); +static long odev_ioctl (struct file *file,unsigned int cmd,unsigned long arg);static unsigned int odev_poll (struct file *file,poll_table * wait);#ifdef CONFIG_PROC_FS static void info_read (snd_info_entry_t *entry,snd_info_buffer_t *buf);
@@ -177,20 +177,20 @@return snd_seq_oss_write (dp, buf, count, file); } -static int -odev_ioctl (struct inode *inode,struct file *file,unsigned int cmd,unsigned long arg) +static long +odev_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {seq_oss_devinfo_t *dp; -int err; dp = file->private_data;snd_assert (dp !=NULL , return -EIO ); -/* FIXME: need to unlock BKL to allow preemption */ -unlock_kernel (); - err =snd_seq_oss_ioctl (dp, cmd, arg); -lock_kernel (); -return err; +return snd_seq_oss_ioctl (dp, cmd, arg); } +#ifdef CONFIG_COMPAT +#define odev_ioctl_compat odev_ioctl +#else +#define odev_ioctl_compat NULL +#endif static unsigned int odev_poll (struct file *file,poll_table * wait)
@@ -213,7 +213,8 @@ .open = odev_open, .release = odev_release, .poll = odev_poll, - .ioctl = odev_ioctl, + .unlocked_ioctl = odev_ioctl, + .compat_ioctl = odev_ioctl_compat, };static snd_minor_t seq_oss_reg = {
include/sound/hwdep.h +1 -0
@@ -38,6 +38,7 @@int (*release) (snd_hwdep_t * hw,struct file * file);unsigned int (*poll) (snd_hwdep_t * hw,struct file * file,poll_table * wait);int (*ioctl) (snd_hwdep_t * hw,struct file * file,unsigned int cmd,unsigned long arg); +int (*ioctl_compat) (snd_hwdep_t * hw,struct file * file,unsigned int cmd,unsigned long arg);int (*mmap) (snd_hwdep_t * hw,struct file * file,struct vm_area_struct * vma);int (*dsp_status) (snd_hwdep_t * hw,snd_hwdep_dsp_status_t * status);int (*dsp_load) (snd_hwdep_t * hw,snd_hwdep_dsp_image_t * image);
PATCH 3/3 Resend: Conversion to compat_ioctl for ALSA drivers
Sorry, the last patch I sent included a typo.
(Thanks Mathieu Segaud to point it out)
The fixed version is below:
================
The last patch covers the rest of ALSA APIs: hwdep, rawmidi, timer and seq. Also it covers the OSS emulation modules.
sound/core/hwdep.c +11 -14
@@ -232,8 +232,7 @@return 0 ; } -static inline int _snd_hwdep_ioctl (struct inode *inode,struct file * file, -unsigned int cmd,unsigned long arg) +static long snd_hwdep_ioctl (struct file * file,unsigned int cmd,unsigned long arg) {snd_hwdep_t *hw = file->private_data;void __user *argp = (void __user *)arg;
@@ -252,17 +251,6 @@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 = file->private_data;
@@ -315,6 +303,12 @@return -ENOIOCTLCMD ; } +#ifdef CONFIG_COMPAT +#include "hwdep_compat.c" +#else +#define snd_hwdep_ioctl_compat NULL +#endif +/* */
@@ -328,7 +322,8 @@ .open = snd_hwdep_open, .release = snd_hwdep_release, .poll = snd_hwdep_poll, - .ioctl = snd_hwdep_ioctl, + .unlocked_ioctl = snd_hwdep_ioctl, + .compat_ioctl = snd_hwdep_ioctl_compat, .mmap = snd_hwdep_mmap, };
@@ -509,12 +504,14 @@ } snd_hwdep_proc_entry = entry;snd_ctl_register_ioctl (snd_hwdep_control_ioctl); +snd_ctl_register_ioctl_compat (snd_hwdep_control_ioctl);return 0 ; } static void __exit alsa_hwdep_exit(void) {snd_ctl_unregister_ioctl (snd_hwdep_control_ioctl); +snd_ctl_unregister_ioctl_compat (snd_hwdep_control_ioctl);if (snd_hwdep_proc_entry) {snd_info_unregister (snd_hwdep_proc_entry); snd_hwdep_proc_entry =NULL ;
sound/core/hwdep_compat.c new file +77 -0
77 lines not on this page · raw message
sound/core/rawmidi.c +13 -14
@@ -673,8 +673,7 @@return 0 ; } -static inline int _snd_rawmidi_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) +static long snd_rawmidi_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {snd_rawmidi_file_t *rfile;void __user *argp = (void __user *)arg;
@@ -784,17 +783,6 @@return -ENOTTY ; } -/* FIXME: need to unlock BKL to allow preemption */ -static int snd_rawmidi_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) -{ -int err; -unlock_kernel (); - err =_snd_rawmidi_ioctl (inode, file, cmd, arg); -lock_kernel (); -return err; -} - static int snd_rawmidi_control_ioctl(snd_card_t * card, snd_ctl_file_t * control, unsigned int cmd,
@@ -1278,6 +1266,14 @@ }/* +*/ +#ifdef CONFIG_COMPAT +#include "rawmidi_compat.c" +#else +#define snd_rawmidi_ioctl_compat NULL +#endif + +/* */
@@ -1347,7 +1343,8 @@ .open = snd_rawmidi_open, .release = snd_rawmidi_release, .poll = snd_rawmidi_poll, - .ioctl = snd_rawmidi_ioctl, + .unlocked_ioctl = snd_rawmidi_ioctl, + .compat_ioctl = snd_rawmidi_ioctl_compat, }; static snd_minor_t snd_rawmidi_reg =
@@ -1628,6 +1625,7 @@ {snd_ctl_register_ioctl (snd_rawmidi_control_ioctl); +snd_ctl_register_ioctl_compat (snd_rawmidi_control_ioctl);#ifdef CONFIG_SND_OSSEMUL {int i;/* check device map table */
@@ -1649,6 +1647,7 @@ static void __exit alsa_rawmidi_exit(void) {snd_ctl_unregister_ioctl (snd_rawmidi_control_ioctl); +snd_ctl_unregister_ioctl_compat (snd_rawmidi_control_ioctl); }module_init (alsa_rawmidi_init)
sound/core/rawmidi_compat.c new file +120 -0
120 lines not on this page · raw message
sound/core/timer.c +10 -15
@@ -76,7 +76,7 @@static LIST_HEAD (snd_timer_slave_list);/* lock for slave active lists */ -static spinlock_t slave_active_lock =SPIN_LOCK_UNLOCKED ; +static DEFINE_SPINLOCK (slave_active_lock);static DECLARE_MUTEX (register_mutex);
@@ -1653,8 +1653,7 @@return (err =snd_timer_continue (tu->timeri)) <0 ? err :0 ; } -static inline int _snd_timer_user_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) +static long snd_timer_user_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {snd_timer_user_t *tu;void __user *argp = (void __user *)arg;
@@ -1701,17 +1700,6 @@return -ENOTTY ; } -/* FIXME: need to unlock BKL to allow preemption */ -static int snd_timer_user_ioctl (struct inode *inode,struct file * file, -unsigned int cmd,unsigned long arg) -{ -int err; -unlock_kernel (); - err =_snd_timer_user_ioctl (inode, file, cmd, arg); -lock_kernel (); -return err; -} -static int snd_timer_user_fasync (int fd,struct file * file,int on) {snd_timer_user_t *tu;
@@ -1803,6 +1791,12 @@return mask; } +#ifdef CONFIG_COMPAT +#include "timer_compat.c" +#else +#define snd_timer_user_ioctl_compat NULL +#endif +static struct file_operations snd_timer_f_ops = { .owner =THIS_MODULE ,
@@ -1810,7 +1804,8 @@ .open = snd_timer_user_open, .release = snd_timer_user_release, .poll = snd_timer_user_poll, - .ioctl = snd_timer_user_ioctl, + .unlocked_ioctl = snd_timer_user_ioctl, + .compat_ioctl = snd_timer_user_ioctl_compat, .fasync = snd_timer_user_fasync, };
sound/core/timer_compat.c new file +119 -0
119 lines not on this page · raw message
sound/core/oss/mixer_oss.c +11 -10
@@ -359,16 +359,9 @@return -ENXIO ; } -/* FIXME: need to unlock BKL to allow preemption */ -static int snd_mixer_oss_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) +static long snd_mixer_oss_ioctl (struct file *file,unsigned int cmd,unsigned long arg) { -int err; -/* FIXME: need to unlock BKL to allow preemption */ -unlock_kernel (); - err =snd_mixer_oss_ioctl1 ((snd_mixer_oss_file_t *) file->private_data, cmd, arg); -lock_kernel (); -return err; +return snd_mixer_oss_ioctl1 ((snd_mixer_oss_file_t *) file->private_data, cmd, arg); }int snd_mixer_oss_ioctl_card (snd_card_t *card,unsigned int cmd,unsigned long arg)
@@ -384,6 +377,13 @@return snd_mixer_oss_ioctl1 (&fmixer, cmd, arg); } +#ifdef CONFIG_COMPAT +/* all compatible */ +#define snd_mixer_oss_ioctl_compat snd_mixer_oss_ioctl +#else +#define snd_mixer_oss_ioctl_compat NULL +#endif +/* * REGISTRATION PART */
@@ -393,7 +393,8 @@ .owner = THIS_MODULE, .open = snd_mixer_oss_open, .release = snd_mixer_oss_release, - .ioctl = snd_mixer_oss_ioctl, + .unlocked_ioctl = snd_mixer_oss_ioctl, + .compat_ioctl = snd_mixer_oss_ioctl_compat, }; static snd_minor_t snd_mixer_oss_reg =
sound/core/oss/pcm_oss.c +9 -13
@@ -1913,8 +1913,7 @@return 0 ; } -static inline int _snd_pcm_oss_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) +static long snd_pcm_oss_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {snd_pcm_oss_file_t *pcm_oss_file;int __user *p = (int __user *)arg;
@@ -2073,16 +2072,12 @@return -EINVAL ; } -/* FIXME: need to unlock BKL to allow preemption */ -static int snd_pcm_oss_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) -{ -int err; -unlock_kernel (); - err =_snd_pcm_oss_ioctl (inode, file, cmd, arg); -lock_kernel (); -return err; -} +#ifdef CONFIG_COMPAT +/* all compatible */ +#define snd_pcm_oss_ioctl_compat snd_pcm_oss_ioctl +#else +#define snd_pcm_oss_ioctl_compat NULL +#endif static ssize_t snd_pcm_oss_read (struct file *file,char __user *buf,size_t count,loff_t *offset) {
@@ -2410,7 +2405,8 @@ .open = snd_pcm_oss_open, .release = snd_pcm_oss_release, .poll = snd_pcm_oss_poll, - .ioctl = snd_pcm_oss_ioctl, + .unlocked_ioctl = snd_pcm_oss_ioctl, + .compat_ioctl = snd_pcm_oss_ioctl_compat, .mmap = snd_pcm_oss_mmap, };
sound/core/seq/seq_clientmgr.c +10 -10
@@ -51,7 +51,7 @@#define SNDRV_SEQ_LFLG_OUTPUT 0x0002#define SNDRV_SEQ_LFLG_OPEN (SNDRV_SEQ_LFLG_INPUT|SNDRV_SEQ_LFLG_OUTPUT) -static spinlock_t clients_lock =SPIN_LOCK_UNLOCKED ; +static DEFINE_SPINLOCK (clients_lock);static DECLARE_MUTEX (register_mutex);/*
@@ -2131,21 +2131,20 @@ } -static int snd_seq_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) +static long snd_seq_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {client_t *client = (client_t *) file->private_data; -int err;snd_assert (client !=NULL , return -ENXIO ); -/* FIXME: need to unlock BKL to allow preemption */ -unlock_kernel (); - err =snd_seq_do_ioctl (client, cmd, (void __user *) arg); -lock_kernel (); -return err; +return snd_seq_do_ioctl (client, cmd, (void __user *) arg); } +#ifdef CONFIG_COMPAT +#include "seq_compat.c" +#else +#define snd_seq_ioctl_compat NULL +#endif /* -------------------------------------------------------- */
@@ -2462,7 +2461,8 @@ .open = snd_seq_open, .release = snd_seq_release, .poll = snd_seq_poll, - .ioctl = snd_seq_ioctl, + .unlocked_ioctl = snd_seq_ioctl, + .compat_ioctl = snd_seq_ioctl_compat, }; static snd_minor_t snd_seq_reg =
sound/core/seq/seq_compat.c new file +137 -0
137 lines not on this page · raw message
sound/core/seq/oss/seq_oss.c +11 -10
@@ -59,7 +59,7 @@static int odev_release (struct inode *inode,struct file *file);static ssize_t odev_read (struct file *file,char __user *buf,size_t count,loff_t *offset);static ssize_t odev_write (struct file *file,const char __user *buf,size_t count,loff_t *offset); -static int odev_ioctl (struct inode *inode,struct file *file,unsigned int cmd,unsigned long arg); +static long odev_ioctl (struct file *file,unsigned int cmd,unsigned long arg);static unsigned int odev_poll (struct file *file,poll_table * wait);#ifdef CONFIG_PROC_FS static void info_read (snd_info_entry_t *entry,snd_info_buffer_t *buf);
@@ -177,20 +177,20 @@return snd_seq_oss_write (dp, buf, count, file); } -static int -odev_ioctl (struct inode *inode,struct file *file,unsigned int cmd,unsigned long arg) +static long +odev_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {seq_oss_devinfo_t *dp; -int err; dp = file->private_data;snd_assert (dp !=NULL , return -EIO ); -/* FIXME: need to unlock BKL to allow preemption */ -unlock_kernel (); - err =snd_seq_oss_ioctl (dp, cmd, arg); -lock_kernel (); -return err; +return snd_seq_oss_ioctl (dp, cmd, arg); } +#ifdef CONFIG_COMPAT +#define odev_ioctl_compat odev_ioctl +#else +#define odev_ioctl_compat NULL +#endif static unsigned int odev_poll (struct file *file,poll_table * wait)
@@ -213,7 +213,8 @@ .open = odev_open, .release = odev_release, .poll = odev_poll, - .ioctl = odev_ioctl, + .unlocked_ioctl = odev_ioctl, + .compat_ioctl = odev_ioctl_compat, };static snd_minor_t seq_oss_reg = {
include/sound/hwdep.h +1 -0
@@ -38,6 +38,7 @@int (*release) (snd_hwdep_t * hw,struct file * file);unsigned int (*poll) (snd_hwdep_t * hw,struct file * file,poll_table * wait);int (*ioctl) (snd_hwdep_t * hw,struct file * file,unsigned int cmd,unsigned long arg); +int (*ioctl_compat) (snd_hwdep_t * hw,struct file * file,unsigned int cmd,unsigned long arg);int (*mmap) (snd_hwdep_t * hw,struct file * file,struct vm_area_struct * vma);int (*dsp_status) (snd_hwdep_t * hw,snd_hwdep_dsp_status_t * status);int (*dsp_load) (snd_hwdep_t * hw,snd_hwdep_dsp_image_t * image);
Quoted 5 lines · Takashi Iwai
Hi,
the following three patches convert the 32bit ioctl layer of ALSA to the new
compat_ioctl(andunlocked_ioctlfor native ioctls).
Quoted 7 lines
The first patch covers the basic entries and control API. The second patch is for PCM API.
The last one is for other APIs including OSS-emulation modules.After these patches are applied, remove the whole subtree in
sound/core/ioctl32. The files in this directory are no longer necessary.
Fix 32-bit calls to snd_pcm_channel_info().
sound/core/pcm_native.c renamed from sound/core/pcm_native.c.bak +16 -10
@@ -602,17 +602,13 @@return 0 ; } -static int snd_pcm_channel_info (snd_pcm_substream_t * substream,snd_pcm_channel_info_t __user * _info) +static int snd_pcm_channel_info (snd_pcm_substream_t * substream,snd_pcm_channel_info_t * info) { -snd_pcm_channel_info_t info;snd_pcm_runtime_t *runtime; -int res;unsigned int channel;snd_assert (substream !=NULL , return -ENXIO ); -if (copy_from_user (&info, _info,sizeof (info))) -return -EFAULT ; - channel = info.channel; + channel = info->channel; runtime = substream->runtime;snd_pcm_stream_lock_irq (substream);if (runtime->status->state ==SNDRV_PCM_STATE_OPEN ) {
@@ -622,9 +618,19 @@snd_pcm_stream_unlock_irq (substream);if (channel >= runtime->channels)return -EINVAL ; -memset (&info,0 ,sizeof (info)); - info.channel = channel; - res = substream->ops->ioctl (substream,SNDRV_PCM_IOCTL1_CHANNEL_INFO , &info); +memset (info,0 ,sizeof (*info)); + info->channel = channel; +return substream->ops->ioctl (substream,SNDRV_PCM_IOCTL1_CHANNEL_INFO , info); +} + +static int snd_pcm_channel_info_user (snd_pcm_substream_t * substream,snd_pcm_channel_info_t __user * _info) +{ +snd_pcm_channel_info_t info; +int res; + +if (copy_from_user (&info, _info,sizeof (info))) +return -EFAULT ; + res =snd_pcm_channel_info (substream, &info);if (res <0 )return res;if (copy_to_user (_info, &info,sizeof (info)))
@@ -2440,7 +2446,7 @@case SNDRV_PCM_IOCTL_STATUS :return snd_pcm_status_user (substream, arg);case SNDRV_PCM_IOCTL_CHANNEL_INFO : -return snd_pcm_channel_info (substream, arg); +return snd_pcm_channel_info_user (substream, arg);case SNDRV_PCM_IOCTL_PREPARE :return snd_pcm_prepare (substream);case SNDRV_PCM_IOCTL_RESET :
Takashi Iwai
AppliedAt Sun, 30 Jan 2005 13:02:15 -0500,
Quoted 11 lines · Brian Gerst
Quoted 9 lines · Takashi Iwai
Hi,
the following three patches convert the 32bit ioctl layer of ALSA to the new
compat_ioctl(andunlocked_ioctlfor native ioctls).The first patch covers the basic entries and control API. The second patch is for PCM API.
The last one is for other APIs including OSS-emulation modules.
Quoted 7 lines
Quoted 3 lines
After these patches are applied, remove the whole subtree in
sound/core/ioctl32. The files in this directory are no longer necessary.Fix 32-bit calls to
snd_pcm_channel_info().Signed-off-by Brian Gerst <[email protected]>
Thanks, applied to the ALSA tree.
Takashi