Commit 645ef9ef1fc0ff70456495b1e21d3420b7b08541
Committed by
Takashi Iwai
1 parent
7b6c3a34e9
Exists in
master
and in
7 other branches
sound: autoconvert trivial BKL users to private mutex
The usage of the BKL in the OSS sound drivers is trivial, and each of them only locks against itself, so it can be turned into per-driver mutexes. This is the script that was used for the conversion: file=$1 name=$2 if grep -q lock_kernel ${file} ; then if grep -q 'include.*linux.mutex.h' ${file} ; then sed -i '/include.*<linux\/smp_lock.h>/d' ${file} else sed -i 's/include.*<linux\/smp_lock.h>.*$/include <linux\/mutex.h>/g' ${file} fi sed -i ${file} \ -e "/^#include.*linux.mutex.h/,$ { 1,/^\(static\|int\|long\)/ { /^\(static\|int\|long\)/istatic DEFINE_MUTEX(${name}_mutex); } }" \ -e "s/\(un\)*lock_kernel\>[ ]*()/mutex_\1lock(\&${name}_mutex)/g" \ -e '/[ ]*cycle_kernel_lock();/d' else sed -i -e '/include.*\<smp_lock.h\>/d' ${file} \ -e '/cycle_kernel_lock()/d' fi Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Showing 7 changed files with 97 additions and 93 deletions Side-by-side Diff
sound/oss/au1550_ac97.c
... | ... | @@ -43,7 +43,6 @@ |
43 | 43 | #include <linux/sound.h> |
44 | 44 | #include <linux/slab.h> |
45 | 45 | #include <linux/soundcard.h> |
46 | -#include <linux/smp_lock.h> | |
47 | 46 | #include <linux/init.h> |
48 | 47 | #include <linux/interrupt.h> |
49 | 48 | #include <linux/kernel.h> |
... | ... | @@ -77,6 +76,7 @@ |
77 | 76 | /* Boot options |
78 | 77 | * 0 = no VRA, 1 = use VRA if codec supports it |
79 | 78 | */ |
79 | +static DEFINE_MUTEX(au1550_ac97_mutex); | |
80 | 80 | static int vra = 1; |
81 | 81 | module_param(vra, bool, 0); |
82 | 82 | MODULE_PARM_DESC(vra, "if 1 use VRA if codec supports it"); |
83 | 83 | |
... | ... | @@ -798,9 +798,9 @@ |
798 | 798 | static int |
799 | 799 | au1550_open_mixdev(struct inode *inode, struct file *file) |
800 | 800 | { |
801 | - lock_kernel(); | |
801 | + mutex_lock(&au1550_ac97_mutex); | |
802 | 802 | file->private_data = &au1550_state; |
803 | - unlock_kernel(); | |
803 | + mutex_unlock(&au1550_ac97_mutex); | |
804 | 804 | return 0; |
805 | 805 | } |
806 | 806 | |
807 | 807 | |
... | ... | @@ -824,9 +824,9 @@ |
824 | 824 | struct ac97_codec *codec = s->codec; |
825 | 825 | int ret; |
826 | 826 | |
827 | - lock_kernel(); | |
827 | + mutex_lock(&au1550_ac97_mutex); | |
828 | 828 | ret = mixdev_ioctl(codec, cmd, arg); |
829 | - unlock_kernel(); | |
829 | + mutex_unlock(&au1550_ac97_mutex); | |
830 | 830 | |
831 | 831 | return ret; |
832 | 832 | } |
... | ... | @@ -1255,7 +1255,7 @@ |
1255 | 1255 | unsigned long size; |
1256 | 1256 | int ret = 0; |
1257 | 1257 | |
1258 | - lock_kernel(); | |
1258 | + mutex_lock(&au1550_ac97_mutex); | |
1259 | 1259 | mutex_lock(&s->sem); |
1260 | 1260 | if (vma->vm_flags & VM_WRITE) |
1261 | 1261 | db = &s->dma_dac; |
... | ... | @@ -1283,7 +1283,7 @@ |
1283 | 1283 | db->mapped = 1; |
1284 | 1284 | out: |
1285 | 1285 | mutex_unlock(&s->sem); |
1286 | - unlock_kernel(); | |
1286 | + mutex_unlock(&au1550_ac97_mutex); | |
1287 | 1287 | return ret; |
1288 | 1288 | } |
1289 | 1289 | |
1290 | 1290 | |
... | ... | @@ -1781,9 +1781,9 @@ |
1781 | 1781 | { |
1782 | 1782 | int ret; |
1783 | 1783 | |
1784 | - lock_kernel(); | |
1784 | + mutex_lock(&au1550_ac97_mutex); | |
1785 | 1785 | ret = au1550_ioctl(file, cmd, arg); |
1786 | - unlock_kernel(); | |
1786 | + mutex_unlock(&au1550_ac97_mutex); | |
1787 | 1787 | |
1788 | 1788 | return ret; |
1789 | 1789 | } |
... | ... | @@ -1804,7 +1804,7 @@ |
1804 | 1804 | #endif |
1805 | 1805 | |
1806 | 1806 | file->private_data = s; |
1807 | - lock_kernel(); | |
1807 | + mutex_lock(&au1550_ac97_mutex); | |
1808 | 1808 | /* wait for device to become free */ |
1809 | 1809 | mutex_lock(&s->open_mutex); |
1810 | 1810 | while (s->open_mode & file->f_mode) { |
... | ... | @@ -1861,7 +1861,7 @@ |
1861 | 1861 | out: |
1862 | 1862 | mutex_unlock(&s->open_mutex); |
1863 | 1863 | out2: |
1864 | - unlock_kernel(); | |
1864 | + mutex_unlock(&au1550_ac97_mutex); | |
1865 | 1865 | return ret; |
1866 | 1866 | } |
1867 | 1867 | |
1868 | 1868 | |
1869 | 1869 | |
... | ... | @@ -1870,12 +1870,12 @@ |
1870 | 1870 | { |
1871 | 1871 | struct au1550_state *s = file->private_data; |
1872 | 1872 | |
1873 | - lock_kernel(); | |
1873 | + mutex_lock(&au1550_ac97_mutex); | |
1874 | 1874 | |
1875 | 1875 | if (file->f_mode & FMODE_WRITE) { |
1876 | - unlock_kernel(); | |
1876 | + mutex_unlock(&au1550_ac97_mutex); | |
1877 | 1877 | drain_dac(s, file->f_flags & O_NONBLOCK); |
1878 | - lock_kernel(); | |
1878 | + mutex_lock(&au1550_ac97_mutex); | |
1879 | 1879 | } |
1880 | 1880 | |
1881 | 1881 | mutex_lock(&s->open_mutex); |
... | ... | @@ -1892,7 +1892,7 @@ |
1892 | 1892 | s->open_mode &= ((~file->f_mode) & (FMODE_READ|FMODE_WRITE)); |
1893 | 1893 | mutex_unlock(&s->open_mutex); |
1894 | 1894 | wake_up(&s->open_wait); |
1895 | - unlock_kernel(); | |
1895 | + mutex_unlock(&au1550_ac97_mutex); | |
1896 | 1896 | return 0; |
1897 | 1897 | } |
1898 | 1898 |
sound/oss/dmasound/dmasound_core.c
... | ... | @@ -181,7 +181,7 @@ |
181 | 181 | #include <linux/init.h> |
182 | 182 | #include <linux/soundcard.h> |
183 | 183 | #include <linux/poll.h> |
184 | -#include <linux/smp_lock.h> | |
184 | +#include <linux/mutex.h> | |
185 | 185 | |
186 | 186 | #include <asm/uaccess.h> |
187 | 187 | |
... | ... | @@ -194,6 +194,7 @@ |
194 | 194 | * Declarations |
195 | 195 | */ |
196 | 196 | |
197 | +static DEFINE_MUTEX(dmasound_core_mutex); | |
197 | 198 | int dmasound_catchRadius = 0; |
198 | 199 | module_param(dmasound_catchRadius, int, 0); |
199 | 200 | |
200 | 201 | |
201 | 202 | |
202 | 203 | |
203 | 204 | |
... | ... | @@ -323,22 +324,22 @@ |
323 | 324 | |
324 | 325 | static int mixer_open(struct inode *inode, struct file *file) |
325 | 326 | { |
326 | - lock_kernel(); | |
327 | + mutex_lock(&dmasound_core_mutex); | |
327 | 328 | if (!try_module_get(dmasound.mach.owner)) { |
328 | - unlock_kernel(); | |
329 | + mutex_unlock(&dmasound_core_mutex); | |
329 | 330 | return -ENODEV; |
330 | 331 | } |
331 | 332 | mixer.busy = 1; |
332 | - unlock_kernel(); | |
333 | + mutex_unlock(&dmasound_core_mutex); | |
333 | 334 | return 0; |
334 | 335 | } |
335 | 336 | |
336 | 337 | static int mixer_release(struct inode *inode, struct file *file) |
337 | 338 | { |
338 | - lock_kernel(); | |
339 | + mutex_lock(&dmasound_core_mutex); | |
339 | 340 | mixer.busy = 0; |
340 | 341 | module_put(dmasound.mach.owner); |
341 | - unlock_kernel(); | |
342 | + mutex_unlock(&dmasound_core_mutex); | |
342 | 343 | return 0; |
343 | 344 | } |
344 | 345 | |
345 | 346 | |
... | ... | @@ -370,9 +371,9 @@ |
370 | 371 | { |
371 | 372 | int ret; |
372 | 373 | |
373 | - lock_kernel(); | |
374 | + mutex_lock(&dmasound_core_mutex); | |
374 | 375 | ret = mixer_ioctl(file, cmd, arg); |
375 | - unlock_kernel(); | |
376 | + mutex_unlock(&dmasound_core_mutex); | |
376 | 377 | |
377 | 378 | return ret; |
378 | 379 | } |
379 | 380 | |
... | ... | @@ -752,9 +753,9 @@ |
752 | 753 | { |
753 | 754 | int rc; |
754 | 755 | |
755 | - lock_kernel(); | |
756 | + mutex_lock(&dmasound_core_mutex); | |
756 | 757 | if (!try_module_get(dmasound.mach.owner)) { |
757 | - unlock_kernel(); | |
758 | + mutex_unlock(&dmasound_core_mutex); | |
758 | 759 | return -ENODEV; |
759 | 760 | } |
760 | 761 | |
761 | 762 | |
... | ... | @@ -799,11 +800,11 @@ |
799 | 800 | sound_set_format(AFMT_MU_LAW); |
800 | 801 | } |
801 | 802 | #endif |
802 | - unlock_kernel(); | |
803 | + mutex_unlock(&dmasound_core_mutex); | |
803 | 804 | return 0; |
804 | 805 | out: |
805 | 806 | module_put(dmasound.mach.owner); |
806 | - unlock_kernel(); | |
807 | + mutex_unlock(&dmasound_core_mutex); | |
807 | 808 | return rc; |
808 | 809 | } |
809 | 810 | |
... | ... | @@ -869,7 +870,7 @@ |
869 | 870 | { |
870 | 871 | int rc = 0; |
871 | 872 | |
872 | - lock_kernel(); | |
873 | + mutex_lock(&dmasound_core_mutex); | |
873 | 874 | |
874 | 875 | if (file->f_mode & FMODE_WRITE) { |
875 | 876 | if (write_sq.busy) |
... | ... | @@ -900,7 +901,7 @@ |
900 | 901 | write_sq_wake_up(file); /* checks f_mode */ |
901 | 902 | #endif /* blocking open() */ |
902 | 903 | |
903 | - unlock_kernel(); | |
904 | + mutex_unlock(&dmasound_core_mutex); | |
904 | 905 | |
905 | 906 | return rc; |
906 | 907 | } |
907 | 908 | |
... | ... | @@ -1141,9 +1142,9 @@ |
1141 | 1142 | { |
1142 | 1143 | int ret; |
1143 | 1144 | |
1144 | - lock_kernel(); | |
1145 | + mutex_lock(&dmasound_core_mutex); | |
1145 | 1146 | ret = sq_ioctl(file, cmd, arg); |
1146 | - unlock_kernel(); | |
1147 | + mutex_unlock(&dmasound_core_mutex); | |
1147 | 1148 | |
1148 | 1149 | return ret; |
1149 | 1150 | } |
... | ... | @@ -1257,7 +1258,7 @@ |
1257 | 1258 | int len = 0; |
1258 | 1259 | int ret; |
1259 | 1260 | |
1260 | - lock_kernel(); | |
1261 | + mutex_lock(&dmasound_core_mutex); | |
1261 | 1262 | ret = -EBUSY; |
1262 | 1263 | if (state.busy) |
1263 | 1264 | goto out; |
1264 | 1265 | |
1265 | 1266 | |
... | ... | @@ -1329,16 +1330,16 @@ |
1329 | 1330 | state.len = len; |
1330 | 1331 | ret = 0; |
1331 | 1332 | out: |
1332 | - unlock_kernel(); | |
1333 | + mutex_unlock(&dmasound_core_mutex); | |
1333 | 1334 | return ret; |
1334 | 1335 | } |
1335 | 1336 | |
1336 | 1337 | static int state_release(struct inode *inode, struct file *file) |
1337 | 1338 | { |
1338 | - lock_kernel(); | |
1339 | + mutex_lock(&dmasound_core_mutex); | |
1339 | 1340 | state.busy = 0; |
1340 | 1341 | module_put(dmasound.mach.owner); |
1341 | - unlock_kernel(); | |
1342 | + mutex_unlock(&dmasound_core_mutex); | |
1342 | 1343 | return 0; |
1343 | 1344 | } |
1344 | 1345 |
sound/oss/msnd_pinnacle.c
... | ... | @@ -39,7 +39,7 @@ |
39 | 39 | #include <linux/delay.h> |
40 | 40 | #include <linux/init.h> |
41 | 41 | #include <linux/interrupt.h> |
42 | -#include <linux/smp_lock.h> | |
42 | +#include <linux/mutex.h> | |
43 | 43 | #include <linux/gfp.h> |
44 | 44 | #include <asm/irq.h> |
45 | 45 | #include <asm/io.h> |
... | ... | @@ -79,6 +79,7 @@ |
79 | 79 | dev.rec_sample_rate / \ |
80 | 80 | dev.rec_channels) |
81 | 81 | |
82 | +static DEFINE_MUTEX(msnd_pinnacle_mutex); | |
82 | 83 | static multisound_dev_t dev; |
83 | 84 | |
84 | 85 | #ifndef HAVE_DSPCODEH |
85 | 86 | |
... | ... | @@ -651,12 +652,12 @@ |
651 | 652 | |
652 | 653 | ret = -EINVAL; |
653 | 654 | |
654 | - lock_kernel(); | |
655 | + mutex_lock(&msnd_pinnacle_mutex); | |
655 | 656 | if (minor == dev.dsp_minor) |
656 | 657 | ret = dsp_ioctl(file, cmd, arg); |
657 | 658 | else if (minor == dev.mixer_minor) |
658 | 659 | ret = mixer_ioctl(cmd, arg); |
659 | - unlock_kernel(); | |
660 | + mutex_unlock(&msnd_pinnacle_mutex); | |
660 | 661 | |
661 | 662 | return ret; |
662 | 663 | } |
... | ... | @@ -761,7 +762,7 @@ |
761 | 762 | int minor = iminor(inode); |
762 | 763 | int err = 0; |
763 | 764 | |
764 | - lock_kernel(); | |
765 | + mutex_lock(&msnd_pinnacle_mutex); | |
765 | 766 | if (minor == dev.dsp_minor) { |
766 | 767 | if ((file->f_mode & FMODE_WRITE && |
767 | 768 | test_bit(F_AUDIO_WRITE_INUSE, &dev.flags)) || |
... | ... | @@ -791,7 +792,7 @@ |
791 | 792 | } else |
792 | 793 | err = -EINVAL; |
793 | 794 | out: |
794 | - unlock_kernel(); | |
795 | + mutex_unlock(&msnd_pinnacle_mutex); | |
795 | 796 | return err; |
796 | 797 | } |
797 | 798 | |
798 | 799 | |
... | ... | @@ -800,14 +801,14 @@ |
800 | 801 | int minor = iminor(inode); |
801 | 802 | int err = 0; |
802 | 803 | |
803 | - lock_kernel(); | |
804 | + mutex_lock(&msnd_pinnacle_mutex); | |
804 | 805 | if (minor == dev.dsp_minor) |
805 | 806 | err = dsp_release(file); |
806 | 807 | else if (minor == dev.mixer_minor) { |
807 | 808 | /* nothing */ |
808 | 809 | } else |
809 | 810 | err = -EINVAL; |
810 | - unlock_kernel(); | |
811 | + mutex_unlock(&msnd_pinnacle_mutex); | |
811 | 812 | return err; |
812 | 813 | } |
813 | 814 |
sound/oss/sh_dac_audio.c
... | ... | @@ -16,7 +16,7 @@ |
16 | 16 | #include <linux/slab.h> |
17 | 17 | #include <linux/fs.h> |
18 | 18 | #include <linux/sound.h> |
19 | -#include <linux/smp_lock.h> | |
19 | +#include <linux/mutex.h> | |
20 | 20 | #include <linux/soundcard.h> |
21 | 21 | #include <linux/interrupt.h> |
22 | 22 | #include <linux/hrtimer.h> |
... | ... | @@ -34,6 +34,7 @@ |
34 | 34 | |
35 | 35 | #define BUFFER_SIZE 48000 |
36 | 36 | |
37 | +static DEFINE_MUTEX(sh_dac_audio_mutex); | |
37 | 38 | static int rate; |
38 | 39 | static int empty; |
39 | 40 | static char *data_buffer, *buffer_begin, *buffer_end; |
40 | 41 | |
... | ... | @@ -163,9 +164,9 @@ |
163 | 164 | { |
164 | 165 | int ret; |
165 | 166 | |
166 | - lock_kernel(); | |
167 | + mutex_lock(&sh_dac_audio_mutex); | |
167 | 168 | ret = dac_audio_ioctl(file, cmd, arg); |
168 | - unlock_kernel(); | |
169 | + mutex_unlock(&sh_dac_audio_mutex); | |
169 | 170 | |
170 | 171 | return ret; |
171 | 172 | } |
172 | 173 | |
173 | 174 | |
... | ... | @@ -229,16 +230,16 @@ |
229 | 230 | if (file->f_mode & FMODE_READ) |
230 | 231 | return -ENODEV; |
231 | 232 | |
232 | - lock_kernel(); | |
233 | + mutex_lock(&sh_dac_audio_mutex); | |
233 | 234 | if (in_use) { |
234 | - unlock_kernel(); | |
235 | + mutex_unlock(&sh_dac_audio_mutex); | |
235 | 236 | return -EBUSY; |
236 | 237 | } |
237 | 238 | |
238 | 239 | in_use = 1; |
239 | 240 | |
240 | 241 | dac_audio_start(); |
241 | - unlock_kernel(); | |
242 | + mutex_unlock(&sh_dac_audio_mutex); | |
242 | 243 | return 0; |
243 | 244 | } |
244 | 245 |
sound/oss/soundcard.c
... | ... | @@ -40,7 +40,7 @@ |
40 | 40 | #include <linux/major.h> |
41 | 41 | #include <linux/delay.h> |
42 | 42 | #include <linux/proc_fs.h> |
43 | -#include <linux/smp_lock.h> | |
43 | +#include <linux/mutex.h> | |
44 | 44 | #include <linux/module.h> |
45 | 45 | #include <linux/mm.h> |
46 | 46 | #include <linux/device.h> |
... | ... | @@ -56,6 +56,7 @@ |
56 | 56 | * Table for permanently allocated memory (used when unloading the module) |
57 | 57 | */ |
58 | 58 | void * sound_mem_blocks[MAX_MEM_BLOCKS]; |
59 | +static DEFINE_MUTEX(soundcard_mutex); | |
59 | 60 | int sound_nblocks = 0; |
60 | 61 | |
61 | 62 | /* Persistent DMA buffers */ |
... | ... | @@ -151,7 +152,7 @@ |
151 | 152 | * big one anyway, we might as well bandage here.. |
152 | 153 | */ |
153 | 154 | |
154 | - lock_kernel(); | |
155 | + mutex_lock(&soundcard_mutex); | |
155 | 156 | |
156 | 157 | DEB(printk("sound_read(dev=%d, count=%d)\n", dev, count)); |
157 | 158 | switch (dev & 0x0f) { |
... | ... | @@ -169,7 +170,7 @@ |
169 | 170 | case SND_DEV_MIDIN: |
170 | 171 | ret = MIDIbuf_read(dev, file, buf, count); |
171 | 172 | } |
172 | - unlock_kernel(); | |
173 | + mutex_unlock(&soundcard_mutex); | |
173 | 174 | return ret; |
174 | 175 | } |
175 | 176 | |
... | ... | @@ -178,7 +179,7 @@ |
178 | 179 | int dev = iminor(file->f_path.dentry->d_inode); |
179 | 180 | int ret = -EINVAL; |
180 | 181 | |
181 | - lock_kernel(); | |
182 | + mutex_lock(&soundcard_mutex); | |
182 | 183 | DEB(printk("sound_write(dev=%d, count=%d)\n", dev, count)); |
183 | 184 | switch (dev & 0x0f) { |
184 | 185 | case SND_DEV_SEQ: |
... | ... | @@ -196,7 +197,7 @@ |
196 | 197 | ret = MIDIbuf_write(dev, file, buf, count); |
197 | 198 | break; |
198 | 199 | } |
199 | - unlock_kernel(); | |
200 | + mutex_unlock(&soundcard_mutex); | |
200 | 201 | return ret; |
201 | 202 | } |
202 | 203 | |
... | ... | @@ -210,7 +211,7 @@ |
210 | 211 | printk(KERN_ERR "Invalid minor device %d\n", dev); |
211 | 212 | return -ENXIO; |
212 | 213 | } |
213 | - lock_kernel(); | |
214 | + mutex_lock(&soundcard_mutex); | |
214 | 215 | switch (dev & 0x0f) { |
215 | 216 | case SND_DEV_CTL: |
216 | 217 | dev >>= 4; |
... | ... | @@ -247,7 +248,7 @@ |
247 | 248 | retval = -ENXIO; |
248 | 249 | } |
249 | 250 | |
250 | - unlock_kernel(); | |
251 | + mutex_unlock(&soundcard_mutex); | |
251 | 252 | return 0; |
252 | 253 | } |
253 | 254 | |
... | ... | @@ -255,7 +256,7 @@ |
255 | 256 | { |
256 | 257 | int dev = iminor(inode); |
257 | 258 | |
258 | - lock_kernel(); | |
259 | + mutex_lock(&soundcard_mutex); | |
259 | 260 | DEB(printk("sound_release(dev=%d)\n", dev)); |
260 | 261 | switch (dev & 0x0f) { |
261 | 262 | case SND_DEV_CTL: |
... | ... | @@ -280,7 +281,7 @@ |
280 | 281 | default: |
281 | 282 | printk(KERN_ERR "Sound error: Releasing unknown device 0x%02x\n", dev); |
282 | 283 | } |
283 | - unlock_kernel(); | |
284 | + mutex_unlock(&soundcard_mutex); | |
284 | 285 | |
285 | 286 | return 0; |
286 | 287 | } |
... | ... | @@ -354,7 +355,7 @@ |
354 | 355 | if (cmd == OSS_GETVERSION) |
355 | 356 | return __put_user(SOUND_VERSION, (int __user *)p); |
356 | 357 | |
357 | - lock_kernel(); | |
358 | + mutex_lock(&soundcard_mutex); | |
358 | 359 | if (_IOC_TYPE(cmd) == 'M' && num_mixers > 0 && /* Mixer ioctl */ |
359 | 360 | (dev & 0x0f) != SND_DEV_CTL) { |
360 | 361 | dtype = dev & 0x0f; |
... | ... | @@ -369,7 +370,7 @@ |
369 | 370 | ret = sound_mixer_ioctl(dev >> 4, cmd, p); |
370 | 371 | break; |
371 | 372 | } |
372 | - unlock_kernel(); | |
373 | + mutex_unlock(&soundcard_mutex); | |
373 | 374 | return ret; |
374 | 375 | } |
375 | 376 | |
... | ... | @@ -399,7 +400,7 @@ |
399 | 400 | break; |
400 | 401 | |
401 | 402 | } |
402 | - unlock_kernel(); | |
403 | + mutex_unlock(&soundcard_mutex); | |
403 | 404 | return ret; |
404 | 405 | } |
405 | 406 | |
406 | 407 | |
407 | 408 | |
408 | 409 | |
409 | 410 | |
410 | 411 | |
... | ... | @@ -439,35 +440,35 @@ |
439 | 440 | printk(KERN_ERR "Sound: mmap() not supported for other than audio devices\n"); |
440 | 441 | return -EINVAL; |
441 | 442 | } |
442 | - lock_kernel(); | |
443 | + mutex_lock(&soundcard_mutex); | |
443 | 444 | if (vma->vm_flags & VM_WRITE) /* Map write and read/write to the output buf */ |
444 | 445 | dmap = audio_devs[dev]->dmap_out; |
445 | 446 | else if (vma->vm_flags & VM_READ) |
446 | 447 | dmap = audio_devs[dev]->dmap_in; |
447 | 448 | else { |
448 | 449 | printk(KERN_ERR "Sound: Undefined mmap() access\n"); |
449 | - unlock_kernel(); | |
450 | + mutex_unlock(&soundcard_mutex); | |
450 | 451 | return -EINVAL; |
451 | 452 | } |
452 | 453 | |
453 | 454 | if (dmap == NULL) { |
454 | 455 | printk(KERN_ERR "Sound: mmap() error. dmap == NULL\n"); |
455 | - unlock_kernel(); | |
456 | + mutex_unlock(&soundcard_mutex); | |
456 | 457 | return -EIO; |
457 | 458 | } |
458 | 459 | if (dmap->raw_buf == NULL) { |
459 | 460 | printk(KERN_ERR "Sound: mmap() called when raw_buf == NULL\n"); |
460 | - unlock_kernel(); | |
461 | + mutex_unlock(&soundcard_mutex); | |
461 | 462 | return -EIO; |
462 | 463 | } |
463 | 464 | if (dmap->mapping_flags) { |
464 | 465 | printk(KERN_ERR "Sound: mmap() called twice for the same DMA buffer\n"); |
465 | - unlock_kernel(); | |
466 | + mutex_unlock(&soundcard_mutex); | |
466 | 467 | return -EIO; |
467 | 468 | } |
468 | 469 | if (vma->vm_pgoff != 0) { |
469 | 470 | printk(KERN_ERR "Sound: mmap() offset must be 0.\n"); |
470 | - unlock_kernel(); | |
471 | + mutex_unlock(&soundcard_mutex); | |
471 | 472 | return -EINVAL; |
472 | 473 | } |
473 | 474 | size = vma->vm_end - vma->vm_start; |
... | ... | @@ -478,7 +479,7 @@ |
478 | 479 | if (remap_pfn_range(vma, vma->vm_start, |
479 | 480 | virt_to_phys(dmap->raw_buf) >> PAGE_SHIFT, |
480 | 481 | vma->vm_end - vma->vm_start, vma->vm_page_prot)) { |
481 | - unlock_kernel(); | |
482 | + mutex_unlock(&soundcard_mutex); | |
482 | 483 | return -EAGAIN; |
483 | 484 | } |
484 | 485 | |
... | ... | @@ -490,7 +491,7 @@ |
490 | 491 | memset(dmap->raw_buf, |
491 | 492 | dmap->neutral_byte, |
492 | 493 | dmap->bytes_in_use); |
493 | - unlock_kernel(); | |
494 | + mutex_unlock(&soundcard_mutex); | |
494 | 495 | return 0; |
495 | 496 | } |
496 | 497 |
sound/oss/swarm_cs4297a.c
... | ... | @@ -68,7 +68,6 @@ |
68 | 68 | #include <linux/delay.h> |
69 | 69 | #include <linux/sound.h> |
70 | 70 | #include <linux/slab.h> |
71 | -#include <linux/smp_lock.h> | |
72 | 71 | #include <linux/soundcard.h> |
73 | 72 | #include <linux/ac97_codec.h> |
74 | 73 | #include <linux/pci.h> |
... | ... | @@ -94,6 +93,7 @@ |
94 | 93 | |
95 | 94 | struct cs4297a_state; |
96 | 95 | |
96 | +static DEFINE_MUTEX(swarm_cs4297a_mutex); | |
97 | 97 | static void stop_dac(struct cs4297a_state *s); |
98 | 98 | static void stop_adc(struct cs4297a_state *s); |
99 | 99 | static void start_dac(struct cs4297a_state *s); |
... | ... | @@ -1535,7 +1535,7 @@ |
1535 | 1535 | CS_DBGOUT(CS_FUNCTION | CS_OPEN, 4, |
1536 | 1536 | printk(KERN_INFO "cs4297a: cs4297a_open_mixdev()+\n")); |
1537 | 1537 | |
1538 | - lock_kernel(); | |
1538 | + mutex_lock(&swarm_cs4297a_mutex); | |
1539 | 1539 | list_for_each(entry, &cs4297a_devs) |
1540 | 1540 | { |
1541 | 1541 | s = list_entry(entry, struct cs4297a_state, list); |
... | ... | @@ -1547,7 +1547,7 @@ |
1547 | 1547 | CS_DBGOUT(CS_FUNCTION | CS_OPEN | CS_ERROR, 2, |
1548 | 1548 | printk(KERN_INFO "cs4297a: cs4297a_open_mixdev()- -ENODEV\n")); |
1549 | 1549 | |
1550 | - unlock_kernel(); | |
1550 | + mutex_unlock(&swarm_cs4297a_mutex); | |
1551 | 1551 | return -ENODEV; |
1552 | 1552 | } |
1553 | 1553 | VALIDATE_STATE(s); |
... | ... | @@ -1555,7 +1555,7 @@ |
1555 | 1555 | |
1556 | 1556 | CS_DBGOUT(CS_FUNCTION | CS_OPEN, 4, |
1557 | 1557 | printk(KERN_INFO "cs4297a: cs4297a_open_mixdev()- 0\n")); |
1558 | - unlock_kernel(); | |
1558 | + mutex_unlock(&swarm_cs4297a_mutex); | |
1559 | 1559 | |
1560 | 1560 | return nonseekable_open(inode, file); |
1561 | 1561 | } |
1562 | 1562 | |
... | ... | @@ -1575,10 +1575,10 @@ |
1575 | 1575 | unsigned int cmd, unsigned long arg) |
1576 | 1576 | { |
1577 | 1577 | int ret; |
1578 | - lock_kernel(); | |
1578 | + mutex_lock(&swarm_cs4297a_mutex); | |
1579 | 1579 | ret = mixer_ioctl((struct cs4297a_state *) file->private_data, cmd, |
1580 | 1580 | arg); |
1581 | - unlock_kernel(); | |
1581 | + mutex_unlock(&swarm_cs4297a_mutex); | |
1582 | 1582 | return ret; |
1583 | 1583 | } |
1584 | 1584 | |
1585 | 1585 | |
... | ... | @@ -2350,9 +2350,9 @@ |
2350 | 2350 | { |
2351 | 2351 | int ret; |
2352 | 2352 | |
2353 | - lock_kernel(); | |
2353 | + mutex_lock(&swarm_cs4297a_mutex); | |
2354 | 2354 | ret = cs4297a_ioctl(file, cmd, arg); |
2355 | - unlock_kernel(); | |
2355 | + mutex_unlock(&swarm_cs4297a_mutex); | |
2356 | 2356 | |
2357 | 2357 | return ret; |
2358 | 2358 | } |
2359 | 2359 | |
... | ... | @@ -2509,9 +2509,9 @@ |
2509 | 2509 | { |
2510 | 2510 | int ret; |
2511 | 2511 | |
2512 | - lock_kernel(); | |
2512 | + mutex_lock(&swarm_cs4297a_mutex); | |
2513 | 2513 | ret = cs4297a_open(inode, file); |
2514 | - unlock_kernel(); | |
2514 | + mutex_unlock(&swarm_cs4297a_mutex); | |
2515 | 2515 | |
2516 | 2516 | return ret; |
2517 | 2517 | } |
sound/oss/vwsnd.c
... | ... | @@ -145,7 +145,6 @@ |
145 | 145 | #include <linux/init.h> |
146 | 146 | |
147 | 147 | #include <linux/spinlock.h> |
148 | -#include <linux/smp_lock.h> | |
149 | 148 | #include <linux/wait.h> |
150 | 149 | #include <linux/interrupt.h> |
151 | 150 | #include <linux/mutex.h> |
... | ... | @@ -160,6 +159,7 @@ |
160 | 159 | |
161 | 160 | #ifdef VWSND_DEBUG |
162 | 161 | |
162 | +static DEFINE_MUTEX(vwsnd_mutex); | |
163 | 163 | static int shut_up = 1; |
164 | 164 | |
165 | 165 | /* |
166 | 166 | |
... | ... | @@ -2891,11 +2891,11 @@ |
2891 | 2891 | vwsnd_dev_t *devc = (vwsnd_dev_t *) file->private_data; |
2892 | 2892 | int ret; |
2893 | 2893 | |
2894 | - lock_kernel(); | |
2894 | + mutex_lock(&vwsnd_mutex); | |
2895 | 2895 | mutex_lock(&devc->io_mutex); |
2896 | 2896 | ret = vwsnd_audio_do_ioctl(file, cmd, arg); |
2897 | 2897 | mutex_unlock(&devc->io_mutex); |
2898 | - unlock_kernel(); | |
2898 | + mutex_unlock(&vwsnd_mutex); | |
2899 | 2899 | |
2900 | 2900 | return ret; |
2901 | 2901 | } |
... | ... | @@ -2922,7 +2922,7 @@ |
2922 | 2922 | |
2923 | 2923 | DBGE("(inode=0x%p, file=0x%p)\n", inode, file); |
2924 | 2924 | |
2925 | - lock_kernel(); | |
2925 | + mutex_lock(&vwsnd_mutex); | |
2926 | 2926 | INC_USE_COUNT; |
2927 | 2927 | for (devc = vwsnd_dev_list; devc; devc = devc->next_dev) |
2928 | 2928 | if ((devc->audio_minor & ~0x0F) == (minor & ~0x0F)) |
... | ... | @@ -2930,7 +2930,7 @@ |
2930 | 2930 | |
2931 | 2931 | if (devc == NULL) { |
2932 | 2932 | DEC_USE_COUNT; |
2933 | - unlock_kernel(); | |
2933 | + mutex_unlock(&vwsnd_mutex); | |
2934 | 2934 | return -ENODEV; |
2935 | 2935 | } |
2936 | 2936 | |
2937 | 2937 | |
... | ... | @@ -2939,13 +2939,13 @@ |
2939 | 2939 | mutex_unlock(&devc->open_mutex); |
2940 | 2940 | if (file->f_flags & O_NONBLOCK) { |
2941 | 2941 | DEC_USE_COUNT; |
2942 | - unlock_kernel(); | |
2942 | + mutex_unlock(&vwsnd_mutex); | |
2943 | 2943 | return -EBUSY; |
2944 | 2944 | } |
2945 | 2945 | interruptible_sleep_on(&devc->open_wait); |
2946 | 2946 | if (signal_pending(current)) { |
2947 | 2947 | DEC_USE_COUNT; |
2948 | - unlock_kernel(); | |
2948 | + mutex_unlock(&vwsnd_mutex); | |
2949 | 2949 | return -ERESTARTSYS; |
2950 | 2950 | } |
2951 | 2951 | mutex_lock(&devc->open_mutex); |
... | ... | @@ -2998,7 +2998,7 @@ |
2998 | 2998 | |
2999 | 2999 | file->private_data = devc; |
3000 | 3000 | DBGRV(); |
3001 | - unlock_kernel(); | |
3001 | + mutex_unlock(&vwsnd_mutex); | |
3002 | 3002 | return 0; |
3003 | 3003 | } |
3004 | 3004 | |
... | ... | @@ -3012,7 +3012,7 @@ |
3012 | 3012 | vwsnd_port_t *wport = NULL, *rport = NULL; |
3013 | 3013 | int err = 0; |
3014 | 3014 | |
3015 | - lock_kernel(); | |
3015 | + mutex_lock(&vwsnd_mutex); | |
3016 | 3016 | mutex_lock(&devc->io_mutex); |
3017 | 3017 | { |
3018 | 3018 | DBGEV("(inode=0x%p, file=0x%p)\n", inode, file); |
... | ... | @@ -3040,7 +3040,7 @@ |
3040 | 3040 | wake_up(&devc->open_wait); |
3041 | 3041 | DEC_USE_COUNT; |
3042 | 3042 | DBGR(); |
3043 | - unlock_kernel(); | |
3043 | + mutex_unlock(&vwsnd_mutex); | |
3044 | 3044 | return err; |
3045 | 3045 | } |
3046 | 3046 | |
3047 | 3047 | |
3048 | 3048 | |
... | ... | @@ -3068,18 +3068,18 @@ |
3068 | 3068 | DBGEV("(inode=0x%p, file=0x%p)\n", inode, file); |
3069 | 3069 | |
3070 | 3070 | INC_USE_COUNT; |
3071 | - lock_kernel(); | |
3071 | + mutex_lock(&vwsnd_mutex); | |
3072 | 3072 | for (devc = vwsnd_dev_list; devc; devc = devc->next_dev) |
3073 | 3073 | if (devc->mixer_minor == iminor(inode)) |
3074 | 3074 | break; |
3075 | 3075 | |
3076 | 3076 | if (devc == NULL) { |
3077 | 3077 | DEC_USE_COUNT; |
3078 | - unlock_kernel(); | |
3078 | + mutex_unlock(&vwsnd_mutex); | |
3079 | 3079 | return -ENODEV; |
3080 | 3080 | } |
3081 | 3081 | file->private_data = devc; |
3082 | - unlock_kernel(); | |
3082 | + mutex_unlock(&vwsnd_mutex); | |
3083 | 3083 | return 0; |
3084 | 3084 | } |
3085 | 3085 | |
... | ... | @@ -3223,7 +3223,7 @@ |
3223 | 3223 | |
3224 | 3224 | DBGEV("(devc=0x%p, cmd=0x%x, arg=0x%lx)\n", devc, cmd, arg); |
3225 | 3225 | |
3226 | - lock_kernel(); | |
3226 | + mutex_lock(&vwsnd_mutex); | |
3227 | 3227 | mutex_lock(&devc->mix_mutex); |
3228 | 3228 | { |
3229 | 3229 | if ((cmd & ~nrmask) == MIXER_READ(0)) |
... | ... | @@ -3234,7 +3234,7 @@ |
3234 | 3234 | retval = -EINVAL; |
3235 | 3235 | } |
3236 | 3236 | mutex_unlock(&devc->mix_mutex); |
3237 | - unlock_kernel(); | |
3237 | + mutex_unlock(&vwsnd_mutex); | |
3238 | 3238 | return retval; |
3239 | 3239 | } |
3240 | 3240 |