All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] sound: riptide: Remove duplicate judgments code
@ 2023-07-04  9:11 Minjie Du
  2023-07-04  9:31 ` Takashi Iwai
  0 siblings, 1 reply; 3+ messages in thread
From: Minjie Du @ 2023-07-04  9:11 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, Minjie Du, Stephen Rothwell,
	moderated list:SOUND, open list
  Cc: opensource.kernel

Fix: delate duplicate judgments
Could you help check it out? Thank you!

Signed-off-by: Minjie Du <duminjie@vivo.com>
---
 sound/pci/riptide/riptide.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
index b37c877c2..9bf4b2e86 100644
--- a/sound/pci/riptide/riptide.c
+++ b/sound/pci/riptide/riptide.c
@@ -958,8 +958,7 @@ getsourcesink(struct cmdif *cif, unsigned char source, unsigned char sink,
 {
 	union cmdret rptr = CMDRET_ZERO;
 
-	if (SEND_RSSV(cif, source, sink, &rptr) &&
-	    SEND_RSSV(cif, source, sink, &rptr))
+	if (SEND_RSSV(cif, source, sink, &rptr))
 		return -EIO;
 	*a = rptr.retbytes[0];
 	*b = rptr.retbytes[1];
@@ -978,8 +977,7 @@ getsamplerate(struct cmdif *cif, unsigned char *intdec, unsigned int *rate)
 	s = intdec;
 	for (i = 0; i < 2; i++) {
 		if (*s != 0xff) {
-			if (SEND_RSRC(cif, *s, &rptr) &&
-			    SEND_RSRC(cif, *s, &rptr))
+			if (SEND_RSRC(cif, *s, &rptr))
 				return -EIO;
 			p[i] += rptr.retwords[1];
 			p[i] *= rptr.retwords[2];
@@ -1013,8 +1011,7 @@ setsampleformat(struct cmdif *cif,
 	sig = snd_pcm_format_unsigned(format) != 0;
 	order = snd_pcm_format_big_endian(format) != 0;
 
-	if (SEND_SETF(cif, mixer, w, ch, order, sig, id) &&
-	    SEND_SETF(cif, mixer, w, ch, order, sig, id)) {
+	if (SEND_SETF(cif, mixer, w, ch, order, sig, id)) {
 		snd_printdd("setsampleformat failed\n");
 		return -EIO;
 	}
@@ -1060,7 +1057,7 @@ getmixer(struct cmdif *cif, short num, unsigned short *rval,
 {
 	union cmdret rptr = CMDRET_ZERO;
 
-	if (SEND_RDGV(cif, num, num, &rptr) && SEND_RDGV(cif, num, num, &rptr))
+	if (SEND_RDGV(cif, num, num, &rptr))
 		return -EIO;
 	*rval = rptr.retwords[0];
 	*lval = rptr.retwords[1];
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] sound: riptide: Remove duplicate judgments code
  2023-07-04  9:11 [PATCH v1] sound: riptide: Remove duplicate judgments code Minjie Du
@ 2023-07-04  9:31 ` Takashi Iwai
  2023-07-04  9:39   ` 回复: " 杜敏杰
  0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2023-07-04  9:31 UTC (permalink / raw)
  To: Minjie Du
  Cc: Jaroslav Kysela, Takashi Iwai, Stephen Rothwell,
	moderated list:SOUND, open list, opensource.kernel

On Tue, 04 Jul 2023 11:11:31 +0200,
Minjie Du wrote:
> 
> Fix: delate duplicate judgments
> Could you help check it out? Thank you!

I'm afraid that it's no right fix.
The duplicated calls actually send two commands sequentially, and if
you drop one, it'll change the behavior completely.

Honestly speaking, I have no idea whether sending twice is mandatory
for this chip.  It's an ugly driver by reverse engineering, so who
knows.  We can get rid of it in future.  But it's a different topic.


thanks,

Takashi

> 
> Signed-off-by: Minjie Du <duminjie@vivo.com>
> ---
>  sound/pci/riptide/riptide.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
> index b37c877c2..9bf4b2e86 100644
> --- a/sound/pci/riptide/riptide.c
> +++ b/sound/pci/riptide/riptide.c
> @@ -958,8 +958,7 @@ getsourcesink(struct cmdif *cif, unsigned char source, unsigned char sink,
>  {
>  	union cmdret rptr = CMDRET_ZERO;
>  
> -	if (SEND_RSSV(cif, source, sink, &rptr) &&
> -	    SEND_RSSV(cif, source, sink, &rptr))
> +	if (SEND_RSSV(cif, source, sink, &rptr))
>  		return -EIO;
>  	*a = rptr.retbytes[0];
>  	*b = rptr.retbytes[1];
> @@ -978,8 +977,7 @@ getsamplerate(struct cmdif *cif, unsigned char *intdec, unsigned int *rate)
>  	s = intdec;
>  	for (i = 0; i < 2; i++) {
>  		if (*s != 0xff) {
> -			if (SEND_RSRC(cif, *s, &rptr) &&
> -			    SEND_RSRC(cif, *s, &rptr))
> +			if (SEND_RSRC(cif, *s, &rptr))
>  				return -EIO;
>  			p[i] += rptr.retwords[1];
>  			p[i] *= rptr.retwords[2];
> @@ -1013,8 +1011,7 @@ setsampleformat(struct cmdif *cif,
>  	sig = snd_pcm_format_unsigned(format) != 0;
>  	order = snd_pcm_format_big_endian(format) != 0;
>  
> -	if (SEND_SETF(cif, mixer, w, ch, order, sig, id) &&
> -	    SEND_SETF(cif, mixer, w, ch, order, sig, id)) {
> +	if (SEND_SETF(cif, mixer, w, ch, order, sig, id)) {
>  		snd_printdd("setsampleformat failed\n");
>  		return -EIO;
>  	}
> @@ -1060,7 +1057,7 @@ getmixer(struct cmdif *cif, short num, unsigned short *rval,
>  {
>  	union cmdret rptr = CMDRET_ZERO;
>  
> -	if (SEND_RDGV(cif, num, num, &rptr) && SEND_RDGV(cif, num, num, &rptr))
> +	if (SEND_RDGV(cif, num, num, &rptr))
>  		return -EIO;
>  	*rval = rptr.retwords[0];
>  	*lval = rptr.retwords[1];
> -- 
> 2.39.0
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* 回复: [PATCH v1] sound: riptide: Remove duplicate judgments code
  2023-07-04  9:31 ` Takashi Iwai
