V4L/DVB (3380): Semaphore to mutex conversion on drivers/media

- Semaphore to mutex conversion.
The conversion was generated via scripts, and the result was validated
automatically via a script as well.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>

authored by Ingo Molnar and committed by Mauro Carvalho Chehab 1e4baed3 7d83e843

+45 -43
+11 -11
drivers/media/dvb/dvb-core/dvbdev.c
··· 33 33 #include <linux/device.h> 34 34 #include <linux/fs.h> 35 35 #include <linux/cdev.h> 36 - 36 + #include <linux/mutex.h> 37 37 #include "dvbdev.h" 38 38 39 39 static int dvbdev_debug; ··· 44 44 #define dprintk if (dvbdev_debug) printk 45 45 46 46 static LIST_HEAD(dvb_adapter_list); 47 - static DECLARE_MUTEX(dvbdev_register_lock); 47 + static DEFINE_MUTEX(dvbdev_register_lock); 48 48 49 49 static const char * const dnames[] = { 50 50 "video", "audio", "sec", "frontend", "demux", "dvr", "ca", ··· 202 202 struct dvb_device *dvbdev; 203 203 int id; 204 204 205 - if (down_interruptible (&dvbdev_register_lock)) 205 + if (mutex_lock_interruptible(&dvbdev_register_lock)) 206 206 return -ERESTARTSYS; 207 207 208 208 if ((id = dvbdev_get_free_id (adap, type)) < 0) { 209 - up (&dvbdev_register_lock); 209 + mutex_unlock(&dvbdev_register_lock); 210 210 *pdvbdev = NULL; 211 211 printk ("%s: could get find free device id...\n", __FUNCTION__); 212 212 return -ENFILE; ··· 215 215 *pdvbdev = dvbdev = kmalloc(sizeof(struct dvb_device), GFP_KERNEL); 216 216 217 217 if (!dvbdev) { 218 - up(&dvbdev_register_lock); 218 + mutex_unlock(&dvbdev_register_lock); 219 219 return -ENOMEM; 220 220 } 221 221 222 - up (&dvbdev_register_lock); 222 + mutex_unlock(&dvbdev_register_lock); 223 223 224 224 memcpy(dvbdev, template, sizeof(struct dvb_device)); 225 225 dvbdev->type = type; ··· 289 289 { 290 290 int num; 291 291 292 - if (down_interruptible (&dvbdev_register_lock)) 292 + if (mutex_lock_interruptible(&dvbdev_register_lock)) 293 293 return -ERESTARTSYS; 294 294 295 295 if ((num = dvbdev_get_free_adapter_num ()) < 0) { 296 - up (&dvbdev_register_lock); 296 + mutex_unlock(&dvbdev_register_lock); 297 297 return -ENFILE; 298 298 } 299 299 ··· 309 309 310 310 list_add_tail (&adap->list_head, &dvb_adapter_list); 311 311 312 - up (&dvbdev_register_lock); 312 + mutex_unlock(&dvbdev_register_lock); 313 313 314 314 return num; 315 315 } ··· 320 320 { 321 321 devfs_remove("dvb/adapter%d", adap->num); 322 322 323 - if (down_interruptible (&dvbdev_register_lock)) 323 + if (mutex_lock_interruptible(&dvbdev_register_lock)) 324 324 return -ERESTARTSYS; 325 325 list_del (&adap->list_head); 326 - up (&dvbdev_register_lock); 326 + mutex_unlock(&dvbdev_register_lock); 327 327 return 0; 328 328 } 329 329 EXPORT_SYMBOL(dvb_unregister_adapter);
+8 -7
drivers/media/video/cx88/cx88-core.c
··· 32 32 #include <linux/pci.h> 33 33 #include <linux/delay.h> 34 34 #include <linux/videodev2.h> 35 + #include <linux/mutex.h> 35 36 36 37 #include "cx88.h" 37 38 #include <media/v4l2-common.h> ··· 76 75 77 76 static unsigned int cx88_devcount; 78 77 static LIST_HEAD(cx88_devlist); 79 - static DECLARE_MUTEX(devlist); 78 + static DEFINE_MUTEX(devlist); 80 79 81 80 #define NO_SYNC_LINE (-1U) 82 81 ··· 1037 1036 struct list_head *item; 1038 1037 int i; 1039 1038 1040 - down(&devlist); 1039 + mutex_lock(&devlist); 1041 1040 list_for_each(item,&cx88_devlist) { 1042 1041 core = list_entry(item, struct cx88_core, devlist); 1043 1042 if (pci->bus->number != core->pci_bus) ··· 1048 1047 if (0 != get_ressources(core,pci)) 1049 1048 goto fail_unlock; 1050 1049 atomic_inc(&core->refcount); 1051 - up(&devlist); 1050 + mutex_unlock(&devlist); 1052 1051 return core; 1053 1052 } 1054 1053 core = kzalloc(sizeof(*core),GFP_KERNEL); ··· 1123 1122 cx88_card_setup(core); 1124 1123 cx88_ir_init(core,pci); 1125 1124 1126 - up(&devlist); 1125 + mutex_unlock(&devlist); 1127 1126 return core; 1128 1127 1129 1128 fail_free: 1130 1129 kfree(core); 1131 1130 fail_unlock: 1132 - up(&devlist); 1131 + mutex_unlock(&devlist); 1133 1132 return NULL; 1134 1133 } 1135 1134 ··· 1141 1140 if (!atomic_dec_and_test(&core->refcount)) 1142 1141 return; 1143 1142 1144 - down(&devlist); 1143 + mutex_lock(&devlist); 1145 1144 cx88_ir_fini(core); 1146 1145 if (0 == core->i2c_rc) 1147 1146 i2c_bit_del_bus(&core->i2c_adap); 1148 1147 list_del(&core->devlist); 1149 1148 iounmap(core->lmmio); 1150 1149 cx88_devcount--; 1151 - up(&devlist); 1150 + mutex_unlock(&devlist); 1152 1151 kfree(core); 1153 1152 } 1154 1153
+4 -3
drivers/media/video/em28xx/em28xx-video.c
··· 29 29 #include <linux/i2c.h> 30 30 #include <linux/version.h> 31 31 #include <linux/video_decoder.h> 32 + #include <linux/mutex.h> 32 33 33 34 #include "em28xx.h" 34 35 #include <media/tuner.h> ··· 192 191 193 192 static struct usb_driver em28xx_usb_driver; 194 193 195 - static DECLARE_MUTEX(em28xx_sysfs_lock); 194 + static DEFINE_MUTEX(em28xx_sysfs_lock); 196 195 static DECLARE_RWSEM(em28xx_disconnect); 197 196 198 197 /********************* v4l2 interface ******************************************/ ··· 395 394 */ 396 395 static void em28xx_release_resources(struct em28xx *dev) 397 396 { 398 - down(&em28xx_sysfs_lock); 397 + mutex_lock(&em28xx_sysfs_lock); 399 398 400 399 em28xx_info("V4L2 device /dev/video%d deregistered\n", 401 400 dev->vdev->minor); ··· 404 403 /* video_unregister_device(dev->vbi_dev); */ 405 404 em28xx_i2c_unregister(dev); 406 405 usb_put_dev(dev->udev); 407 - up(&em28xx_sysfs_lock); 406 + mutex_unlock(&em28xx_sysfs_lock); 408 407 } 409 408 410 409 /*
+10 -9
drivers/media/video/saa7134/saa7134-core.c
··· 31 31 #include <linux/sound.h> 32 32 #include <linux/interrupt.h> 33 33 #include <linux/delay.h> 34 + #include <linux/mutex.h> 34 35 35 36 #include "saa7134-reg.h" 36 37 #include "saa7134.h" ··· 85 84 MODULE_PARM_DESC(tuner, "tuner type"); 86 85 MODULE_PARM_DESC(card, "card type"); 87 86 88 - static DECLARE_MUTEX(devlist_lock); 87 + static DEFINE_MUTEX(devlist_lock); 89 88 LIST_HEAD(saa7134_devlist); 90 89 static LIST_HEAD(mops_list); 91 90 static unsigned int saa7134_devcount; ··· 970 969 pci_set_drvdata(pci_dev,dev); 971 970 saa7134_devcount++; 972 971 973 - down(&devlist_lock); 972 + mutex_lock(&devlist_lock); 974 973 list_for_each(item,&mops_list) { 975 974 mops = list_entry(item, struct saa7134_mpeg_ops, next); 976 975 mpeg_ops_attach(mops, dev); 977 976 } 978 977 list_add_tail(&dev->devlist,&saa7134_devlist); 979 - up(&devlist_lock); 978 + mutex_unlock(&devlist_lock); 980 979 981 980 /* check for signal */ 982 981 saa7134_irq_video_intl(dev); ··· 1032 1031 saa7134_hwfini(dev); 1033 1032 1034 1033 /* unregister */ 1035 - down(&devlist_lock); 1034 + mutex_lock(&devlist_lock); 1036 1035 list_del(&dev->devlist); 1037 1036 list_for_each(item,&mops_list) { 1038 1037 mops = list_entry(item, struct saa7134_mpeg_ops, next); 1039 1038 mpeg_ops_detach(mops, dev); 1040 1039 } 1041 - up(&devlist_lock); 1040 + mutex_unlock(&devlist_lock); 1042 1041 saa7134_devcount--; 1043 1042 1044 1043 saa7134_i2c_unregister(dev); ··· 1072 1071 struct list_head *item; 1073 1072 struct saa7134_dev *dev; 1074 1073 1075 - down(&devlist_lock); 1074 + mutex_lock(&devlist_lock); 1076 1075 list_for_each(item,&saa7134_devlist) { 1077 1076 dev = list_entry(item, struct saa7134_dev, devlist); 1078 1077 mpeg_ops_attach(ops, dev); 1079 1078 } 1080 1079 list_add_tail(&ops->next,&mops_list); 1081 - up(&devlist_lock); 1080 + mutex_unlock(&devlist_lock); 1082 1081 return 0; 1083 1082 } 1084 1083 ··· 1087 1086 struct list_head *item; 1088 1087 struct saa7134_dev *dev; 1089 1088 1090 - down(&devlist_lock); 1089 + mutex_lock(&devlist_lock); 1091 1090 list_del(&ops->next); 1092 1091 list_for_each(item,&saa7134_devlist) { 1093 1092 dev = list_entry(item, struct saa7134_dev, devlist); 1094 1093 mpeg_ops_detach(ops, dev); 1095 1094 } 1096 - up(&devlist_lock); 1095 + mutex_unlock(&devlist_lock); 1097 1096 } 1098 1097 1099 1098 EXPORT_SYMBOL(saa7134_ts_register);
+12 -13
drivers/media/video/videodev.c
··· 29 29 #include <linux/devfs_fs_kernel.h> 30 30 #include <asm/uaccess.h> 31 31 #include <asm/system.h> 32 - #include <asm/semaphore.h> 33 32 34 33 #include <linux/videodev.h> 35 34 ··· 82 83 */ 83 84 84 85 static struct video_device *video_device[VIDEO_NUM_DEVICES]; 85 - static DECLARE_MUTEX(videodev_lock); 86 + static DEFINE_MUTEX(videodev_lock); 86 87 87 88 struct video_device* video_devdata(struct file *file) 88 89 { ··· 101 102 102 103 if(minor>=VIDEO_NUM_DEVICES) 103 104 return -ENODEV; 104 - down(&videodev_lock); 105 + mutex_lock(&videodev_lock); 105 106 vfl=video_device[minor]; 106 107 if(vfl==NULL) { 107 - up(&videodev_lock); 108 + mutex_unlock(&videodev_lock); 108 109 request_module("char-major-%d-%d", VIDEO_MAJOR, minor); 109 - down(&videodev_lock); 110 + mutex_lock(&videodev_lock); 110 111 vfl=video_device[minor]; 111 112 if (vfl==NULL) { 112 - up(&videodev_lock); 113 + mutex_unlock(&videodev_lock); 113 114 return -ENODEV; 114 115 } 115 116 } ··· 122 123 file->f_op = fops_get(old_fops); 123 124 } 124 125 fops_put(old_fops); 125 - up(&videodev_lock); 126 + mutex_unlock(&videodev_lock); 126 127 return err; 127 128 } 128 129 ··· 303 304 } 304 305 305 306 /* pick a minor number */ 306 - down(&videodev_lock); 307 + mutex_lock(&videodev_lock); 307 308 if (nr >= 0 && nr < end-base) { 308 309 /* use the one the driver asked for */ 309 310 i = base+nr; 310 311 if (NULL != video_device[i]) { 311 - up(&videodev_lock); 312 + mutex_unlock(&videodev_lock); 312 313 return -ENFILE; 313 314 } 314 315 } else { ··· 317 318 if (NULL == video_device[i]) 318 319 break; 319 320 if (i == end) { 320 - up(&videodev_lock); 321 + mutex_unlock(&videodev_lock); 321 322 return -ENFILE; 322 323 } 323 324 } 324 325 video_device[i]=vfd; 325 326 vfd->minor=i; 326 - up(&videodev_lock); 327 + mutex_unlock(&videodev_lock); 327 328 328 329 sprintf(vfd->devfs_name, "v4l/%s%d", name_base, i - base); 329 330 devfs_mk_cdev(MKDEV(VIDEO_MAJOR, vfd->minor), ··· 361 362 362 363 void video_unregister_device(struct video_device *vfd) 363 364 { 364 - down(&videodev_lock); 365 + mutex_lock(&videodev_lock); 365 366 if(video_device[vfd->minor]!=vfd) 366 367 panic("videodev: bad unregister"); 367 368 368 369 devfs_remove(vfd->devfs_name); 369 370 video_device[vfd->minor]=NULL; 370 371 class_device_unregister(&vfd->class_dev); 371 - up(&videodev_lock); 372 + mutex_unlock(&videodev_lock); 372 373 } 373 374 374 375