All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Chen <peter.chen@kernel.org>
To: Pawel Laszczak <pawell@cadence.com>
Cc: "balbi@kernel.org" <balbi@kernel.org>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"ruslan.bilovol@gmail.com" <ruslan.bilovol@gmail.com>,
	"jbrunet@baylibre.com" <jbrunet@baylibre.com>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Rahul Kumar <kurahul@cadence.com>
Subject: Re: [PATCH 1/2] usb: gadget: f_uac2: Stop endpoint before enabling it.
Date: Fri, 23 Apr 2021 18:49:14 +0800	[thread overview]
Message-ID: <20210423104914.GA6448@nchen> (raw)
In-Reply-To: <BYAPR07MB5381F9748155F73732090E87DD489@BYAPR07MB5381.namprd07.prod.outlook.com>

On 21-04-20 03:56:25, Pawel Laszczak wrote:
> >On 21-04-19 09:50:53, Pawel Laszczak wrote:
> >> From: Pawel Laszczak <pawell@cadence.com>
> >>
> >> Patch adds disabling endpoint before enabling it during changing
> >> alternate setting. Lack of this functionality causes that in some
> >> cases uac2 queue the same request multiple time.
> >> Such situation can occur when host send set interface with
> >> alternate setting 1 twice.
> >>
> >> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
> >> ---
> >>  drivers/usb/gadget/function/f_uac2.c | 8 ++++----
> >>  1 file changed, 4 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
> >> index 9cc5c512a5cd..7d20a9d8a1b4 100644
> >> --- a/drivers/usb/gadget/function/f_uac2.c
> >> +++ b/drivers/usb/gadget/function/f_uac2.c
> >> @@ -890,17 +890,17 @@ afunc_set_alt(struct usb_function *fn, unsigned intf, unsigned alt)
> >>  	if (intf == uac2->as_out_intf) {
> >>  		uac2->as_out_alt = alt;
> >>
> >> +		u_audio_stop_capture(&uac2->g_audio);
> >> +
> >>  		if (alt)
> >>  			ret = u_audio_start_capture(&uac2->g_audio);
> >> -		else
> >> -			u_audio_stop_capture(&uac2->g_audio);
> >>  	} else if (intf == uac2->as_in_intf) {
> >>  		uac2->as_in_alt = alt;
> >>
> >> +		u_audio_stop_playback(&uac2->g_audio);
> >> +
> >>  		if (alt)
> >>  			ret = u_audio_start_playback(&uac2->g_audio);
> >> -		else
> >> -			u_audio_stop_playback(&uac2->g_audio);
> >>  	} else {
> >>  		dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
> >>  		return -EINVAL;
> >
> >To avoid this, you may use prm->ep_enabled to judge if the endpoint has
> >already enabled.
> 
> Such condition is as first instruction inside u_audio_stop_playback->free_ep  function,
> so we don't need duplicate it here.
> 

Get your points, you may add more explanations both the code your change
and the commit log.

-- 

Thanks,
Peter Chen


  reply	other threads:[~2021-04-23 10:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-19  7:50 [PATCH 1/2] usb: gadget: f_uac2: Stop endpoint before enabling it Pawel Laszczak
2021-04-20  1:08 ` Peter Chen
2021-04-20  3:56   ` Pawel Laszczak
2021-04-23 10:49     ` Peter Chen [this message]
2021-04-25  3:28       ` Peter Chen

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=20210423104914.GA6448@nchen \
    --to=peter.chen@kernel.org \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jbrunet@baylibre.com \
    --cc=kurahul@cadence.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=pawell@cadence.com \
    --cc=ruslan.bilovol@gmail.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.