Skip to content

Commit

Permalink
ALSA: control: Rename ctl_files_rwlock to controls_rwlock
Browse files Browse the repository at this point in the history
We'll re-use the existing rwlock for the protection of control list
lookup, too, and now rename it to a more generic name.

This is a preliminary change, only the rename of the struct field
here, no functional changes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20240809104234.8488-2-tiwai@suse.de
  • Loading branch information
tiwai committed Aug 9, 2024
1 parent d3e82ce commit f428cc9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/sound/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ struct snd_card {
struct device *ctl_dev; /* control device */
unsigned int last_numid; /* last used numeric ID */
struct rw_semaphore controls_rwsem; /* controls lock (list and values) */
rwlock_t ctl_files_rwlock; /* ctl_files list lock */
rwlock_t controls_rwlock; /* lock for ctl_files list */
int controls_count; /* count of all controls */
size_t user_ctl_alloc_size; // current memory allocation by user controls.
struct list_head controls; /* all controls for this card */
Expand Down
10 changes: 5 additions & 5 deletions sound/core/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static int snd_ctl_open(struct inode *inode, struct file *file)
ctl->preferred_subdevice[i] = -1;
ctl->pid = get_pid(task_pid(current));
file->private_data = ctl;
scoped_guard(write_lock_irqsave, &card->ctl_files_rwlock)
scoped_guard(write_lock_irqsave, &card->controls_rwlock)
list_add_tail(&ctl->list, &card->ctl_files);
snd_card_unref(card);
return 0;
Expand Down Expand Up @@ -117,7 +117,7 @@ static int snd_ctl_release(struct inode *inode, struct file *file)
file->private_data = NULL;
card = ctl->card;

scoped_guard(write_lock_irqsave, &card->ctl_files_rwlock)
scoped_guard(write_lock_irqsave, &card->controls_rwlock)
list_del(&ctl->list);

scoped_guard(rwsem_write, &card->controls_rwsem) {
Expand Down Expand Up @@ -157,7 +157,7 @@ void snd_ctl_notify(struct snd_card *card, unsigned int mask,
if (card->shutdown)
return;

guard(read_lock_irqsave)(&card->ctl_files_rwlock);
guard(read_lock_irqsave)(&card->controls_rwlock);
#if IS_ENABLED(CONFIG_SND_MIXER_OSS)
card->mixer_oss_change_count++;
#endif
Expand Down Expand Up @@ -2178,7 +2178,7 @@ int snd_ctl_get_preferred_subdevice(struct snd_card *card, int type)
struct snd_ctl_file *kctl;
int subdevice = -1;

guard(read_lock_irqsave)(&card->ctl_files_rwlock);
guard(read_lock_irqsave)(&card->controls_rwlock);
list_for_each_entry(kctl, &card->ctl_files, list) {
if (kctl->pid == task_pid(current)) {
subdevice = kctl->preferred_subdevice[type];
Expand Down Expand Up @@ -2328,7 +2328,7 @@ static int snd_ctl_dev_disconnect(struct snd_device *device)
struct snd_card *card = device->device_data;
struct snd_ctl_file *ctl;

scoped_guard(read_lock_irqsave, &card->ctl_files_rwlock) {
scoped_guard(read_lock_irqsave, &card->controls_rwlock) {
list_for_each_entry(ctl, &card->ctl_files, list) {
wake_up(&ctl->change_sleep);
snd_kill_fasync(ctl->fasync, SIGIO, POLL_ERR);
Expand Down
2 changes: 1 addition & 1 deletion sound/core/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ static int snd_card_init(struct snd_card *card, struct device *parent,
card->module = module;
INIT_LIST_HEAD(&card->devices);
init_rwsem(&card->controls_rwsem);
rwlock_init(&card->ctl_files_rwlock);
rwlock_init(&card->controls_rwlock);
INIT_LIST_HEAD(&card->controls);
INIT_LIST_HEAD(&card->ctl_files);
#ifdef CONFIG_SND_CTL_FAST_LOOKUP
Expand Down

0 comments on commit f428cc9

Please sign in to comment.