Skip to content

Commit 6cc8445

Browse files
ossilatortiwai
authored andcommitted
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>
1 parent e68235c commit 6cc8445

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

sound/core/timer.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,7 @@ static void snd_timer_proc_read(struct snd_info_entry *entry,
12461246
{
12471247
struct snd_timer *timer;
12481248
struct snd_timer_instance *ti;
1249+
unsigned long resolution;
12491250

12501251
mutex_lock(&register_mutex);
12511252
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,
12691270
timer->tmr_device, timer->tmr_subdevice);
12701271
}
12711272
snd_iprintf(buffer, "%s :", timer->name);
1272-
if (timer->hw.resolution)
1273+
spin_lock_irq(&timer->lock);
1274+
resolution = snd_timer_hw_resolution(timer);
1275+
spin_unlock_irq(&timer->lock);
1276+
if (resolution)
12731277
snd_iprintf(buffer, " %lu.%03luus (%lu ticks)",
1274-
timer->hw.resolution / 1000,
1275-
timer->hw.resolution % 1000,
1278+
resolution / 1000,
1279+
resolution % 1000,
12761280
timer->hw.ticks);
12771281
if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)
12781282
snd_iprintf(buffer, " SLAVE");
@@ -1662,7 +1666,9 @@ static int snd_timer_user_ginfo(struct file *file,
16621666
ginfo->flags |= SNDRV_TIMER_FLG_SLAVE;
16631667
strscpy(ginfo->id, t->id, sizeof(ginfo->id));
16641668
strscpy(ginfo->name, t->name, sizeof(ginfo->name));
1665-
ginfo->resolution = t->hw.resolution;
1669+
spin_lock_irq(&t->lock);
1670+
ginfo->resolution = snd_timer_hw_resolution(t);
1671+
spin_unlock_irq(&t->lock);
16661672
if (t->hw.resolution_min > 0) {
16671673
ginfo->resolution_min = t->hw.resolution_min;
16681674
ginfo->resolution_max = t->hw.resolution_max;
@@ -1817,7 +1823,9 @@ static int snd_timer_user_info(struct file *file,
18171823
info->flags |= SNDRV_TIMER_FLG_SLAVE;
18181824
strscpy(info->id, t->id, sizeof(info->id));
18191825
strscpy(info->name, t->name, sizeof(info->name));
1820-
info->resolution = t->hw.resolution;
1826+
spin_lock_irq(&t->lock);
1827+
info->resolution = snd_timer_hw_resolution(t);
1828+
spin_unlock_irq(&t->lock);
18211829
if (copy_to_user(_info, info, sizeof(*_info)))
18221830
err = -EFAULT;
18231831
kfree(info);

0 commit comments

Comments
 (0)