lkml.org 
[lkml]   [2021]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.14 11/30] USB: usblp: dont call usb_set_interface if theres a single alt
    Date
    From: Jeremy Figgins <kernel@jeremyfiggins.com>

    commit d8c6edfa3f4ee0d45d7ce5ef18d1245b78774b9d upstream.

    Some devices, such as the Winbond Electronics Corp. Virtual Com Port
    (Vendor=0416, ProdId=5011), lockup when usb_set_interface() or
    usb_clear_halt() are called. This device has only a single
    altsetting, so it should not be necessary to call usb_set_interface().

    Acked-by: Pete Zaitcev <zaitcev@redhat.com>
    Signed-off-by: Jeremy Figgins <kernel@jeremyfiggins.com>
    Link: https://lore.kernel.org/r/YAy9kJhM/rG8EQXC@watson
    Cc: stable <stable@vger.kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    drivers/usb/class/usblp.c | 19 +++++++++++--------
    1 file changed, 11 insertions(+), 8 deletions(-)

    --- a/drivers/usb/class/usblp.c
    +++ b/drivers/usb/class/usblp.c
    @@ -1340,14 +1340,17 @@ static int usblp_set_protocol(struct usb
    if (protocol < USBLP_FIRST_PROTOCOL || protocol > USBLP_LAST_PROTOCOL)
    return -EINVAL;

    - alts = usblp->protocol[protocol].alt_setting;
    - if (alts < 0)
    - return -EINVAL;
    - r = usb_set_interface(usblp->dev, usblp->ifnum, alts);
    - if (r < 0) {
    - printk(KERN_ERR "usblp: can't set desired altsetting %d on interface %d\n",
    - alts, usblp->ifnum);
    - return r;
    + /* Don't unnecessarily set the interface if there's a single alt. */
    + if (usblp->intf->num_altsetting > 1) {
    + alts = usblp->protocol[protocol].alt_setting;
    + if (alts < 0)
    + return -EINVAL;
    + r = usb_set_interface(usblp->dev, usblp->ifnum, alts);
    + if (r < 0) {
    + printk(KERN_ERR "usblp: can't set desired altsetting %d on interface %d\n",
    + alts, usblp->ifnum);
    + return r;
    + }
    }

    usblp->bidir = (usblp->protocol[protocol].epread != NULL);

    \
     
     \ /
      Last update: 2021-02-08 16:56    [W:4.132 / U:2.496 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site