* [PATCH] sound: isa: combine lines that defining variables and assigning values
@ 2025-06-06 10:25 Li Jun
2025-06-09 7:52 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Li Jun @ 2025-06-06 10:25 UTC (permalink / raw)
To: perex, tiwai, linux-sound, lijun01
Because the vars be assigning values immediately after
defining, so combine them.
Signed-off-by: Li Jun <lijun01@kylinos.cn>
---
sound/isa/ad1816a/ad1816a_lib.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c
index 2b87036cb94f..29ec91ba8c51 100644
--- a/sound/isa/ad1816a/ad1816a_lib.c
+++ b/sound/isa/ad1816a/ad1816a_lib.c
@@ -276,8 +276,10 @@ static snd_pcm_uframes_t snd_ad1816a_playback_pointer(struct snd_pcm_substream *
{
struct snd_ad1816a *chip = snd_pcm_substream_chip(substream);
size_t ptr;
+
if (!(chip->mode & AD1816A_MODE_PLAYBACK))
return 0;
+
ptr = snd_dma_pointer(chip->dma1, chip->p_dma_size);
return bytes_to_frames(substream->runtime, ptr);
}
@@ -286,8 +288,10 @@ static snd_pcm_uframes_t snd_ad1816a_capture_pointer(struct snd_pcm_substream *s
{
struct snd_ad1816a *chip = snd_pcm_substream_chip(substream);
size_t ptr;
+
if (!(chip->mode & AD1816A_MODE_CAPTURE))
return 0;
+
ptr = snd_dma_pointer(chip->dma2, chip->c_dma_size);
return bytes_to_frames(substream->runtime, ptr);
}
@@ -425,11 +429,11 @@ static int snd_ad1816a_playback_open(struct snd_pcm_substream *substream)
{
struct snd_ad1816a *chip = snd_pcm_substream_chip(substream);
struct snd_pcm_runtime *runtime = substream->runtime;
- int error;
+ int error = snd_ad1816a_open(chip, AD1816A_MODE_PLAYBACK);
- error = snd_ad1816a_open(chip, AD1816A_MODE_PLAYBACK);
if (error < 0)
return error;
+
runtime->hw = snd_ad1816a_playback;
snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.buffer_bytes_max);
snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.period_bytes_max);
@@ -441,11 +445,11 @@ static int snd_ad1816a_capture_open(struct snd_pcm_substream *substream)
{
struct snd_ad1816a *chip = snd_pcm_substream_chip(substream);
struct snd_pcm_runtime *runtime = substream->runtime;
- int error;
+ int error = snd_ad1816a_open(chip, AD1816A_MODE_CAPTURE);
- error = snd_ad1816a_open(chip, AD1816A_MODE_CAPTURE);
if (error < 0)
return error;
+
runtime->hw = snd_ad1816a_capture;
snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.buffer_bytes_max);
snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.period_bytes_max);
@@ -618,10 +622,9 @@ static const struct snd_pcm_ops snd_ad1816a_capture_ops = {
int snd_ad1816a_pcm(struct snd_ad1816a *chip, int device)
{
- int error;
struct snd_pcm *pcm;
+ int error = snd_pcm_new(chip->card, "AD1816A", device, 1, 1, &pcm);
- error = snd_pcm_new(chip->card, "AD1816A", device, 1, 1, &pcm);
if (error)
return error;
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] sound: isa: combine lines that defining variables and assigning values
2025-06-06 10:25 [PATCH] sound: isa: combine lines that defining variables and assigning values Li Jun
@ 2025-06-09 7:52 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2025-06-09 7:52 UTC (permalink / raw)
To: Li Jun; +Cc: perex, tiwai, linux-sound
On Fri, 06 Jun 2025 12:25:38 +0200,
Li Jun wrote:
>
> Because the vars be assigning values immediately after
> defining, so combine them.
>
> Signed-off-by: Li Jun <lijun01@kylinos.cn>
Thanks for the patch. But this doesn't improve the readability much,
nor fix any real bugs. As those are all legacy drivers, I'd rather
leave untouched.
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-09 7:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-06 10:25 [PATCH] sound: isa: combine lines that defining variables and assigning values Li Jun
2025-06-09 7:52 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox