aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2007-10-10 04:37:42 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-10 12:35:07 -0400
commit6d28e98906aa9405895f92348543d08da1837ea5 (patch)
tree3f92cb9777405d0576f36b86501820c191deab3d
parent805a43924158e4eb2bffc4cac0aedcfb42a89469 (diff)
V4L/DVB (6314): saa7134: Replace list_for_each+list_entry with list_for_each_entry
A couple loops weren't changed because they expected the loop iterator to be left as NULL if the list was empty. Maybe the code should just check for that first, then loop? Adjust some of the loop logic to be simpler. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c20
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c15
-rw-r--r--drivers/media/video/saa7134/saa7134-oss.c42
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c22
4 files changed, 35 insertions, 64 deletions
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index 80f04f252fc..1a4a24471f2 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -890,7 +890,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
890 const struct pci_device_id *pci_id) 890 const struct pci_device_id *pci_id)
891{ 891{
892 struct saa7134_dev *dev; 892 struct saa7134_dev *dev;
893 struct list_head *item;
894 struct saa7134_mpeg_ops *mops; 893 struct saa7134_mpeg_ops *mops;
895 int err; 894 int err;
896 895
@@ -1072,10 +1071,8 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
1072 saa7134_devcount++; 1071 saa7134_devcount++;
1073 1072
1074 mutex_lock(&devlist_lock); 1073 mutex_lock(&devlist_lock);
1075 list_for_each(item,&mops_list) { 1074 list_for_each_entry(mops, &mops_list, next)
1076 mops = list_entry(item, struct saa7134_mpeg_ops, next);
1077 mpeg_ops_attach(mops, dev); 1075 mpeg_ops_attach(mops, dev);
1078 }
1079 list_add_tail(&dev->devlist,&saa7134_devlist); 1076 list_add_tail(&dev->devlist,&saa7134_devlist);
1080 mutex_unlock(&devlist_lock); 1077 mutex_unlock(&devlist_lock);
1081 1078
@@ -1109,7 +1106,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
1109static void __devexit saa7134_finidev(struct pci_dev *pci_dev) 1106static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
1110{ 1107{
1111 struct saa7134_dev *dev = pci_get_drvdata(pci_dev); 1108 struct saa7134_dev *dev = pci_get_drvdata(pci_dev);
1112 struct list_head *item;
1113 struct saa7134_mpeg_ops *mops; 1109 struct saa7134_mpeg_ops *mops;
1114 1110
1115 /* Release DMA sound modules if present */ 1111 /* Release DMA sound modules if present */
@@ -1138,10 +1134,8 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
1138 /* unregister */ 1134 /* unregister */
1139 mutex_lock(&devlist_lock); 1135 mutex_lock(&devlist_lock);
1140 list_del(&dev->devlist); 1136 list_del(&dev->devlist);
1141 list_for_each(item,&mops_list) { 1137 list_for_each_entry(mops, &mops_list, next)
1142 mops = list_entry(item, struct saa7134_mpeg_ops, next);
1143 mpeg_ops_detach(mops, dev); 1138 mpeg_ops_detach(mops, dev);
1144 }
1145 mutex_unlock(&devlist_lock); 1139 mutex_unlock(&devlist_lock);
1146 saa7134_devcount--; 1140 saa7134_devcount--;
1147 1141
@@ -1237,14 +1231,11 @@ static int saa7134_resume(struct pci_dev *pci_dev)
1237 1231
1238int saa7134_ts_register(struct saa7134_mpeg_ops *ops) 1232int saa7134_ts_register(struct saa7134_mpeg_ops *ops)
1239{ 1233{
1240 struct list_head *item;
1241 struct saa7134_dev *dev; 1234 struct saa7134_dev *dev;
1242 1235
1243 mutex_lock(&devlist_lock); 1236 mutex_lock(&devlist_lock);
1244 list_for_each(item,&saa7134_devlist) { 1237 list_for_each_entry(dev, &saa7134_devlist, devlist)
1245 dev = list_entry(item, struct saa7134_dev, devlist);
1246 mpeg_ops_attach(ops, dev); 1238 mpeg_ops_attach(ops, dev);
1247 }
1248 list_add_tail(&ops->next,&mops_list); 1239 list_add_tail(&ops->next,&mops_list);
1249 mutex_unlock(&devlist_lock); 1240 mutex_unlock(&devlist_lock);
1250 return 0; 1241 return 0;
@@ -1252,15 +1243,12 @@ int saa7134_ts_register(struct saa7134_mpeg_ops *ops)
1252 1243
1253void saa7134_ts_unregister(struct saa7134_mpeg_ops *ops) 1244void saa7134_ts_unregister(struct saa7134_mpeg_ops *ops)
1254{ 1245{
1255 struct list_head *item;
1256 struct saa7134_dev *dev; 1246 struct saa7134_dev *dev;
1257 1247
1258 mutex_lock(&devlist_lock); 1248 mutex_lock(&devlist_lock);
1259 list_del(&ops->next); 1249 list_del(&ops->next);
1260 list_for_each(item,&saa7134_devlist) { 1250 list_for_each_entry(dev, &saa7134_devlist, devlist)
1261 dev = list_entry(item, struct saa7134_dev, devlist);
1262 mpeg_ops_detach(ops, dev); 1251 mpeg_ops_detach(ops, dev);
1263 }
1264 mutex_unlock(&devlist_lock); 1252 mutex_unlock(&devlist_lock);
1265} 1253}
1266 1254
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index a16df57af63..34ca874dd7f 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -76,17 +76,14 @@ static int ts_init_encoder(struct saa7134_dev* dev)
76static int ts_open(struct inode *inode, struct file *file) 76static int ts_open(struct inode *inode, struct file *file)
77{ 77{
78 int minor = iminor(inode); 78 int minor = iminor(inode);
79 struct saa7134_dev *h,*dev = NULL; 79 struct saa7134_dev *dev;
80 struct list_head *list;
81 int err; 80 int err;
82 81
83 list_for_each(list,&saa7134_devlist) { 82 list_for_each_entry(dev, &saa7134_devlist, devlist)
84 h = list_entry(list, struct saa7134_dev, devlist); 83 if (dev->empress_dev && dev->empress_dev->minor == minor)
85 if (h->empress_dev && h->empress_dev->minor == minor) 84 goto found;
86 dev = h; 85 return -ENODEV;
87 } 86 found:
88 if (NULL == dev)
89 return -ENODEV;
90 87
91 dprintk("open minor=%d\n",minor); 88 dprintk("open minor=%d\n",minor);
92 err = -EBUSY; 89 err = -EBUSY;
diff --git a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c
index 1a737b64736..aedf04653e0 100644
--- a/drivers/media/video/saa7134/saa7134-oss.c
+++ b/drivers/media/video/saa7134/saa7134-oss.c
@@ -239,17 +239,14 @@ static int dsp_rec_stop(struct saa7134_dev *dev)
239static int dsp_open(struct inode *inode, struct file *file) 239static int dsp_open(struct inode *inode, struct file *file)
240{ 240{
241 int minor = iminor(inode); 241 int minor = iminor(inode);
242 struct saa7134_dev *h,*dev = NULL; 242 struct saa7134_dev *dev;
243 struct list_head *list;
244 int err; 243 int err;
245 244
246 list_for_each(list,&saa7134_devlist) { 245 list_for_each_entry(dev, &saa7134_devlist, devlist)
247 h = list_entry(list, struct saa7134_dev, devlist); 246 if (dev->dmasound.minor_dsp == minor)
248 if (h->dmasound.minor_dsp == minor) 247 goto found;
249 dev = h; 248 return -ENODEV;
250 } 249 found:
251 if (NULL == dev)
252 return -ENODEV;
253 250
254 mutex_lock(&dev->dmasound.lock); 251 mutex_lock(&dev->dmasound.lock);
255 err = -EBUSY; 252 err = -EBUSY;
@@ -680,19 +677,14 @@ mixer_level(struct saa7134_dev *dev, enum saa7134_audio_in src, int level)
680static int mixer_open(struct inode *inode, struct file *file) 677static int mixer_open(struct inode *inode, struct file *file)
681{ 678{
682 int minor = iminor(inode); 679 int minor = iminor(inode);
683 struct saa7134_dev *h,*dev = NULL; 680 struct saa7134_dev *dev;
684 struct list_head *list;
685 681
686 list_for_each(list,&saa7134_devlist) { 682 list_for_each_entry(dev, &saa7134_devlist, devlist)
687 h = list_entry(list, struct saa7134_dev, devlist); 683 if (dev->dmasound.minor_mixer == minor) {
688 if (h->dmasound.minor_mixer == minor) 684 file->private_data = dev;
689 dev = h; 685 return 0;
690 } 686 }
691 if (NULL == dev) 687 return -ENODEV;
692 return -ENODEV;
693
694 file->private_data = dev;
695 return 0;
696} 688}
697 689
698static int mixer_release(struct inode *inode, struct file *file) 690static int mixer_release(struct inode *inode, struct file *file)
@@ -1022,18 +1014,14 @@ static int saa7134_oss_init(void)
1022 1014
1023static void saa7134_oss_exit(void) 1015static void saa7134_oss_exit(void)
1024{ 1016{
1025 struct saa7134_dev *dev = NULL; 1017 struct saa7134_dev *dev;
1026 struct list_head *list;
1027
1028 list_for_each(list,&saa7134_devlist) {
1029 dev = list_entry(list, struct saa7134_dev, devlist);
1030 1018
1019 list_for_each_entry(dev, &saa7134_devlist, devlist) {
1031 /* Device isn't registered by OSS, probably ALSA's */ 1020 /* Device isn't registered by OSS, probably ALSA's */
1032 if (!dev->dmasound.minor_dsp) 1021 if (!dev->dmasound.minor_dsp)
1033 continue; 1022 continue;
1034 1023
1035 oss_device_exit(dev); 1024 oss_device_exit(dev);
1036
1037 } 1025 }
1038 1026
1039 saa7134_dmasound_init = NULL; 1027 saa7134_dmasound_init = NULL;
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index 7c97ac15e66..471b92793c1 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -1285,26 +1285,24 @@ static int saa7134_resource(struct saa7134_fh *fh)
1285static int video_open(struct inode *inode, struct file *file) 1285static int video_open(struct inode *inode, struct file *file)
1286{ 1286{
1287 int minor = iminor(inode); 1287 int minor = iminor(inode);
1288 struct saa7134_dev *h,*dev = NULL; 1288 struct saa7134_dev *dev;
1289 struct saa7134_fh *fh; 1289 struct saa7134_fh *fh;
1290 struct list_head *list;
1291 enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1290 enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1292 int radio = 0; 1291 int radio = 0;
1293 list_for_each(list,&saa7134_devlist) { 1292 list_for_each_entry(dev, &saa7134_devlist, devlist) {
1294 h = list_entry(list, struct saa7134_dev, devlist); 1293 if (dev->video_dev && (dev->video_dev->minor == minor))
1295 if (h->video_dev && (h->video_dev->minor == minor)) 1294 goto found;
1296 dev = h; 1295 if (dev->radio_dev && (dev->radio_dev->minor == minor)) {
1297 if (h->radio_dev && (h->radio_dev->minor == minor)) {
1298 radio = 1; 1296 radio = 1;
1299 dev = h; 1297 goto found;
1300 } 1298 }
1301 if (h->vbi_dev && (h->vbi_dev->minor == minor)) { 1299 if (dev->vbi_dev && (dev->vbi_dev->minor == minor)) {
1302 type = V4L2_BUF_TYPE_VBI_CAPTURE; 1300 type = V4L2_BUF_TYPE_VBI_CAPTURE;
1303 dev = h; 1301 goto found;
1304 } 1302 }
1305 } 1303 }
1306 if (NULL == dev) 1304 return -ENODEV;
1307 return -ENODEV; 1305 found:
1308 1306
1309 dprintk("open minor=%d radio=%d type=%s\n",minor,radio, 1307 dprintk("open minor=%d radio=%d type=%s\n",minor,radio,
1310 v4l2_type_names[type]); 1308 v4l2_type_names[type]);