Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 47038
b: refs/heads/master
c: 9244b2c
h: refs/heads/master
v: v3
  • Loading branch information
Johannes Berg authored and Jaroslav Kysela committed Feb 9, 2007
1 parent ea91bab commit 23eadf8
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 215 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d595ee7e0162ae66faa8c4c7d8c2069b40d64fed
refs/heads/master: 9244b2c3079faac79b3b961116bd548c45087e2c
37 changes: 9 additions & 28 deletions trunk/sound/core/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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 &&
Expand Down Expand Up @@ -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;
}
Expand All @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand All @@ -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);
}
Expand Down
5 changes: 2 additions & 3 deletions trunk/sound/core/control_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down
24 changes: 6 additions & 18 deletions trunk/sound/core/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 &&
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -234,16 +224,14 @@ 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;

snd_assert(card != NULL, return -ENXIO);
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;
Expand Down
10 changes: 2 additions & 8 deletions trunk/sound/core/hwdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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(&register_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(&register_mutex);
}

Expand Down
10 changes: 3 additions & 7 deletions trunk/sound/core/memalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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" };
Expand All @@ -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",
Expand Down
Loading

0 comments on commit 23eadf8

Please sign in to comment.