[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87o6siuyl7.wl-tiwai@suse.de>
Date: Thu, 14 Aug 2025 09:55:16 +0200
From: Takashi Iwai <tiwai@...e.de>
To: Šerif Rami <ramiserifpersia@...il.com>
Cc: Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>,
linux-kernel@...r.kernel.org,
linux-sound@...r.kernel.org
Subject: Re: [PATCH v4 2/7] ALSA: usb-audio: us144mkii: Add PCM core infrastructure
On Wed, 13 Aug 2025 15:15:13 +0200,
Šerif Rami wrote:
>
> +static snd_pcm_uframes_t
> +tascam_capture_pointer(struct snd_pcm_substream *substream)
> +{
> + struct tascam_card *tascam = snd_pcm_substream_chip(substream);
> + struct snd_pcm_runtime *runtime = substream->runtime;
> + u64 pos;
> +
> + if (!atomic_read(&tascam->capture_active))
> + return 0;
> +
> + guard(spinlock_irqsave)(&tascam->lock);
> + pos = tascam->capture_frames_processed;
> +
> + if (runtime->buffer_size == 0)
> + return 0;
> +
> + u64 remainder = do_div(pos, runtime->buffer_size);
> +
> + return runtime ? remainder : 0;
If runtime is NULL, it already hits Oops, so this NULL check makes
little sense.
Also, the "u64 remainder" declaration should be put at the beginning
of the function (although nowadays allowed in the middle).
But, judging the code, you don't have to assign but just return
do_div().
> +static snd_pcm_uframes_t
> +tascam_playback_pointer(struct snd_pcm_substream *substream)
> +{
> + struct tascam_card *tascam = snd_pcm_substream_chip(substream);
> + struct snd_pcm_runtime *runtime = substream->runtime;
> + u64 pos;
> +
> + if (!atomic_read(&tascam->playback_active))
> + return 0;
> +
> + guard(spinlock_irqsave)(&tascam->lock);
> + pos = tascam->playback_frames_consumed;
> +
> + if (runtime->buffer_size == 0)
> + return 0;
> +
> + u64 remainder = do_div(pos, runtime->buffer_size);
> +
> + return runtime ? remainder : 0;
Ditto.
thanks,
Takashi
Powered by blists - more mailing lists