Message ID | 20230407024616.2883701-2-badhri@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp23765vqo; Thu, 6 Apr 2023 20:46:25 -0700 (PDT) X-Google-Smtp-Source: AKy350ZNu/0Si59zxrsjB4hAQEzlsHaIvRPFj4/YqbkJ/SP2uaZt5mR+VHP+UnMWMKOmpblKZk4U X-Received: by 2002:a17:902:f68c:b0:19f:7977:c9d6 with SMTP id l12-20020a170902f68c00b0019f7977c9d6mr1666272plg.28.1680839185447; Thu, 06 Apr 2023 20:46:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680839185; cv=none; d=google.com; s=arc-20160816; b=wcIm/KZ4euyFvyr+G1iADG19esoJ9UGfoFxYEM0ehVr0DL618Rkyp8D9S1pkc402D1 +QJfbpvt10ZRBAIJhN9LI4e/9B1kiPCMNGfPRZTExuVBbZIcWxX7Dm9S1JR239DLXc/u z66kTIIafa3LxTMXkfJgwCPH9B5PjnYv80scnerh06J61zuvqa/4UYIaXsEJACKVZOSP DJeLgvzjDtUYmPUL0Ktqt/bspWR4IbWA7wNLOhOGfas62d92xXBBAXEEOeRtIdNXg0mT gcOpiZCza/7pN/lZfem+lSYiB2GObwsXLnwOdPHPuVXErsP6LVwOLlgvKTkD0VHa3OBI AOSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=nUz0udxJSncClIXfXpDEBX9ECoOtSVVpf/KdMJ7vysQ=; b=lLvb4aBkVV2SNkvcrJKBvUdLwUcj4MeuJi/6gymX6DQ6xxgWm6mndTatRaq4SO74J1 pswsqALrKEjuIUkSRFqixs50PPSyXJkokmIXi8pH0hrANS8qK56n2PPbnc8fAKdZGvmG J0Qaqh9RzCmzCpVdFkRwH/v3yYOLkN0hD4z9ShazP1opZ0NfjZcsAv3xLKF+38aUpGkp liy3bxYpsrcN2a5BgAptpAQPCFCLQ6FWHysSmTns19xI0Lq2OPBWIXhaJO9bGuPnCanR NqYvXxGdth0xI9qKGkYafLLFX0zq4m0/aSAe+GGK6kShqNZq+son9opEJYac4cemtwDk jzJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Wt0oTZn2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b20-20020a170902d89400b0019e27966ce5si611114plz.218.2023.04.06.20.46.13; Thu, 06 Apr 2023 20:46:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Wt0oTZn2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239799AbjDGCqY (ORCPT <rfc822;a1648639935@gmail.com> + 99 others); Thu, 6 Apr 2023 22:46:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239329AbjDGCqX (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 6 Apr 2023 22:46:23 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0AEB83D1 for <linux-kernel@vger.kernel.org>; Thu, 6 Apr 2023 19:46:21 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-54196bfcd5fso402778507b3.4 for <linux-kernel@vger.kernel.org>; Thu, 06 Apr 2023 19:46:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680835581; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=nUz0udxJSncClIXfXpDEBX9ECoOtSVVpf/KdMJ7vysQ=; b=Wt0oTZn2fcVjC7J7ao1RrEACmnskuXW5Y7RH57Bg0T+h9jBUlNoupAWUyDyLfTW/pN WEd44/ggQ2SzaO14FiShx/WghxIFA4ZvwSSwzHeVlSyTQ1gxSXBbh2sLYU4F2izjb8QN D6fUQFjaTQYfUYkHVbNHCdW8Kk2NZT/ZDf8oB12Ro5L8pv0U5Qd/VIUtWhF/EWflY0aG S3fb37isoWdDMd07xuEl++VVRtp8HXfdt3nJJpsdbncr2egeat7GJH/mpqAySzq9iv3b I1PUThLbYl4RNWQqFx3znDP9jE20Cxne92rT6P44z6cwwITtEnKAL3ebacl9O1Atzcie HPDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680835581; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nUz0udxJSncClIXfXpDEBX9ECoOtSVVpf/KdMJ7vysQ=; b=thhW6HQ7NDeGjUsuXj1cVSi8RipoojICdmUvNGG32T4VJc2DK9uHJeo2UtpgrqqAtP tXMwK+n/6BOei0uRo7sLULRB5savIN68nZZicQh+eek0FE227Q/15jEJHOyia48FuzzI EoBa1FJXJxnW4ZdWpyESzjA5qEWLVKBLgncWqC/CIyZWxuTFU7ucF5k9HmaEtLt8hwV+ Kve0gDLXiQmbGcb2987Ed37WNJ32kHu+GB1kt+BQjxepORCAckg+6vQ9vnJ/p7399T/s wSGyOAR81jhIsZlnyqe6NpjqUs4bL6f5Ok1163SK1Td4dWH5h/1wYf/AtpwWy+IgQW0c LruQ== X-Gm-Message-State: AAQBX9dE9lBNDbBINPd3lIRNMicFExEUKVWhYhjXcRsiN7dg3mEBCW4y p8LWvk8TSYhe23WvRnvFGkX0DT7RcTU= X-Received: from badhri.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:6442]) (user=badhri job=sendgmr) by 2002:a05:690c:72c:b0:52f:184a:da09 with SMTP id bt12-20020a05690c072c00b0052f184ada09mr355489ywb.2.1680835581211; Thu, 06 Apr 2023 19:46:21 -0700 (PDT) Date: Fri, 7 Apr 2023 02:46:16 +0000 In-Reply-To: <20230407024616.2883701-1-badhri@google.com> Mime-Version: 1.0 References: <20230407024616.2883701-1-badhri@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230407024616.2883701-2-badhri@google.com> Subject: [PATCH v3 2/2] usb: gadget: udc: core: Prevent redundant calls to pullup From: Badhri Jagan Sridharan <badhri@google.com> To: gregkh@linuxfoundation.org, stern@rowland.harvard.edu, colin.i.king@gmail.com, xuetao09@huawei.com, quic_eserrao@quicinc.com, water.zhangjiantao@huawei.com, peter.chen@freescale.com, balbi@ti.com Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Badhri Jagan Sridharan <badhri@google.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762487629895249789?= X-GMAIL-MSGID: =?utf-8?q?1762487629895249789?= |
Series |
[v3,1/2] usb: gadget: udc: core: Invoke usb_gadget_connect only when started
|
|
Commit Message
Badhri Jagan Sridharan
April 7, 2023, 2:46 a.m. UTC
usb_gadget_connect calls gadget->ops->pullup without checking whether
gadget->connected was previously set. Make this symmetric to
usb_gadget_disconnect by returning early if gadget->connected is
already set.
Cc: stable@vger.kernel.org
Fixes: 5a1da544e572 ("usb: gadget: core: do not try to disconnect gadget if it is not connected")
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
---
Changes since v2:
* none
Changes since v1:
* Fixed commit message comments.
---
drivers/usb/gadget/udc/core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c index 3eb5d4e392db..7e9ce872451e 100644 --- a/drivers/usb/gadget/udc/core.c +++ b/drivers/usb/gadget/udc/core.c @@ -702,6 +702,9 @@ int usb_gadget_connect_locked(struct usb_gadget *gadget) __must_hold(&gadget->ud goto out; } + if (gadget->connected) + goto out; + if (gadget->deactivated || !gadget->udc->started) { /* * If gadget is deactivated we only save new state.