提交 6d28e989 编写于 作者: T Trent Piepho 提交者: Mauro Carvalho Chehab

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: NTrent Piepho <xyzzy@speakeasy.org>
Signed-off-by: NMauro Carvalho Chehab <mchehab@infradead.org>
上级 805a4392
...@@ -890,7 +890,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, ...@@ -890,7 +890,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
const struct pci_device_id *pci_id) const struct pci_device_id *pci_id)
{ {
struct saa7134_dev *dev; struct saa7134_dev *dev;
struct list_head *item;
struct saa7134_mpeg_ops *mops; struct saa7134_mpeg_ops *mops;
int err; int err;
...@@ -1072,10 +1071,8 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, ...@@ -1072,10 +1071,8 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
saa7134_devcount++; saa7134_devcount++;
mutex_lock(&devlist_lock); mutex_lock(&devlist_lock);
list_for_each(item,&mops_list) { list_for_each_entry(mops, &mops_list, next)
mops = list_entry(item, struct saa7134_mpeg_ops, next);
mpeg_ops_attach(mops, dev); mpeg_ops_attach(mops, dev);
}
list_add_tail(&dev->devlist,&saa7134_devlist); list_add_tail(&dev->devlist,&saa7134_devlist);
mutex_unlock(&devlist_lock); mutex_unlock(&devlist_lock);
...@@ -1109,7 +1106,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, ...@@ -1109,7 +1106,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
static void __devexit saa7134_finidev(struct pci_dev *pci_dev) static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
{ {
struct saa7134_dev *dev = pci_get_drvdata(pci_dev); struct saa7134_dev *dev = pci_get_drvdata(pci_dev);
struct list_head *item;
struct saa7134_mpeg_ops *mops; struct saa7134_mpeg_ops *mops;
/* Release DMA sound modules if present */ /* Release DMA sound modules if present */
...@@ -1138,10 +1134,8 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev) ...@@ -1138,10 +1134,8 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
/* unregister */ /* unregister */
mutex_lock(&devlist_lock); mutex_lock(&devlist_lock);
list_del(&dev->devlist); list_del(&dev->devlist);
list_for_each(item,&mops_list) { list_for_each_entry(mops, &mops_list, next)
mops = list_entry(item, struct saa7134_mpeg_ops, next);
mpeg_ops_detach(mops, dev); mpeg_ops_detach(mops, dev);
}
mutex_unlock(&devlist_lock); mutex_unlock(&devlist_lock);
saa7134_devcount--; saa7134_devcount--;
...@@ -1237,14 +1231,11 @@ static int saa7134_resume(struct pci_dev *pci_dev) ...@@ -1237,14 +1231,11 @@ static int saa7134_resume(struct pci_dev *pci_dev)
int saa7134_ts_register(struct saa7134_mpeg_ops *ops) int saa7134_ts_register(struct saa7134_mpeg_ops *ops)
{ {
struct list_head *item;
struct saa7134_dev *dev; struct saa7134_dev *dev;
mutex_lock(&devlist_lock); mutex_lock(&devlist_lock);
list_for_each(item,&saa7134_devlist) { list_for_each_entry(dev, &saa7134_devlist, devlist)
dev = list_entry(item, struct saa7134_dev, devlist);
mpeg_ops_attach(ops, dev); mpeg_ops_attach(ops, dev);
}
list_add_tail(&ops->next,&mops_list); list_add_tail(&ops->next,&mops_list);
mutex_unlock(&devlist_lock); mutex_unlock(&devlist_lock);
return 0; return 0;
...@@ -1252,15 +1243,12 @@ int saa7134_ts_register(struct saa7134_mpeg_ops *ops) ...@@ -1252,15 +1243,12 @@ int saa7134_ts_register(struct saa7134_mpeg_ops *ops)
void saa7134_ts_unregister(struct saa7134_mpeg_ops *ops) void saa7134_ts_unregister(struct saa7134_mpeg_ops *ops)
{ {
struct list_head *item;
struct saa7134_dev *dev; struct saa7134_dev *dev;
mutex_lock(&devlist_lock); mutex_lock(&devlist_lock);
list_del(&ops->next); list_del(&ops->next);
list_for_each(item,&saa7134_devlist) { list_for_each_entry(dev, &saa7134_devlist, devlist)
dev = list_entry(item, struct saa7134_dev, devlist);
mpeg_ops_detach(ops, dev); mpeg_ops_detach(ops, dev);
}
mutex_unlock(&devlist_lock); mutex_unlock(&devlist_lock);
} }
......
...@@ -76,17 +76,14 @@ static int ts_init_encoder(struct saa7134_dev* dev) ...@@ -76,17 +76,14 @@ static int ts_init_encoder(struct saa7134_dev* dev)
static int ts_open(struct inode *inode, struct file *file) static int ts_open(struct inode *inode, struct file *file)
{ {
int minor = iminor(inode); int minor = iminor(inode);
struct saa7134_dev *h,*dev = NULL; struct saa7134_dev *dev;
struct list_head *list;
int err; int err;
list_for_each(list,&saa7134_devlist) { list_for_each_entry(dev, &saa7134_devlist, devlist)
h = list_entry(list, struct saa7134_dev, devlist); if (dev->empress_dev && dev->empress_dev->minor == minor)
if (h->empress_dev && h->empress_dev->minor == minor) goto found;
dev = h; return -ENODEV;
} found:
if (NULL == dev)
return -ENODEV;
dprintk("open minor=%d\n",minor); dprintk("open minor=%d\n",minor);
err = -EBUSY; err = -EBUSY;
......
...@@ -239,17 +239,14 @@ static int dsp_rec_stop(struct saa7134_dev *dev) ...@@ -239,17 +239,14 @@ static int dsp_rec_stop(struct saa7134_dev *dev)
static int dsp_open(struct inode *inode, struct file *file) static int dsp_open(struct inode *inode, struct file *file)
{ {
int minor = iminor(inode); int minor = iminor(inode);
struct saa7134_dev *h,*dev = NULL; struct saa7134_dev *dev;
struct list_head *list;
int err; int err;
list_for_each(list,&saa7134_devlist) { list_for_each_entry(dev, &saa7134_devlist, devlist)
h = list_entry(list, struct saa7134_dev, devlist); if (dev->dmasound.minor_dsp == minor)
if (h->dmasound.minor_dsp == minor) goto found;
dev = h; return -ENODEV;
} found:
if (NULL == dev)
return -ENODEV;
mutex_lock(&dev->dmasound.lock); mutex_lock(&dev->dmasound.lock);
err = -EBUSY; err = -EBUSY;
...@@ -680,19 +677,14 @@ mixer_level(struct saa7134_dev *dev, enum saa7134_audio_in src, int level) ...@@ -680,19 +677,14 @@ mixer_level(struct saa7134_dev *dev, enum saa7134_audio_in src, int level)
static int mixer_open(struct inode *inode, struct file *file) static int mixer_open(struct inode *inode, struct file *file)
{ {
int minor = iminor(inode); int minor = iminor(inode);
struct saa7134_dev *h,*dev = NULL; struct saa7134_dev *dev;
struct list_head *list;
list_for_each(list,&saa7134_devlist) { list_for_each_entry(dev, &saa7134_devlist, devlist)
h = list_entry(list, struct saa7134_dev, devlist); if (dev->dmasound.minor_mixer == minor) {
if (h->dmasound.minor_mixer == minor) file->private_data = dev;
dev = h; return 0;
} }
if (NULL == dev) return -ENODEV;
return -ENODEV;
file->private_data = dev;
return 0;
} }
static int mixer_release(struct inode *inode, struct file *file) static int mixer_release(struct inode *inode, struct file *file)
...@@ -1022,18 +1014,14 @@ static int saa7134_oss_init(void) ...@@ -1022,18 +1014,14 @@ static int saa7134_oss_init(void)
static void saa7134_oss_exit(void) static void saa7134_oss_exit(void)
{ {
struct saa7134_dev *dev = NULL; struct saa7134_dev *dev;
struct list_head *list;
list_for_each(list,&saa7134_devlist) {
dev = list_entry(list, struct saa7134_dev, devlist);
list_for_each_entry(dev, &saa7134_devlist, devlist) {
/* Device isn't registered by OSS, probably ALSA's */ /* Device isn't registered by OSS, probably ALSA's */
if (!dev->dmasound.minor_dsp) if (!dev->dmasound.minor_dsp)
continue; continue;
oss_device_exit(dev); oss_device_exit(dev);
} }
saa7134_dmasound_init = NULL; saa7134_dmasound_init = NULL;
......
...@@ -1285,26 +1285,24 @@ static int saa7134_resource(struct saa7134_fh *fh) ...@@ -1285,26 +1285,24 @@ static int saa7134_resource(struct saa7134_fh *fh)
static int video_open(struct inode *inode, struct file *file) static int video_open(struct inode *inode, struct file *file)
{ {
int minor = iminor(inode); int minor = iminor(inode);
struct saa7134_dev *h,*dev = NULL; struct saa7134_dev *dev;
struct saa7134_fh *fh; struct saa7134_fh *fh;
struct list_head *list;
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
int radio = 0; int radio = 0;
list_for_each(list,&saa7134_devlist) { list_for_each_entry(dev, &saa7134_devlist, devlist) {
h = list_entry(list, struct saa7134_dev, devlist); if (dev->video_dev && (dev->video_dev->minor == minor))
if (h->video_dev && (h->video_dev->minor == minor)) goto found;
dev = h; if (dev->radio_dev && (dev->radio_dev->minor == minor)) {
if (h->radio_dev && (h->radio_dev->minor == minor)) {
radio = 1; radio = 1;
dev = h; goto found;
} }
if (h->vbi_dev && (h->vbi_dev->minor == minor)) { if (dev->vbi_dev && (dev->vbi_dev->minor == minor)) {
type = V4L2_BUF_TYPE_VBI_CAPTURE; type = V4L2_BUF_TYPE_VBI_CAPTURE;
dev = h; goto found;
} }
} }
if (NULL == dev) return -ENODEV;
return -ENODEV; found:
dprintk("open minor=%d radio=%d type=%s\n",minor,radio, dprintk("open minor=%d radio=%d type=%s\n",minor,radio,
v4l2_type_names[type]); v4l2_type_names[type]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册