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>
This commit is contained in:
Trent Piepho 2007-10-10 05:37:42 -03:00 committed by Mauro Carvalho Chehab
parent 805a439241
commit 6d28e98906
4 changed files with 35 additions and 64 deletions

View File

@ -890,7 +890,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
const struct pci_device_id *pci_id)
{
struct saa7134_dev *dev;
struct list_head *item;
struct saa7134_mpeg_ops *mops;
int err;
@ -1072,10 +1071,8 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
saa7134_devcount++;
mutex_lock(&devlist_lock);
list_for_each(item,&mops_list) {
mops = list_entry(item, struct saa7134_mpeg_ops, next);
list_for_each_entry(mops, &mops_list, next)
mpeg_ops_attach(mops, dev);
}
list_add_tail(&dev->devlist,&saa7134_devlist);
mutex_unlock(&devlist_lock);
@ -1109,7 +1106,6 @@ static int __devinit saa7134_initdev(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 list_head *item;
struct saa7134_mpeg_ops *mops;
/* Release DMA sound modules if present */
@ -1138,10 +1134,8 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
/* unregister */
mutex_lock(&devlist_lock);
list_del(&dev->devlist);
list_for_each(item,&mops_list) {
mops = list_entry(item, struct saa7134_mpeg_ops, next);
list_for_each_entry(mops, &mops_list, next)
mpeg_ops_detach(mops, dev);
}
mutex_unlock(&devlist_lock);
saa7134_devcount--;
@ -1237,14 +1231,11 @@ static int saa7134_resume(struct pci_dev *pci_dev)
int saa7134_ts_register(struct saa7134_mpeg_ops *ops)
{
struct list_head *item;
struct saa7134_dev *dev;
mutex_lock(&devlist_lock);
list_for_each(item,&saa7134_devlist) {
dev = list_entry(item, struct saa7134_dev, devlist);
list_for_each_entry(dev, &saa7134_devlist, devlist)
mpeg_ops_attach(ops, dev);
}
list_add_tail(&ops->next,&mops_list);
mutex_unlock(&devlist_lock);
return 0;
@ -1252,15 +1243,12 @@ int saa7134_ts_register(struct saa7134_mpeg_ops *ops)
void saa7134_ts_unregister(struct saa7134_mpeg_ops *ops)
{
struct list_head *item;
struct saa7134_dev *dev;
mutex_lock(&devlist_lock);
list_del(&ops->next);
list_for_each(item,&saa7134_devlist) {
dev = list_entry(item, struct saa7134_dev, devlist);
list_for_each_entry(dev, &saa7134_devlist, devlist)
mpeg_ops_detach(ops, dev);
}
mutex_unlock(&devlist_lock);
}

View File

@ -76,17 +76,14 @@ static int ts_init_encoder(struct saa7134_dev* dev)
static int ts_open(struct inode *inode, struct file *file)
{
int minor = iminor(inode);
struct saa7134_dev *h,*dev = NULL;
struct list_head *list;
struct saa7134_dev *dev;
int err;
list_for_each(list,&saa7134_devlist) {
h = list_entry(list, struct saa7134_dev, devlist);
if (h->empress_dev && h->empress_dev->minor == minor)
dev = h;
}
if (NULL == dev)
list_for_each_entry(dev, &saa7134_devlist, devlist)
if (dev->empress_dev && dev->empress_dev->minor == minor)
goto found;
return -ENODEV;
found:
dprintk("open minor=%d\n",minor);
err = -EBUSY;

View File

@ -239,17 +239,14 @@ static int dsp_rec_stop(struct saa7134_dev *dev)
static int dsp_open(struct inode *inode, struct file *file)
{
int minor = iminor(inode);
struct saa7134_dev *h,*dev = NULL;
struct list_head *list;
struct saa7134_dev *dev;
int err;
list_for_each(list,&saa7134_devlist) {
h = list_entry(list, struct saa7134_dev, devlist);
if (h->dmasound.minor_dsp == minor)
dev = h;
}
if (NULL == dev)
list_for_each_entry(dev, &saa7134_devlist, devlist)
if (dev->dmasound.minor_dsp == minor)
goto found;
return -ENODEV;
found:
mutex_lock(&dev->dmasound.lock);
err = -EBUSY;
@ -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)
{
int minor = iminor(inode);
struct saa7134_dev *h,*dev = NULL;
struct list_head *list;
list_for_each(list,&saa7134_devlist) {
h = list_entry(list, struct saa7134_dev, devlist);
if (h->dmasound.minor_mixer == minor)
dev = h;
}
if (NULL == dev)
return -ENODEV;
struct saa7134_dev *dev;
list_for_each_entry(dev, &saa7134_devlist, devlist)
if (dev->dmasound.minor_mixer == minor) {
file->private_data = dev;
return 0;
}
return -ENODEV;
}
static int mixer_release(struct inode *inode, struct file *file)
@ -1022,18 +1014,14 @@ static int saa7134_oss_init(void)
static void saa7134_oss_exit(void)
{
struct saa7134_dev *dev = NULL;
struct list_head *list;
list_for_each(list,&saa7134_devlist) {
dev = list_entry(list, struct saa7134_dev, devlist);
struct saa7134_dev *dev;
list_for_each_entry(dev, &saa7134_devlist, devlist) {
/* Device isn't registered by OSS, probably ALSA's */
if (!dev->dmasound.minor_dsp)
continue;
oss_device_exit(dev);
}
saa7134_dmasound_init = NULL;

View File

@ -1285,26 +1285,24 @@ static int saa7134_resource(struct saa7134_fh *fh)
static int video_open(struct inode *inode, struct file *file)
{
int minor = iminor(inode);
struct saa7134_dev *h,*dev = NULL;
struct saa7134_dev *dev;
struct saa7134_fh *fh;
struct list_head *list;
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
int radio = 0;
list_for_each(list,&saa7134_devlist) {
h = list_entry(list, struct saa7134_dev, devlist);
if (h->video_dev && (h->video_dev->minor == minor))
dev = h;
if (h->radio_dev && (h->radio_dev->minor == minor)) {
list_for_each_entry(dev, &saa7134_devlist, devlist) {
if (dev->video_dev && (dev->video_dev->minor == minor))
goto found;
if (dev->radio_dev && (dev->radio_dev->minor == minor)) {
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;
dev = h;
goto found;
}
}
if (NULL == dev)
return -ENODEV;
found:
dprintk("open minor=%d radio=%d type=%s\n",minor,radio,
v4l2_type_names[type]);