All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: "Šerif Rami" <ramiserifpersia@gmail.com>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org
Subject: Re: [PATCH v4 2/7] ALSA: usb-audio: us144mkii: Add PCM core infrastructure
Date: Thu, 14 Aug 2025 09:55:16 +0200	[thread overview]
Message-ID: <87o6siuyl7.wl-tiwai@suse.de> (raw)
In-Reply-To: <20250813131518.18985-3-ramiserifpersia@gmail.com>

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

  reply	other threads:[~2025-08-14  7:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-13 13:15 [PATCH v4 0/7] ALSA: usb-audio: Add driver for TASCAM US-144MKII Šerif Rami
2025-08-13 13:15 ` [PATCH v4 1/7] ALSA: usb-audio: Add initial " Šerif Rami
2025-08-13 13:15 ` [PATCH v4 2/7] ALSA: usb-audio: us144mkii: Add PCM core infrastructure Šerif Rami
2025-08-14  7:55   ` Takashi Iwai [this message]
2025-08-13 13:15 ` [PATCH v4 3/7] ALSA: usb-audio: us144mkii: Implement audio playback and feedback Šerif Rami
2025-08-13 13:15 ` [PATCH v4 4/7] ALSA: usb-audio: us144mkii: Implement audio capture and decoding Šerif Rami
2025-08-14  7:59   ` Takashi Iwai
2025-08-13 13:15 ` [PATCH v4 5/7] ALSA: usb-audio: us144mkii: Add MIDI support and mixer controls Šerif Rami
2025-08-14  8:03   ` Takashi Iwai
2025-08-13 13:15 ` [PATCH v4 6/7] ALSA: usb-audio: us144mkii: Add deep sleep command Šerif Rami
2025-08-13 13:15 ` [PATCH v4 7/7] ALSA: usb-audio: Add infrastructure for TASCAM US-144MKII Šerif Rami

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o6siuyl7.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=ramiserifpersia@gmail.com \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.