From patchwork Thu Mar 21 14:42:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 10863723 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 885C41390 for ; Thu, 21 Mar 2019 14:43:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D22228E5A for ; Thu, 21 Mar 2019 14:43:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60D932A20B; Thu, 21 Mar 2019 14:43:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE2C228E5A for ; Thu, 21 Mar 2019 14:43:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728440AbfCUOm5 (ORCPT ); Thu, 21 Mar 2019 10:42:57 -0400 Received: from outils.crapouillou.net ([89.234.176.41]:41366 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728085AbfCUOm5 (ORCPT ); Thu, 21 Mar 2019 10:42:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1553179373; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=Y6zik/OXb4wlKL56pTqENQbTKhIMGne//RzaGCY864Y=; b=eKhlECiAwPXB7Rd8KV0/LkWmDTrDj8bQgaejHKKnMa3o4bLht0HOK7UicWVKTPKjs5pnfx VQfETFXZiT0Qf5WURG5Jbk/YXm/FbTx+ww0N95o7vPWtcACSuk8QnjuRLZrPcemlFXP2Pi u2H5YbDAHAa+qDZQPjjw663UzmWFhTY= From: Paul Cercueil To: Bin Liu Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, od@zcrc.me, Paul Cercueil Subject: [PATCH] usb: musb: Force-disable pullup on shutdown Date: Thu, 21 Mar 2019 15:42:46 +0100 Message-Id: <20190321144246.3547-1-paul@crapouillou.net> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When the musb is shutdown, for instance when the driver is unloaded, force-disable the pullup. Otherwise, the host will still see the gadget device even after the shutdown. Signed-off-by: Paul Cercueil --- drivers/usb/musb/musb_gadget.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index ffe462a657b1..a78a7391031b 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1808,11 +1808,18 @@ int musb_gadget_setup(struct musb *musb) void musb_gadget_cleanup(struct musb *musb) { + unsigned long flags; + if (musb->port_mode == MUSB_HOST) return; cancel_delayed_work_sync(&musb->gadget_work); usb_del_gadget_udc(&musb->g); + + /* Force-disable the pull-up */ + spin_lock_irqsave(&musb->lock, flags); + musb_pullup(musb, 0); + spin_unlock_irqrestore(&musb->lock, flags); } /*