summaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@gmx.de>2023-06-12 21:13:22 +0200
committerTakashi Iwai <tiwai@suse.de>2023-06-13 07:43:38 +0200
commit6cc844504638b0d1429be729b2d66be92276e24b (patch)
tree43ed0bc66fe69f41496af9c42ae175d2ab6476bc /sound/core
parente68235c8aae9af08a868e4a4337daf2bcb4f6a92 (diff)
downloadlinux-stable-6cc844504638b0d1429be729b2d66be92276e24b.tar.gz
linux-stable-6cc844504638b0d1429be729b2d66be92276e24b.tar.bz2
linux-stable-6cc844504638b0d1429be729b2d66be92276e24b.zip
ALSA: timer: minimize open-coded access to hw.resolution
Some info-querying code still used hw.resolution directly instead of calling snd_timer_hw_resolution(), thus missing a possible hw.c_resolution callback. This patch rectifies that. Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Link: https://lore.kernel.org/r/20230612191325.1315854-7-oswald.buddenhagen@gmx.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/timer.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/sound/core/timer.c b/sound/core/timer.c
index e08a37c23add..9d0d2a5c2e15 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -1246,6 +1246,7 @@ static void snd_timer_proc_read(struct snd_info_entry *entry,
{
struct snd_timer *timer;
struct snd_timer_instance *ti;
+ unsigned long resolution;
mutex_lock(&register_mutex);
list_for_each_entry(timer, &snd_timer_list, device_list) {
@@ -1269,10 +1270,13 @@ static void snd_timer_proc_read(struct snd_info_entry *entry,
timer->tmr_device, timer->tmr_subdevice);
}
snd_iprintf(buffer, "%s :", timer->name);
- if (timer->hw.resolution)
+ spin_lock_irq(&timer->lock);
+ resolution = snd_timer_hw_resolution(timer);
+ spin_unlock_irq(&timer->lock);
+ if (resolution)
snd_iprintf(buffer, " %lu.%03luus (%lu ticks)",
- timer->hw.resolution / 1000,
- timer->hw.resolution % 1000,
+ resolution / 1000,
+ resolution % 1000,
timer->hw.ticks);
if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)
snd_iprintf(buffer, " SLAVE");
@@ -1662,7 +1666,9 @@ static int snd_timer_user_ginfo(struct file *file,
ginfo->flags |= SNDRV_TIMER_FLG_SLAVE;
strscpy(ginfo->id, t->id, sizeof(ginfo->id));
strscpy(ginfo->name, t->name, sizeof(ginfo->name));
- ginfo->resolution = t->hw.resolution;
+ spin_lock_irq(&t->lock);
+ ginfo->resolution = snd_timer_hw_resolution(t);
+ spin_unlock_irq(&t->lock);
if (t->hw.resolution_min > 0) {
ginfo->resolution_min = t->hw.resolution_min;
ginfo->resolution_max = t->hw.resolution_max;
@@ -1817,7 +1823,9 @@ static int snd_timer_user_info(struct file *file,
info->flags |= SNDRV_TIMER_FLG_SLAVE;
strscpy(info->id, t->id, sizeof(info->id));
strscpy(info->name, t->name, sizeof(info->name));
- info->resolution = t->hw.resolution;
+ spin_lock_irq(&t->lock);
+ info->resolution = snd_timer_hw_resolution(t);
+ spin_unlock_irq(&t->lock);
if (copy_to_user(_info, info, sizeof(*_info)))
err = -EFAULT;
kfree(info);