ALSA: Switch to use hrtimer_setup()

hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

Acked-by: Zack Rusin <zack.rusin@broadcom.com>
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Takashi Iwai <tiwai@suse.com>
Link: https://patch.msgid.link/598031332ce738c82286a158cb66eb7e735b2e79.1738746904.git.namcao@linutronix.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Nam Cao 2025-02-05 11:46:33 +01:00 committed by Takashi Iwai
parent d7e2447a4d
commit 70e90680c2
4 changed files with 4 additions and 8 deletions

View File

@ -66,9 +66,8 @@ static int snd_hrtimer_open(struct snd_timer *t)
stime = kzalloc(sizeof(*stime), GFP_KERNEL); stime = kzalloc(sizeof(*stime), GFP_KERNEL);
if (!stime) if (!stime)
return -ENOMEM; return -ENOMEM;
hrtimer_init(&stime->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
stime->timer = t; stime->timer = t;
stime->hrt.function = snd_hrtimer_callback; hrtimer_setup(&stime->hrt, snd_hrtimer_callback, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
t->private_data = stime; t->private_data = stime;
return 0; return 0;
} }

View File

@ -457,8 +457,7 @@ static int dummy_hrtimer_create(struct snd_pcm_substream *substream)
if (!dpcm) if (!dpcm)
return -ENOMEM; return -ENOMEM;
substream->runtime->private_data = dpcm; substream->runtime->private_data = dpcm;
hrtimer_init(&dpcm->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT); hrtimer_setup(&dpcm->timer, dummy_hrtimer_callback, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
dpcm->timer.function = dummy_hrtimer_callback;
dpcm->substream = substream; dpcm->substream = substream;
atomic_set(&dpcm->running, 0); atomic_set(&dpcm->running, 0);
return 0; return 0;

View File

@ -103,8 +103,7 @@ static int snd_card_pcsp_probe(int devnum, struct device *dev)
if (devnum != 0) if (devnum != 0)
return -EINVAL; return -EINVAL;
hrtimer_init(&pcsp_chip.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); hrtimer_setup(&pcsp_chip.timer, pcsp_do_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
pcsp_chip.timer.function = pcsp_do_timer;
err = snd_devm_card_new(dev, index, id, THIS_MODULE, 0, &card); err = snd_devm_card_new(dev, index, id, THIS_MODULE, 0, &card);
if (err < 0) if (err < 0)

View File

@ -312,8 +312,7 @@ static int snd_sh_dac_create(struct snd_card *card,
chip->card = card; chip->card = card;
hrtimer_init(&chip->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); hrtimer_setup(&chip->hrtimer, sh_dac_audio_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
chip->hrtimer.function = sh_dac_audio_timer;
dac_audio_reset(chip); dac_audio_reset(chip);
chip->rate = 8000; chip->rate = 8000;