@ 2023-07-04  9:39   ` 杜敏杰
  0 siblings, 0 replies; 3+ messages in thread
From: 杜敏杰 @ 2023-07-04  9:39 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Jaroslav Kysela, Takashi Iwai, Stephen Rothwell,
	moderated list:SOUND, open list, opensource.kernel

OK, Thank you for your reply.

-----邮件原件-----
发件人: Takashi Iwai <tiwai@suse.de> 
发送时间: 2023年7月4日 17:32
收件人: 杜敏杰 <duminjie@vivo.com>
抄送: Jaroslav Kysela <perex@perex.cz>; Takashi Iwai <tiwai@suse.com>; Stephen Rothwell <sfr@canb.auug.org.au>; moderated list:SOUND <alsa-devel@alsa-project.org>; open list <linux-kernel@vger.kernel.org>; opensource.kernel <opensource.kernel@vivo.com>
主题: Re: [PATCH v1] sound: riptide: Remove duplicate judgments code

[Some people who received this message don't often get email from tiwai@suse.de. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

On Tue, 04 Jul 2023 11:11:31 +0200,
Minjie Du wrote:
>
> Fix: delate duplicate judgments
> Could you help check it out? Thank you!

I'm afraid that it's no right fix.
The duplicated calls actually send two commands sequentially, and if you drop one, it'll change the behavior completely.

Honestly speaking, I have no idea whether sending twice is mandatory for this chip.  It's an ugly driver by reverse engineering, so who knows.  We can get rid of it in future.  But it's a different topic.


thanks,

Takashi

>
> Signed-off-by: Minjie Du <duminjie@vivo.com>
> ---
>  sound/pci/riptide/riptide.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c 
> index b37c877c2..9bf4b2e86 100644
> --- a/sound/pci/riptide/riptide.c
> +++ b/sound/pci/riptide/riptide.c
> @@ -958,8 +958,7 @@ getsourcesink(struct cmdif *cif, unsigned char 
> source, unsigned char sink,  {
>       union cmdret rptr = CMDRET_ZERO;
>
> -     if (SEND_RSSV(cif, source, sink, &rptr) &&
> -         SEND_RSSV(cif, source, sink, &rptr))
> +     if (SEND_RSSV(cif, source, sink, &rptr))
>               return -EIO;
>       *a = rptr.retbytes[0];
>       *b = rptr.retbytes[1];
> @@ -978,8 +977,7 @@ getsamplerate(struct cmdif *cif, unsigned char *intdec, unsigned int *rate)
>       s = intdec;
>       for (i = 0; i < 2; i++) {
>               if (*s != 0xff) {
> -                     if (SEND_RSRC(cif, *s, &rptr) &&
> -                         SEND_RSRC(cif, *s, &rptr))
> +                     if (SEND_RSRC(cif, *s, &rptr))
>                               return -EIO;
>                       p[i] += rptr.retwords[1];
>                       p[i] *= rptr.retwords[2]; @@ -1013,8 +1011,7 @@ 
> setsampleformat(struct cmdif *cif,
>       sig = snd_pcm_format_unsigned(format) != 0;
>       order = snd_pcm_format_big_endian(format) != 0;
>
> -     if (SEND_SETF(cif, mixer, w, ch, order, sig, id) &&
> -         SEND_SETF(cif, mixer, w, ch, order, sig, id)) {
> +     if (SEND_SETF(cif, mixer, w, ch, order, sig, id)) {
>               snd_printdd("setsampleformat failed\n");
>               return -EIO;
>       }
> @@ -1060,7 +1057,7 @@ getmixer(struct cmdif *cif, short num, unsigned 
> short *rval,  {
>       union cmdret rptr = CMDRET_ZERO;
>
> -     if (SEND_RDGV(cif, num, num, &rptr) && SEND_RDGV(cif, num, num, &rptr))
> +     if (SEND_RDGV(cif, num, num, &rptr))
>               return -EIO;
>       *rval = rptr.retwords[0];
>       *lval = rptr.retwords[1];
> --
> 2.39.0
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-04 15:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-04  9:11 [PATCH v1] sound: riptide: Remove duplicate judgments code Minjie Du
2023-07-04  9:31 ` Takashi Iwai
2023-07-04  9:39   ` 回复: " 杜敏杰

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.