[ALSA] alsa core: convert to list_for_each_entry*
This patch converts most uses of list_for_each to list_for_each_entry all across alsa. In some place apparently an item can be on a list with different pointers so of course that isn't compatible with list_for_each, I therefore didn't touch those places. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
This commit is contained in:
parent
d595ee7e01
commit
9244b2c307
12 changed files with 102 additions and 214 deletions
|
@ -108,7 +108,6 @@ static void snd_ctl_empty_read_queue(struct snd_ctl_file * ctl)
|
|||
static int snd_ctl_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct list_head *list;
|
||||
struct snd_card *card;
|
||||
struct snd_ctl_file *ctl;
|
||||
struct snd_kcontrol *control;
|
||||
|
@ -122,12 +121,10 @@ static int snd_ctl_release(struct inode *inode, struct file *file)
|
|||
list_del(&ctl->list);
|
||||
write_unlock_irqrestore(&card->ctl_files_rwlock, flags);
|
||||
down_write(&card->controls_rwsem);
|
||||
list_for_each(list, &card->controls) {
|
||||
control = snd_kcontrol(list);
|
||||
list_for_each_entry(control, &card->controls, list)
|
||||
for (idx = 0; idx < control->count; idx++)
|
||||
if (control->vd[idx].owner == ctl)
|
||||
control->vd[idx].owner = NULL;
|
||||
}
|
||||
up_write(&card->controls_rwsem);
|
||||
snd_ctl_empty_read_queue(ctl);
|
||||
kfree(ctl);
|
||||
|
@ -140,7 +137,6 @@ void snd_ctl_notify(struct snd_card *card, unsigned int mask,
|
|||
struct snd_ctl_elem_id *id)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct list_head *flist;
|
||||
struct snd_ctl_file *ctl;
|
||||
struct snd_kctl_event *ev;
|
||||
|
||||
|
@ -149,14 +145,11 @@ void snd_ctl_notify(struct snd_card *card, unsigned int mask,
|
|||
#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
|
||||
card->mixer_oss_change_count++;
|
||||
#endif
|
||||
list_for_each(flist, &card->ctl_files) {
|
||||
struct list_head *elist;
|
||||
ctl = snd_ctl_file(flist);
|
||||
list_for_each_entry(ctl, &card->ctl_files, list) {
|
||||
if (!ctl->subscribed)
|
||||
continue;
|
||||
spin_lock_irqsave(&ctl->read_lock, flags);
|
||||
list_for_each(elist, &ctl->events) {
|
||||
ev = snd_kctl_event(elist);
|
||||
list_for_each_entry(ev, &ctl->events, list) {
|
||||
if (ev->id.numid == id->numid) {
|
||||
ev->mask |= mask;
|
||||
goto _found;
|
||||
|
@ -277,11 +270,9 @@ EXPORT_SYMBOL(snd_ctl_free_one);
|
|||
static unsigned int snd_ctl_hole_check(struct snd_card *card,
|
||||
unsigned int count)
|
||||
{
|
||||
struct list_head *list;
|
||||
struct snd_kcontrol *kctl;
|
||||
|
||||
list_for_each(list, &card->controls) {
|
||||
kctl = snd_kcontrol(list);
|
||||
list_for_each_entry(kctl, &card->controls, list) {
|
||||
if ((kctl->id.numid <= card->last_numid &&
|
||||
kctl->id.numid + kctl->count > card->last_numid) ||
|
||||
(kctl->id.numid <= card->last_numid + count - 1 &&
|
||||
|
@ -498,12 +489,10 @@ EXPORT_SYMBOL(snd_ctl_rename_id);
|
|||
*/
|
||||
struct snd_kcontrol *snd_ctl_find_numid(struct snd_card *card, unsigned int numid)
|
||||
{
|
||||
struct list_head *list;
|
||||
struct snd_kcontrol *kctl;
|
||||
|
||||
snd_assert(card != NULL && numid != 0, return NULL);
|
||||
list_for_each(list, &card->controls) {
|
||||
kctl = snd_kcontrol(list);
|
||||
list_for_each_entry(kctl, &card->controls, list) {
|
||||
if (kctl->id.numid <= numid && kctl->id.numid + kctl->count > numid)
|
||||
return kctl;
|
||||
}
|
||||
|
@ -527,14 +516,12 @@ EXPORT_SYMBOL(snd_ctl_find_numid);
|
|||
struct snd_kcontrol *snd_ctl_find_id(struct snd_card *card,
|
||||
struct snd_ctl_elem_id *id)
|
||||
{
|
||||
struct list_head *list;
|
||||
struct snd_kcontrol *kctl;
|
||||
|
||||
snd_assert(card != NULL && id != NULL, return NULL);
|
||||
if (id->numid != 0)
|
||||
return snd_ctl_find_numid(card, id->numid);
|
||||
list_for_each(list, &card->controls) {
|
||||
kctl = snd_kcontrol(list);
|
||||
list_for_each_entry(kctl, &card->controls, list) {
|
||||
if (kctl->id.iface != id->iface)
|
||||
continue;
|
||||
if (kctl->id.device != id->device)
|
||||
|
@ -1182,7 +1169,6 @@ static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg
|
|||
{
|
||||
struct snd_ctl_file *ctl;
|
||||
struct snd_card *card;
|
||||
struct list_head *list;
|
||||
struct snd_kctl_ioctl *p;
|
||||
void __user *argp = (void __user *)arg;
|
||||
int __user *ip = argp;
|
||||
|
@ -1232,8 +1218,7 @@ static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg
|
|||
#endif
|
||||
}
|
||||
down_read(&snd_ioctl_rwsem);
|
||||
list_for_each(list, &snd_control_ioctls) {
|
||||
p = list_entry(list, struct snd_kctl_ioctl, list);
|
||||
list_for_each_entry(p, &snd_control_ioctls, list) {
|
||||
err = p->fioctl(card, ctl, cmd, arg);
|
||||
if (err != -ENOIOCTLCMD) {
|
||||
up_read(&snd_ioctl_rwsem);
|
||||
|
@ -1357,13 +1342,11 @@ EXPORT_SYMBOL(snd_ctl_register_ioctl_compat);
|
|||
static int _snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn,
|
||||
struct list_head *lists)
|
||||
{
|
||||
struct list_head *list;
|
||||
struct snd_kctl_ioctl *p;
|
||||
|
||||
snd_assert(fcn != NULL, return -EINVAL);
|
||||
down_write(&snd_ioctl_rwsem);
|
||||
list_for_each(list, lists) {
|
||||
p = list_entry(list, struct snd_kctl_ioctl, list);
|
||||
list_for_each_entry(p, lists, list) {
|
||||
if (p->fioctl == fcn) {
|
||||
list_del(&p->list);
|
||||
up_write(&snd_ioctl_rwsem);
|
||||
|
@ -1453,7 +1436,6 @@ static int snd_ctl_dev_register(struct snd_device *device)
|
|||
static int snd_ctl_dev_disconnect(struct snd_device *device)
|
||||
{
|
||||
struct snd_card *card = device->device_data;
|
||||
struct list_head *flist;
|
||||
struct snd_ctl_file *ctl;
|
||||
int err, cardnum;
|
||||
|
||||
|
@ -1462,8 +1444,7 @@ static int snd_ctl_dev_disconnect(struct snd_device *device)
|
|||
snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO);
|
||||
|
||||
down_read(&card->controls_rwsem);
|
||||
list_for_each(flist, &card->ctl_files) {
|
||||
ctl = snd_ctl_file(flist);
|
||||
list_for_each_entry(ctl, &card->ctl_files, list) {
|
||||
wake_up(&ctl->change_sleep);
|
||||
kill_fasync(&ctl->fasync, SIGIO, POLL_ERR);
|
||||
}
|
||||
|
|
|
@ -392,7 +392,7 @@ enum {
|
|||
static inline long snd_ctl_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
struct snd_ctl_file *ctl;
|
||||
struct list_head *list;
|
||||
struct snd_kctl_ioctl *p;
|
||||
void __user *argp = compat_ptr(arg);
|
||||
int err;
|
||||
|
||||
|
@ -427,8 +427,7 @@ static inline long snd_ctl_ioctl_compat(struct file *file, unsigned int cmd, uns
|
|||
}
|
||||
|
||||
down_read(&snd_ioctl_rwsem);
|
||||
list_for_each(list, &snd_control_compat_ioctls) {
|
||||
struct snd_kctl_ioctl *p = list_entry(list, struct snd_kctl_ioctl, list);
|
||||
list_for_each_entry(p, &snd_control_compat_ioctls, list) {
|
||||
if (p->fioctl) {
|
||||
err = p->fioctl(ctl->card, ctl, cmd, arg);
|
||||
if (err != -ENOIOCTLCMD) {
|
||||
|
|
|
@ -79,13 +79,11 @@ EXPORT_SYMBOL(snd_device_new);
|
|||
*/
|
||||
int snd_device_free(struct snd_card *card, void *device_data)
|
||||
{
|
||||
struct list_head *list;
|
||||
struct snd_device *dev;
|
||||
|
||||
snd_assert(card != NULL, return -ENXIO);
|
||||
snd_assert(device_data != NULL, return -ENXIO);
|
||||
list_for_each(list, &card->devices) {
|
||||
dev = snd_device(list);
|
||||
list_for_each_entry(dev, &card->devices, list) {
|
||||
if (dev->device_data != device_data)
|
||||
continue;
|
||||
/* unlink */
|
||||
|
@ -124,13 +122,11 @@ EXPORT_SYMBOL(snd_device_free);
|
|||
*/
|
||||
int snd_device_disconnect(struct snd_card *card, void *device_data)
|
||||
{
|
||||
struct list_head *list;
|
||||
struct snd_device *dev;
|
||||
|
||||
snd_assert(card != NULL, return -ENXIO);
|
||||
snd_assert(device_data != NULL, return -ENXIO);
|
||||
list_for_each(list, &card->devices) {
|
||||
dev = snd_device(list);
|
||||
list_for_each_entry(dev, &card->devices, list) {
|
||||
if (dev->device_data != device_data)
|
||||
continue;
|
||||
if (dev->state == SNDRV_DEV_REGISTERED &&
|
||||
|
@ -161,14 +157,12 @@ int snd_device_disconnect(struct snd_card *card, void *device_data)
|
|||
*/
|
||||
int snd_device_register(struct snd_card *card, void *device_data)
|
||||
{
|
||||
struct list_head *list;
|
||||
struct snd_device *dev;
|
||||
int err;
|
||||
|
||||
snd_assert(card != NULL, return -ENXIO);
|
||||
snd_assert(device_data != NULL, return -ENXIO);
|
||||
list_for_each(list, &card->devices) {
|
||||
dev = snd_device(list);
|
||||
list_for_each_entry(dev, &card->devices, list) {
|
||||
if (dev->device_data != device_data)
|
||||
continue;
|
||||
if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) {
|
||||
|
@ -192,13 +186,11 @@ EXPORT_SYMBOL(snd_device_register);
|
|||
*/
|
||||
int snd_device_register_all(struct snd_card *card)
|
||||
{
|
||||
struct list_head *list;
|
||||
struct snd_device *dev;
|
||||
int err;
|
||||
|
||||
snd_assert(card != NULL, return -ENXIO);
|
||||
list_for_each(list, &card->devices) {
|
||||
dev = snd_device(list);
|
||||
list_for_each_entry(dev, &card->devices, list) {
|
||||
if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) {
|
||||
if ((err = dev->ops->dev_register(dev)) < 0)
|
||||
return err;
|
||||
|
@ -215,12 +207,10 @@ int snd_device_register_all(struct snd_card *card)
|
|||
int snd_device_disconnect_all(struct snd_card *card)
|
||||
{
|
||||
struct snd_device *dev;
|
||||
struct list_head *list;
|
||||
int err = 0;
|
||||
|
||||
snd_assert(card != NULL, return -ENXIO);
|
||||
list_for_each(list, &card->devices) {
|
||||
dev = snd_device(list);
|
||||
list_for_each_entry(dev, &card->devices, list) {
|
||||
if (snd_device_disconnect(card, dev->device_data) < 0)
|
||||
err = -ENXIO;
|
||||
}
|
||||
|
@ -234,7 +224,6 @@ int snd_device_disconnect_all(struct snd_card *card)
|
|||
int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd)
|
||||
{
|
||||
struct snd_device *dev;
|
||||
struct list_head *list;
|
||||
int err;
|
||||
unsigned int range_low, range_high;
|
||||
|
||||
|
@ -242,8 +231,7 @@ int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd)
|
|||
range_low = cmd * SNDRV_DEV_TYPE_RANGE_SIZE;
|
||||
range_high = range_low + SNDRV_DEV_TYPE_RANGE_SIZE - 1;
|
||||
__again:
|
||||
list_for_each(list, &card->devices) {
|
||||
dev = snd_device(list);
|
||||
list_for_each_entry(dev, &card->devices, list) {
|
||||
if (dev->type >= range_low && dev->type <= range_high) {
|
||||
if ((err = snd_device_free(card, dev->device_data)) < 0)
|
||||
return err;
|
||||
|
|
|
@ -47,14 +47,11 @@ static int snd_hwdep_dev_disconnect(struct snd_device *device);
|
|||
|
||||
static struct snd_hwdep *snd_hwdep_search(struct snd_card *card, int device)
|
||||
{
|
||||
struct list_head *p;
|
||||
struct snd_hwdep *hwdep;
|
||||
|
||||
list_for_each(p, &snd_hwdep_devices) {
|
||||
hwdep = list_entry(p, struct snd_hwdep, list);
|
||||
list_for_each_entry(hwdep, &snd_hwdep_devices, list)
|
||||
if (hwdep->card == card && hwdep->device == device)
|
||||
return hwdep;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -468,15 +465,12 @@ static int snd_hwdep_dev_disconnect(struct snd_device *device)
|
|||
static void snd_hwdep_proc_read(struct snd_info_entry *entry,
|
||||
struct snd_info_buffer *buffer)
|
||||
{
|
||||
struct list_head *p;
|
||||
struct snd_hwdep *hwdep;
|
||||
|
||||
mutex_lock(®ister_mutex);
|
||||
list_for_each(p, &snd_hwdep_devices) {
|
||||
hwdep = list_entry(p, struct snd_hwdep, list);
|
||||
list_for_each_entry(hwdep, &snd_hwdep_devices, list)
|
||||
snd_iprintf(buffer, "%02i-%02i: %s\n",
|
||||
hwdep->card->number, hwdep->device, hwdep->name);
|
||||
}
|
||||
mutex_unlock(®ister_mutex);
|
||||
}
|
||||
|
||||
|
|
|
@ -406,19 +406,17 @@ void snd_dma_free_pages(struct snd_dma_buffer *dmab)
|
|||
*/
|
||||
size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id)
|
||||
{
|
||||
struct list_head *p;
|
||||
struct snd_mem_list *mem;
|
||||
|
||||
snd_assert(dmab, return 0);
|
||||
|
||||
mutex_lock(&list_mutex);
|
||||
list_for_each(p, &mem_list_head) {
|
||||
mem = list_entry(p, struct snd_mem_list, list);
|
||||
list_for_each_entry(mem, &mem_list_head, list) {
|
||||
if (mem->id == id &&
|
||||
(mem->buffer.dev.dev == NULL || dmab->dev.dev == NULL ||
|
||||
! memcmp(&mem->buffer.dev, &dmab->dev, sizeof(dmab->dev)))) {
|
||||
struct device *dev = dmab->dev.dev;
|
||||
list_del(p);
|
||||
list_del(&mem->list);
|
||||
*dmab = mem->buffer;
|
||||
if (dmab->dev.dev == NULL)
|
||||
dmab->dev.dev = dev;
|
||||
|
@ -488,7 +486,6 @@ static int snd_mem_proc_read(char *page, char **start, off_t off,
|
|||
{
|
||||
int len = 0;
|
||||
long pages = snd_allocated_pages >> (PAGE_SHIFT-12);
|
||||
struct list_head *p;
|
||||
struct snd_mem_list *mem;
|
||||
int devno;
|
||||
static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG", "SBUS" };
|
||||
|
@ -498,8 +495,7 @@ static int snd_mem_proc_read(char *page, char **start, off_t off,
|
|||
"pages : %li bytes (%li pages per %likB)\n",
|
||||
pages * PAGE_SIZE, pages, PAGE_SIZE / 1024);
|
||||
devno = 0;
|
||||
list_for_each(p, &mem_list_head) {
|
||||
mem = list_entry(p, struct snd_mem_list, list);
|
||||
list_for_each_entry(mem, &mem_list_head, list) {
|
||||
devno++;
|
||||
len += snprintf(page + len, count - len,
|
||||
"buffer %d : ID %08x : type %s\n",
|
||||
|
|
|
@ -45,11 +45,9 @@ static int snd_pcm_dev_disconnect(struct snd_device *device);
|
|||
|
||||
static struct snd_pcm *snd_pcm_search(struct snd_card *card, int device)
|
||||
{
|
||||
struct list_head *p;
|
||||
struct snd_pcm *pcm;
|
||||
|
||||
list_for_each(p, &snd_pcm_devices) {
|
||||
pcm = list_entry(p, struct snd_pcm, list);
|
||||
list_for_each_entry(pcm, &snd_pcm_devices, list) {
|
||||
if (pcm->card == card && pcm->device == device)
|
||||
return pcm;
|
||||
}
|
||||
|
@ -782,7 +780,6 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
|
|||
struct snd_pcm_runtime *runtime;
|
||||
struct snd_ctl_file *kctl;
|
||||
struct snd_card *card;
|
||||
struct list_head *list;
|
||||
int prefer_subdevice = -1;
|
||||
size_t size;
|
||||
|
||||
|
@ -795,8 +792,7 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
|
|||
|
||||
card = pcm->card;
|
||||
down_read(&card->controls_rwsem);
|
||||
list_for_each(list, &card->ctl_files) {
|
||||
kctl = snd_ctl_file(list);
|
||||
list_for_each_entry(kctl, &card->ctl_files, list) {
|
||||
if (kctl->pid == current->pid) {
|
||||
prefer_subdevice = kctl->prefer_pcm_subdevice;
|
||||
if (prefer_subdevice != -1)
|
||||
|
@ -941,7 +937,7 @@ static int snd_pcm_dev_register(struct snd_device *device)
|
|||
{
|
||||
int cidx, err;
|
||||
struct snd_pcm_substream *substream;
|
||||
struct list_head *list;
|
||||
struct snd_pcm_notify *notify;
|
||||
char str[16];
|
||||
struct snd_pcm *pcm = device->device_data;
|
||||
struct device *dev;
|
||||
|
@ -988,11 +984,10 @@ static int snd_pcm_dev_register(struct snd_device *device)
|
|||
for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
|
||||
snd_pcm_timer_init(substream);
|
||||
}
|
||||
list_for_each(list, &snd_pcm_notify_list) {
|
||||
struct snd_pcm_notify *notify;
|
||||
notify = list_entry(list, struct snd_pcm_notify, list);
|
||||
|
||||
list_for_each_entry(notify, &snd_pcm_notify_list, list)
|
||||
notify->n_register(pcm);
|
||||
}
|
||||
|
||||
mutex_unlock(®ister_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1035,7 +1030,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device)
|
|||
|
||||
int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree)
|
||||
{
|
||||
struct list_head *p;
|
||||
struct snd_pcm *pcm;
|
||||
|
||||
snd_assert(notify != NULL &&
|
||||
notify->n_register != NULL &&
|
||||
|
@ -1044,13 +1039,12 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree)
|
|||
mutex_lock(®ister_mutex);
|
||||
if (nfree) {
|
||||
list_del(¬ify->list);
|
||||
list_for_each(p, &snd_pcm_devices)
|
||||
notify->n_unregister(list_entry(p,
|
||||
struct snd_pcm, list));
|
||||
list_for_each_entry(pcm, &snd_pcm_devices, list)
|
||||
notify->n_unregister(pcm);
|
||||
} else {
|
||||
list_add_tail(¬ify->list, &snd_pcm_notify_list);
|
||||
list_for_each(p, &snd_pcm_devices)
|
||||
notify->n_register(list_entry(p, struct snd_pcm, list));
|
||||
list_for_each_entry(pcm, &snd_pcm_devices, list)
|
||||
notify->n_register(pcm);
|
||||
}
|
||||
mutex_unlock(®ister_mutex);
|
||||
return 0;
|
||||
|
@ -1066,12 +1060,10 @@ EXPORT_SYMBOL(snd_pcm_notify);
|
|||
static void snd_pcm_proc_read(struct snd_info_entry *entry,
|
||||
struct snd_info_buffer *buffer)
|
||||
{
|
||||
struct list_head *p;
|
||||
struct snd_pcm *pcm;
|
||||
|
||||
mutex_lock(®ister_mutex);
|
||||
list_for_each(p, &snd_pcm_devices) {
|
||||
pcm = list_entry(p, struct snd_pcm, list);
|
||||
list_for_each_entry(pcm, &snd_pcm_devices, list) {
|
||||
snd_iprintf(buffer, "%02i-%02i: %s : %s",
|
||||
pcm->card->number, pcm->device, pcm->id, pcm->name);
|
||||
if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream)
|
||||
|
|
|
@ -61,14 +61,11 @@ static DEFINE_MUTEX(register_mutex);
|
|||
|
||||
static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device)
|
||||
{
|
||||
struct list_head *p;
|
||||
struct snd_rawmidi *rawmidi;
|
||||
|
||||
list_for_each(p, &snd_rawmidi_devices) {
|
||||
rawmidi = list_entry(p, struct snd_rawmidi, list);
|
||||
list_for_each_entry(rawmidi, &snd_rawmidi_devices, list)
|
||||
if (rawmidi->card == card && rawmidi->device == device)
|
||||
return rawmidi;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -389,7 +386,6 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
|
|||
struct snd_rawmidi *rmidi;
|
||||
struct snd_rawmidi_file *rawmidi_file;
|
||||
wait_queue_t wait;
|
||||
struct list_head *list;
|
||||
struct snd_ctl_file *kctl;
|
||||
|
||||
if (maj == snd_major) {
|
||||
|
@ -426,8 +422,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
|
|||
while (1) {
|
||||
subdevice = -1;
|
||||
down_read(&card->controls_rwsem);
|
||||
list_for_each(list, &card->ctl_files) {
|
||||
kctl = snd_ctl_file(list);
|
||||
list_for_each_entry(kctl, &card->ctl_files, list) {
|
||||
if (kctl->pid == current->pid) {
|
||||
subdevice = kctl->prefer_rawmidi_subdevice;
|
||||
if (subdevice != -1)
|
||||
|
@ -575,7 +570,6 @@ int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info
|
|||
struct snd_rawmidi *rmidi;
|
||||
struct snd_rawmidi_str *pstr;
|
||||
struct snd_rawmidi_substream *substream;
|
||||
struct list_head *list;
|
||||
|
||||
mutex_lock(®ister_mutex);
|
||||
rmidi = snd_rawmidi_search(card, info->device);
|
||||
|
@ -589,8 +583,7 @@ int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info
|
|||
return -ENOENT;
|
||||
if (info->subdevice >= pstr->substream_count)
|
||||
return -ENXIO;
|
||||
list_for_each(list, &pstr->substreams) {
|
||||
substream = list_entry(list, struct snd_rawmidi_substream, list);
|
||||
list_for_each_entry(substream, &pstr->substreams, list) {
|
||||
if ((unsigned int)substream->number == info->subdevice)
|
||||
return snd_rawmidi_info(substream, info);
|
||||
}
|
||||
|
@ -1313,14 +1306,14 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry,
|
|||
struct snd_rawmidi *rmidi;
|
||||
struct snd_rawmidi_substream *substream;
|
||||
struct snd_rawmidi_runtime *runtime;
|
||||
struct list_head *list;
|
||||
|
||||
rmidi = entry->private_data;
|
||||
snd_iprintf(buffer, "%s\n\n", rmidi->name);
|
||||
mutex_lock(&rmidi->open_mutex);
|
||||
if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_OUTPUT) {
|
||||
list_for_each(list, &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams) {
|
||||
substream = list_entry(list, struct snd_rawmidi_substream, list);
|
||||
list_for_each_entry(substream,
|
||||
&rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams,
|
||||
list) {
|
||||
snd_iprintf(buffer,
|
||||
"Output %d\n"
|
||||
" Tx bytes : %lu\n",
|
||||
|
@ -1339,8 +1332,9 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry,
|
|||
}
|
||||
}
|
||||
if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_INPUT) {
|
||||
list_for_each(list, &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams) {
|
||||
substream = list_entry(list, struct snd_rawmidi_substream, list);
|
||||
list_for_each_entry(substream,
|
||||
&rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams,
|
||||
list) {
|
||||
snd_iprintf(buffer,
|
||||
"Input %d\n"
|
||||
" Rx bytes : %lu\n",
|
||||
|
@ -1625,13 +1619,10 @@ static int snd_rawmidi_dev_disconnect(struct snd_device *device)
|
|||
void snd_rawmidi_set_ops(struct snd_rawmidi *rmidi, int stream,
|
||||
struct snd_rawmidi_ops *ops)
|
||||
{
|
||||
struct list_head *list;
|
||||
struct snd_rawmidi_substream *substream;
|
||||
|
||||
list_for_each(list, &rmidi->streams[stream].substreams) {
|
||||
substream = list_entry(list, struct snd_rawmidi_substream, list);
|
||||
list_for_each_entry(substream, &rmidi->streams[stream].substreams, list)
|
||||
substream->ops = ops;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -659,7 +659,6 @@ static int deliver_to_subscribers(struct snd_seq_client *client,
|
|||
int err = 0, num_ev = 0;
|
||||
struct snd_seq_event event_saved;
|
||||
struct snd_seq_client_port *src_port;
|
||||
struct list_head *p;
|
||||
struct snd_seq_port_subs_info *grp;
|
||||
|
||||
src_port = snd_seq_port_use_ptr(client, event->source.port);
|
||||
|
@ -674,8 +673,7 @@ static int deliver_to_subscribers(struct snd_seq_client *client,
|
|||
read_lock(&grp->list_lock);
|
||||
else
|
||||
down_read(&grp->list_mutex);
|
||||
list_for_each(p, &grp->list_head) {
|
||||
subs = list_entry(p, struct snd_seq_subscribers, src_list);
|
||||
list_for_each_entry(subs, &grp->list_head, src_list) {
|
||||
event->dest = subs->info.dest;
|
||||
if (subs->info.flags & SNDRV_SEQ_PORT_SUBS_TIMESTAMP)
|
||||
/* convert time according to flag with subscription */
|
||||
|
@ -709,15 +707,14 @@ static int port_broadcast_event(struct snd_seq_client *client,
|
|||
{
|
||||
int num_ev = 0, err = 0;
|
||||
struct snd_seq_client *dest_client;
|
||||
struct list_head *p;
|
||||
struct snd_seq_client_port *port;
|
||||
|
||||
dest_client = get_event_dest_client(event, SNDRV_SEQ_FILTER_BROADCAST);
|
||||
if (dest_client == NULL)
|
||||
return 0; /* no matching destination */
|
||||
|
||||
read_lock(&dest_client->ports_lock);
|
||||
list_for_each(p, &dest_client->ports_list_head) {
|
||||
struct snd_seq_client_port *port = list_entry(p, struct snd_seq_client_port, list);
|
||||
list_for_each_entry(port, &dest_client->ports_list_head, list) {
|
||||
event->dest.port = port->addr.port;
|
||||
/* pass NULL as source client to avoid error bounce */
|
||||
err = snd_seq_deliver_single_event(NULL, event,
|
||||
|
@ -2473,11 +2470,10 @@ static void snd_seq_info_dump_subscribers(struct snd_info_buffer *buffer,
|
|||
static void snd_seq_info_dump_ports(struct snd_info_buffer *buffer,
|
||||
struct snd_seq_client *client)
|
||||
{
|
||||
struct list_head *l;
|
||||
struct snd_seq_client_port *p;
|
||||
|
||||
mutex_lock(&client->ports_mutex);
|
||||
list_for_each(l, &client->ports_list_head) {
|
||||
struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list);
|
||||
list_for_each_entry(p, &client->ports_list_head, list) {
|
||||
snd_iprintf(buffer, " Port %3d : \"%s\" (%c%c%c%c)\n",
|
||||
p->addr.port, p->name,
|
||||
FLAG_PERM_RD(p->capability),
|
||||
|
|
|
@ -106,11 +106,10 @@ static void remove_drivers(void);
|
|||
static void snd_seq_device_info(struct snd_info_entry *entry,
|
||||
struct snd_info_buffer *buffer)
|
||||
{
|
||||
struct list_head *head;
|
||||
struct ops_list *ops;
|
||||
|
||||
mutex_lock(&ops_mutex);
|
||||
list_for_each(head, &opslist) {
|
||||
struct ops_list *ops = list_entry(head, struct ops_list, list);
|
||||
list_for_each_entry(ops, &opslist, list) {
|
||||
snd_iprintf(buffer, "snd-%s%s%s%s,%d\n",
|
||||
ops->id,
|
||||
ops->driver & DRIVER_LOADED ? ",loaded" : (ops->driver == DRIVER_EMPTY ? ",empty" : ""),
|
||||
|
@ -143,7 +142,7 @@ void snd_seq_autoload_unlock(void)
|
|||
void snd_seq_device_load_drivers(void)
|
||||
{
|
||||
#ifdef CONFIG_KMOD
|
||||
struct list_head *head;
|
||||
struct ops_list *ops;
|
||||
|
||||
/* Calling request_module during module_init()
|
||||
* may cause blocking.
|
||||
|
@ -155,8 +154,7 @@ void snd_seq_device_load_drivers(void)
|
|||
return;
|
||||
|
||||
mutex_lock(&ops_mutex);
|
||||
list_for_each(head, &opslist) {
|
||||
struct ops_list *ops = list_entry(head, struct ops_list, list);
|
||||
list_for_each_entry(ops, &opslist, list) {
|
||||
if (! (ops->driver & DRIVER_LOADED) &&
|
||||
! (ops->driver & DRIVER_REQUESTED)) {
|
||||
ops->used++;
|
||||
|
@ -314,8 +312,8 @@ static int snd_seq_device_dev_disconnect(struct snd_device *device)
|
|||
int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
|
||||
int argsize)
|
||||
{
|
||||
struct list_head *head;
|
||||
struct ops_list *ops;
|
||||
struct snd_seq_device *dev;
|
||||
|
||||
if (id == NULL || entry == NULL ||
|
||||
entry->init_device == NULL || entry->free_device == NULL)
|
||||
|
@ -341,8 +339,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
|
|||
ops->argsize = argsize;
|
||||
|
||||
/* initialize existing devices if necessary */
|
||||
list_for_each(head, &ops->dev_list) {
|
||||
struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list);
|
||||
list_for_each_entry(dev, &ops->dev_list, list) {
|
||||
init_device(dev, ops);
|
||||
}
|
||||
mutex_unlock(&ops->reg_mutex);
|
||||
|
@ -394,8 +391,8 @@ static struct ops_list * create_driver(char *id)
|
|||
*/
|
||||
int snd_seq_device_unregister_driver(char *id)
|
||||
{
|
||||
struct list_head *head;
|
||||
struct ops_list *ops;
|
||||
struct snd_seq_device *dev;
|
||||
|
||||
ops = find_driver(id, 0);
|
||||
if (ops == NULL)
|
||||
|
@ -411,8 +408,7 @@ int snd_seq_device_unregister_driver(char *id)
|
|||
/* close and release all devices associated with this driver */
|
||||
mutex_lock(&ops->reg_mutex);
|
||||
ops->driver |= DRIVER_LOCKED; /* do not remove this driver recursively */
|
||||
list_for_each(head, &ops->dev_list) {
|
||||
struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list);
|
||||
list_for_each_entry(dev, &ops->dev_list, list) {
|
||||
free_device(dev, ops);
|
||||
}
|
||||
|
||||
|
@ -512,11 +508,10 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
|
|||
*/
|
||||
static struct ops_list * find_driver(char *id, int create_if_empty)
|
||||
{
|
||||
struct list_head *head;
|
||||
struct ops_list *ops;
|
||||
|
||||
mutex_lock(&ops_mutex);
|
||||
list_for_each(head, &opslist) {
|
||||
struct ops_list *ops = list_entry(head, struct ops_list, list);
|
||||
list_for_each_entry(ops, &opslist, list) {
|
||||
if (strcmp(ops->id, id) == 0) {
|
||||
ops->used++;
|
||||
mutex_unlock(&ops_mutex);
|
||||
|
|
|
@ -59,14 +59,12 @@ much elements are in array.
|
|||
struct snd_seq_client_port *snd_seq_port_use_ptr(struct snd_seq_client *client,
|
||||
int num)
|
||||
{
|
||||
struct list_head *p;
|
||||
struct snd_seq_client_port *port;
|
||||
|
||||
if (client == NULL)
|
||||
return NULL;
|
||||
read_lock(&client->ports_lock);
|
||||
list_for_each(p, &client->ports_list_head) {
|
||||
port = list_entry(p, struct snd_seq_client_port, list);
|
||||
list_for_each_entry(port, &client->ports_list_head, list) {
|
||||
if (port->addr.port == num) {
|
||||
if (port->closing)
|
||||
break; /* deleting now */
|
||||
|
@ -85,14 +83,12 @@ struct snd_seq_client_port *snd_seq_port_query_nearest(struct snd_seq_client *cl
|
|||
struct snd_seq_port_info *pinfo)
|
||||
{
|
||||
int num;
|
||||
struct list_head *p;
|
||||
struct snd_seq_client_port *port, *found;
|
||||
|
||||
num = pinfo->addr.port;
|
||||
found = NULL;
|
||||
read_lock(&client->ports_lock);
|
||||
list_for_each(p, &client->ports_list_head) {
|
||||
port = list_entry(p, struct snd_seq_client_port, list);
|
||||
list_for_each_entry(port, &client->ports_list_head, list) {
|
||||
if (port->addr.port < num)
|
||||
continue;
|
||||
if (port->addr.port == num) {
|
||||
|
@ -131,8 +127,7 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,
|
|||
int port)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct snd_seq_client_port *new_port;
|
||||
struct list_head *l;
|
||||
struct snd_seq_client_port *new_port, *p;
|
||||
int num = -1;
|
||||
|
||||
/* sanity check */
|
||||
|
@ -161,15 +156,14 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,
|
|||
num = port >= 0 ? port : 0;
|
||||
mutex_lock(&client->ports_mutex);
|
||||
write_lock_irqsave(&client->ports_lock, flags);
|
||||
list_for_each(l, &client->ports_list_head) {
|
||||
struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list);
|
||||
list_for_each_entry(p, &client->ports_list_head, list) {
|
||||
if (p->addr.port > num)
|
||||
break;
|
||||
if (port < 0) /* auto-probe mode */
|
||||
num = p->addr.port + 1;
|
||||
}
|
||||
/* insert the new port */
|
||||
list_add_tail(&new_port->list, l);
|
||||
list_add_tail(&new_port->list, &p->list);
|
||||
client->num_ports++;
|
||||
new_port->addr.port = num; /* store the port number in the port */
|
||||
write_unlock_irqrestore(&client->ports_lock, flags);
|
||||
|
@ -287,16 +281,14 @@ static int port_delete(struct snd_seq_client *client,
|
|||
int snd_seq_delete_port(struct snd_seq_client *client, int port)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct list_head *l;
|
||||
struct snd_seq_client_port *found = NULL;
|
||||
struct snd_seq_client_port *found = NULL, *p;
|
||||
|
||||
mutex_lock(&client->ports_mutex);
|
||||
write_lock_irqsave(&client->ports_lock, flags);
|
||||
list_for_each(l, &client->ports_list_head) {
|
||||
struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list);
|
||||
list_for_each_entry(p, &client->ports_list_head, list) {
|
||||
if (p->addr.port == port) {
|
||||
/* ok found. delete from the list at first */
|
||||
list_del(l);
|
||||
list_del(&p->list);
|
||||
client->num_ports--;
|
||||
found = p;
|
||||
break;
|
||||
|
@ -314,7 +306,8 @@ int snd_seq_delete_port(struct snd_seq_client *client, int port)
|
|||
int snd_seq_delete_all_ports(struct snd_seq_client *client)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct list_head deleted_list, *p, *n;
|
||||
struct list_head deleted_list;
|
||||
struct snd_seq_client_port *port, *tmp;
|
||||
|
||||
/* move the port list to deleted_list, and
|
||||
* clear the port list in the client data.
|
||||
|
@ -331,9 +324,8 @@ int snd_seq_delete_all_ports(struct snd_seq_client *client)
|
|||
write_unlock_irqrestore(&client->ports_lock, flags);
|
||||
|
||||
/* remove each port in deleted_list */
|
||||
list_for_each_safe(p, n, &deleted_list) {
|
||||
struct snd_seq_client_port *port = list_entry(p, struct snd_seq_client_port, list);
|
||||
list_del(p);
|
||||
list_for_each_entry_safe(port, tmp, &deleted_list, list) {
|
||||
list_del(&port->list);
|
||||
snd_seq_system_client_ev_port_exit(port->addr.client, port->addr.port);
|
||||
port_delete(client, port);
|
||||
}
|
||||
|
@ -500,8 +492,7 @@ int snd_seq_port_connect(struct snd_seq_client *connector,
|
|||
{
|
||||
struct snd_seq_port_subs_info *src = &src_port->c_src;
|
||||
struct snd_seq_port_subs_info *dest = &dest_port->c_dest;
|
||||
struct snd_seq_subscribers *subs;
|
||||
struct list_head *p;
|
||||
struct snd_seq_subscribers *subs, *s;
|
||||
int err, src_called = 0;
|
||||
unsigned long flags;
|
||||
int exclusive;
|
||||
|
@ -525,13 +516,11 @@ int snd_seq_port_connect(struct snd_seq_client *connector,
|
|||
if (src->exclusive || dest->exclusive)
|
||||
goto __error;
|
||||
/* check whether already exists */
|
||||
list_for_each(p, &src->list_head) {
|
||||
struct snd_seq_subscribers *s = list_entry(p, struct snd_seq_subscribers, src_list);
|
||||
list_for_each_entry(s, &src->list_head, src_list) {
|
||||
if (match_subs_info(info, &s->info))
|
||||
goto __error;
|
||||
}
|
||||
list_for_each(p, &dest->list_head) {
|
||||
struct snd_seq_subscribers *s = list_entry(p, struct snd_seq_subscribers, dest_list);
|
||||
list_for_each_entry(s, &dest->list_head, dest_list) {
|
||||
if (match_subs_info(info, &s->info))
|
||||
goto __error;
|
||||
}
|
||||
|
@ -582,7 +571,6 @@ int snd_seq_port_disconnect(struct snd_seq_client *connector,
|
|||
struct snd_seq_port_subs_info *src = &src_port->c_src;
|
||||
struct snd_seq_port_subs_info *dest = &dest_port->c_dest;
|
||||
struct snd_seq_subscribers *subs;
|
||||
struct list_head *p;
|
||||
int err = -ENOENT;
|
||||
unsigned long flags;
|
||||
|
||||
|
@ -590,8 +578,7 @@ int snd_seq_port_disconnect(struct snd_seq_client *connector,
|
|||
down_write_nested(&dest->list_mutex, SINGLE_DEPTH_NESTING);
|
||||
|
||||
/* look for the connection */
|
||||
list_for_each(p, &src->list_head) {
|
||||
subs = list_entry(p, struct snd_seq_subscribers, src_list);
|
||||
list_for_each_entry(subs, &src->list_head, src_list) {
|
||||
if (match_subs_info(info, &subs->info)) {
|
||||
write_lock_irqsave(&src->list_lock, flags);
|
||||
// write_lock(&dest->list_lock); // no lock yet
|
||||
|
@ -620,12 +607,10 @@ int snd_seq_port_disconnect(struct snd_seq_client *connector,
|
|||
struct snd_seq_subscribers *snd_seq_port_get_subscription(struct snd_seq_port_subs_info *src_grp,
|
||||
struct snd_seq_addr *dest_addr)
|
||||
{
|
||||
struct list_head *p;
|
||||
struct snd_seq_subscribers *s, *found = NULL;
|
||||
|
||||
down_read(&src_grp->list_mutex);
|
||||
list_for_each(p, &src_grp->list_head) {
|
||||
s = list_entry(p, struct snd_seq_subscribers, src_list);
|
||||
list_for_each_entry(s, &src_grp->list_head, src_list) {
|
||||
if (addr_match(dest_addr, &s->info.dest)) {
|
||||
found = s;
|
||||
break;
|
||||
|
|
|
@ -81,13 +81,11 @@ static int snd_virmidi_dev_receive_event(struct snd_virmidi_dev *rdev,
|
|||
struct snd_seq_event *ev)
|
||||
{
|
||||
struct snd_virmidi *vmidi;
|
||||
struct list_head *list;
|
||||
unsigned char msg[4];
|
||||
int len;
|
||||
|
||||
read_lock(&rdev->filelist_lock);
|
||||
list_for_each(list, &rdev->filelist) {
|
||||
vmidi = list_entry(list, struct snd_virmidi, list);
|
||||
list_for_each_entry(vmidi, &rdev->filelist, list) {
|
||||
if (!vmidi->trigger)
|
||||
continue;
|
||||
if (ev->type == SNDRV_SEQ_EVENT_SYSEX) {
|
||||
|
|
|
@ -130,11 +130,8 @@ static struct snd_timer_instance *snd_timer_instance_new(char *owner,
|
|||
static struct snd_timer *snd_timer_find(struct snd_timer_id *tid)
|
||||
{
|
||||
struct snd_timer *timer = NULL;
|
||||
struct list_head *p;
|
||||
|
||||
list_for_each(p, &snd_timer_list) {
|
||||
timer = list_entry(p, struct snd_timer, device_list);
|
||||
|
||||
list_for_each_entry(timer, &snd_timer_list, device_list) {
|
||||
if (timer->tmr_class != tid->dev_class)
|
||||
continue;
|
||||
if ((timer->tmr_class == SNDRV_TIMER_CLASS_CARD ||
|
||||
|
@ -184,13 +181,10 @@ static void snd_timer_check_slave(struct snd_timer_instance *slave)
|
|||
{
|
||||
struct snd_timer *timer;
|
||||
struct snd_timer_instance *master;
|
||||
struct list_head *p, *q;
|
||||
|
||||
/* FIXME: it's really dumb to look up all entries.. */
|
||||
list_for_each(p, &snd_timer_list) {
|
||||
timer = list_entry(p, struct snd_timer, device_list);
|
||||
list_for_each(q, &timer->open_list_head) {
|
||||
master = list_entry(q, struct snd_timer_instance, open_list);
|
||||
list_for_each_entry(timer, &snd_timer_list, device_list) {
|
||||
list_for_each_entry(master, &timer->open_list_head, open_list) {
|
||||
if (slave->slave_class == master->slave_class &&
|
||||
slave->slave_id == master->slave_id) {
|
||||
list_del(&slave->open_list);
|
||||
|
@ -214,16 +208,13 @@ static void snd_timer_check_slave(struct snd_timer_instance *slave)
|
|||
*/
|
||||
static void snd_timer_check_master(struct snd_timer_instance *master)
|
||||
{
|
||||
struct snd_timer_instance *slave;
|
||||
struct list_head *p, *n;
|
||||
struct snd_timer_instance *slave, *tmp;
|
||||
|
||||
/* check all pending slaves */
|
||||
list_for_each_safe(p, n, &snd_timer_slave_list) {
|
||||
slave = list_entry(p, struct snd_timer_instance, open_list);
|
||||
list_for_each_entry_safe(slave, tmp, &snd_timer_slave_list, open_list) {
|
||||
if (slave->slave_class == master->slave_class &&
|
||||
slave->slave_id == master->slave_id) {
|
||||
list_del(p);
|
||||
list_add_tail(p, &master->slave_list_head);
|
||||
list_move_tail(&slave->open_list, &master->slave_list_head);
|
||||
spin_lock_irq(&slave_active_lock);
|
||||
slave->master = master;
|
||||
slave->timer = master->timer;
|
||||
|
@ -317,8 +308,7 @@ static int _snd_timer_stop(struct snd_timer_instance *timeri,
|
|||
int snd_timer_close(struct snd_timer_instance *timeri)
|
||||
{
|
||||
struct snd_timer *timer = NULL;
|
||||
struct list_head *p, *n;
|
||||
struct snd_timer_instance *slave;
|
||||
struct snd_timer_instance *slave, *tmp;
|
||||
|
||||
snd_assert(timeri != NULL, return -ENXIO);
|
||||
|
||||
|
@ -353,12 +343,11 @@ int snd_timer_close(struct snd_timer_instance *timeri)
|
|||
timer->hw.close)
|
||||
timer->hw.close(timer);
|
||||
/* remove slave links */
|
||||
list_for_each_safe(p, n, &timeri->slave_list_head) {
|
||||
slave = list_entry(p, struct snd_timer_instance, open_list);
|
||||
list_for_each_entry_safe(slave, tmp, &timeri->slave_list_head,
|
||||
open_list) {
|
||||
spin_lock_irq(&slave_active_lock);
|
||||
_snd_timer_stop(slave, 1, SNDRV_TIMER_EVENT_RESOLUTION);
|
||||
list_del(p);
|
||||
list_add_tail(p, &snd_timer_slave_list);
|
||||
list_move_tail(&slave->open_list, &snd_timer_slave_list);
|
||||
slave->master = NULL;
|
||||
slave->timer = NULL;
|
||||
spin_unlock_irq(&slave_active_lock);
|
||||
|
@ -394,7 +383,6 @@ static void snd_timer_notify1(struct snd_timer_instance *ti, int event)
|
|||
unsigned long flags;
|
||||
unsigned long resolution = 0;
|
||||
struct snd_timer_instance *ts;
|
||||
struct list_head *n;
|
||||
struct timespec tstamp;
|
||||
|
||||
getnstimeofday(&tstamp);
|
||||
|
@ -413,11 +401,9 @@ static void snd_timer_notify1(struct snd_timer_instance *ti, int event)
|
|||
if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)
|
||||
return;
|
||||
spin_lock_irqsave(&timer->lock, flags);
|
||||
list_for_each(n, &ti->slave_active_head) {
|
||||
ts = list_entry(n, struct snd_timer_instance, active_list);
|
||||
list_for_each_entry(ts, &ti->slave_active_head, active_list)
|
||||
if (ts->ccallback)
|
||||
ts->ccallback(ti, event + 100, &tstamp, resolution);
|
||||
}
|
||||
spin_unlock_irqrestore(&timer->lock, flags);
|
||||
}
|
||||
|
||||
|
@ -593,10 +579,8 @@ static void snd_timer_reschedule(struct snd_timer * timer, unsigned long ticks_l
|
|||
{
|
||||
struct snd_timer_instance *ti;
|
||||
unsigned long ticks = ~0UL;
|
||||
struct list_head *p;
|
||||
|
||||
list_for_each(p, &timer->active_list_head) {
|
||||
ti = list_entry(p, struct snd_timer_instance, active_list);
|
||||
list_for_each_entry(ti, &timer->active_list_head, active_list) {
|
||||
if (ti->flags & SNDRV_TIMER_IFLG_START) {
|
||||
ti->flags &= ~SNDRV_TIMER_IFLG_START;
|
||||
ti->flags |= SNDRV_TIMER_IFLG_RUNNING;
|
||||
|
@ -661,9 +645,9 @@ static void snd_timer_tasklet(unsigned long arg)
|
|||
*/
|
||||
void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left)
|
||||
{
|
||||
struct snd_timer_instance *ti, *ts;
|
||||
struct snd_timer_instance *ti, *ts, *tmp;
|
||||
unsigned long resolution, ticks;
|
||||
struct list_head *p, *q, *n, *ack_list_head;
|
||||
struct list_head *p, *ack_list_head;
|
||||
unsigned long flags;
|
||||
int use_tasklet = 0;
|
||||
|
||||
|
@ -679,12 +663,12 @@ void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left)
|
|||
resolution = timer->hw.resolution;
|
||||
|
||||
/* loop for all active instances
|
||||
* Here we cannot use list_for_each because the active_list of a
|
||||
* Here we cannot use list_for_each_entry because the active_list of a
|
||||
* processed instance is relinked to done_list_head before the callback
|
||||
* is called.
|
||||
*/
|
||||
list_for_each_safe(p, n, &timer->active_list_head) {
|
||||
ti = list_entry(p, struct snd_timer_instance, active_list);
|
||||
list_for_each_entry_safe(ti, tmp, &timer->active_list_head,
|
||||
active_list) {
|
||||
if (!(ti->flags & SNDRV_TIMER_IFLG_RUNNING))
|
||||
continue;
|
||||
ti->pticks += ticks_left;
|
||||
|
@ -700,7 +684,7 @@ void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left)
|
|||
} else {
|
||||
ti->flags &= ~SNDRV_TIMER_IFLG_RUNNING;
|
||||
if (--timer->running)
|
||||
list_del(p);
|
||||
list_del(&ti->active_list);
|
||||
}
|
||||
if ((timer->hw.flags & SNDRV_TIMER_HW_TASKLET) ||
|
||||
(ti->flags & SNDRV_TIMER_IFLG_FAST))
|
||||
|
@ -709,8 +693,7 @@ void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left)
|
|||
ack_list_head = &timer->sack_list_head;
|
||||
if (list_empty(&ti->ack_list))
|
||||
list_add_tail(&ti->ack_list, ack_list_head);
|
||||
list_for_each(q, &ti->slave_active_head) {
|
||||
ts = list_entry(q, struct snd_timer_instance, active_list);
|
||||
list_for_each_entry(ts, &ti->slave_active_head, active_list) {
|
||||
ts->pticks = ti->pticks;
|
||||
ts->resolution = resolution;
|
||||
if (list_empty(&ts->ack_list))
|
||||
|
@ -844,7 +827,6 @@ static int snd_timer_dev_register(struct snd_device *dev)
|
|||
{
|
||||
struct snd_timer *timer = dev->device_data;
|
||||
struct snd_timer *timer1;
|
||||
struct list_head *p;
|
||||
|
||||
snd_assert(timer != NULL && timer->hw.start != NULL &&
|
||||
timer->hw.stop != NULL, return -ENXIO);
|
||||
|
@ -853,8 +835,7 @@ static int snd_timer_dev_register(struct snd_device *dev)
|
|||
return -EINVAL;
|
||||
|
||||
mutex_lock(®ister_mutex);
|
||||
list_for_each(p, &snd_timer_list) {
|
||||
timer1 = list_entry(p, struct snd_timer, device_list);
|
||||
list_for_each_entry(timer1, &snd_timer_list, device_list) {
|
||||
if (timer1->tmr_class > timer->tmr_class)
|
||||
break;
|
||||
if (timer1->tmr_class < timer->tmr_class)
|
||||
|
@ -877,7 +858,7 @@ static int snd_timer_dev_register(struct snd_device *dev)
|
|||
mutex_unlock(®ister_mutex);
|
||||
return -EBUSY;
|
||||
}
|
||||
list_add_tail(&timer->device_list, p);
|
||||
list_add_tail(&timer->device_list, &timer1->device_list);
|
||||
mutex_unlock(®ister_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
@ -896,7 +877,6 @@ void snd_timer_notify(struct snd_timer *timer, int event, struct timespec *tstam
|
|||
unsigned long flags;
|
||||
unsigned long resolution = 0;
|
||||
struct snd_timer_instance *ti, *ts;
|
||||
struct list_head *p, *n;
|
||||
|
||||
if (! (timer->hw.flags & SNDRV_TIMER_HW_SLAVE))
|
||||
return;
|
||||
|
@ -911,15 +891,12 @@ void snd_timer_notify(struct snd_timer *timer, int event, struct timespec *tstam
|
|||
else
|
||||
resolution = timer->hw.resolution;
|
||||
}
|
||||
list_for_each(p, &timer->active_list_head) {
|
||||
ti = list_entry(p, struct snd_timer_instance, active_list);
|
||||
list_for_each_entry(ti, &timer->active_list_head, active_list) {
|
||||
if (ti->ccallback)
|
||||
ti->ccallback(ti, event, tstamp, resolution);
|
||||
list_for_each(n, &ti->slave_active_head) {
|
||||
ts = list_entry(n, struct snd_timer_instance, active_list);
|
||||
list_for_each_entry(ts, &ti->slave_active_head, active_list)
|
||||
if (ts->ccallback)
|
||||
ts->ccallback(ts, event, tstamp, resolution);
|
||||
}
|
||||
}
|
||||
spin_unlock_irqrestore(&timer->lock, flags);
|
||||
}
|
||||
|
@ -1057,11 +1034,9 @@ static void snd_timer_proc_read(struct snd_info_entry *entry,
|
|||
{
|
||||
struct snd_timer *timer;
|
||||
struct snd_timer_instance *ti;
|
||||
struct list_head *p, *q;
|
||||
|
||||
mutex_lock(®ister_mutex);
|
||||
list_for_each(p, &snd_timer_list) {
|
||||
timer = list_entry(p, struct snd_timer, device_list);
|
||||
list_for_each_entry(timer, &snd_timer_list, device_list) {
|
||||
switch (timer->tmr_class) {
|
||||
case SNDRV_TIMER_CLASS_GLOBAL:
|
||||
snd_iprintf(buffer, "G%i: ", timer->tmr_device);
|
||||
|
@ -1088,14 +1063,12 @@ static void snd_timer_proc_read(struct snd_info_entry *entry,
|
|||
if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)
|
||||
snd_iprintf(buffer, " SLAVE");
|
||||
snd_iprintf(buffer, "\n");
|
||||
list_for_each(q, &timer->open_list_head) {
|
||||
ti = list_entry(q, struct snd_timer_instance, open_list);
|
||||
list_for_each_entry(ti, &timer->open_list_head, open_list)
|
||||
snd_iprintf(buffer, " Client %s : %s\n",
|
||||
ti->owner ? ti->owner : "unknown",
|
||||
ti->flags & (SNDRV_TIMER_IFLG_START |
|
||||
SNDRV_TIMER_IFLG_RUNNING)
|
||||
? "running" : "stopped");
|
||||
}
|
||||
}
|
||||
mutex_unlock(®ister_mutex);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue