From: Takashi Iwai <tiwai@suse.de>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alexander Tsoy <alexander@tsoy.me>,
linux-usb@vger.kernel.org, linux-sound@vger.kernel.org,
alsa-devel@alsa-project.org, Takashi Iwai <tiwai@suse.com>,
Jaroslav Kysela <perex@perex.cz>,
Nikolay Yakimov <root@livid.pp.ru>,
Saranya Gopal <saranya.gopal@intel.com>
Subject: Re: [PATCH] USB: Always select config with the highest supported UAC version
Date: Tue, 13 Feb 2024 13:02:25 +0100 [thread overview]
Message-ID: <87sf1wy3la.wl-tiwai@suse.de> (raw)
In-Reply-To: <2024021353-reversing-waltz-7402@gregkh>
On Tue, 13 Feb 2024 12:05:47 +0100,
Greg Kroah-Hartman wrote:
> On Mon, Feb 12, 2024 at 06:28:48PM +0300, Alexander Tsoy wrote:
> >
> > - /* If there is no UAC3 config, prefer the first config */
> > - else if (i == 0)
> > + if (i == 0)
> > best = c;
> >
> > + /* Assume that bInterfaceProtocol value is always
> > + * growing when UAC versions are incremented, so that
> > + * the direct comparison is possible. */
>
> How do we know this assumption is always true? What happens when it is not?
I believe this assumption is acceptable. It's all about the protocol
number from 1 to 3, so far. If UAC4 is ever supported in future,
it'll be highly probably the number 4. (If not and keeping the same
protocol number 3, we'll need a different check in anyway.)
And the other numbers are excluded already in is_supported_uac()
check.
> > + else if (is_supported_uac(desc) && best_desc &&
> > + (!is_supported_uac(best_desc) ||
> > + (desc->bInterfaceProtocol >
> > + best_desc->bInterfaceProtocol)))
> > + best = c;
>
> I really can't understand this if logic, sorry, can you describe it
> better so that we can maintain it over time?
The condition looks cryptic, though, yes.
Maybe the check should be factored out, e.g.
/* return true if the new config has a higher priority then the old config */
static bool check_uac_desc_priority(struct usb_host_config *old,
struct usb_host_config *new)
{
if (!is_supported_uac(new))
return false;
if (!is_supported_uac(old))
return true;
/*
* Assume that bInterfaceProtocol value is always growing;
* so far, it's true from UAC1 to UAC3 (1..3)
*/
if (new->bInterfaceProtocol > old->bInterfaceProtocol)
return true;
return false;
}
thanks,
Takashi
next prev parent reply other threads:[~2024-02-13 12:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-12 15:28 [PATCH] USB: Always select config with the highest supported UAC version Alexander Tsoy
2024-02-13 11:05 ` Greg Kroah-Hartman
2024-02-13 12:02 ` Takashi Iwai [this message]
2024-02-13 12:11 ` Alexander Tsoy
2024-02-13 12:42 ` Alexander Tsoy
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=87sf1wy3la.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alexander@tsoy.me \
--cc=alsa-devel@alsa-project.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-sound@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=perex@perex.cz \
--cc=root@livid.pp.ru \
--cc=saranya.gopal@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox