From patchwork Fri Mar 16 13:35:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sangwook X-Patchwork-Id: 7332 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 1919F23E29 for ; Fri, 16 Mar 2012 13:37:29 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id B95A0A182CC for ; Fri, 16 Mar 2012 13:37:28 +0000 (UTC) Received: by iage36 with SMTP id e36so7251897iag.11 for ; Fri, 16 Mar 2012 06:37:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=bwENSxr6JpWA1AY4dz592fvUTagiArTSIBP9QAt4a/g=; b=IKFJy0GniU3TIHZqG3k8Ec2bnRaptzd5YKZ6SlQnEtCKaFN29KjPQWw2lOR6Fyox2V kUC+MHjFB0wJLSPvyFswIuP6f4Pr6B3a1wxGAVm6PNNLrRUSHntGIpkQzl1+dwv66XBt hiB8OSB68JKFGLbL+MCYW9/FXqOeQ8zncoO6Itf5R+4pcmHqSdB4CLafIlxH2UeY02h3 FnsRX9QHpTiyZRrGlmQrcXkPjBRaRyzGwaIAxaCZFragLM18FtuJkX6U3mc3KJnW1Z+M xXJJKs07SCHOXGMTfYJ2XWvpiHJxUgxLmZ2agoMCruVcCUwkK+KE2/eMOrsq2WFTuA6O DAMw== Received: by 10.42.145.72 with SMTP id e8mr1487022icv.0.1331905048163; Fri, 16 Mar 2012 06:37:28 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.53.18 with SMTP id k18csp8323ibg; Fri, 16 Mar 2012 06:37:27 -0700 (PDT) Received: by 10.216.132.18 with SMTP id n18mr1593517wei.81.1331905046217; Fri, 16 Mar 2012 06:37:26 -0700 (PDT) Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) by mx.google.com with ESMTPS id dh1si6511568wib.42.2012.03.16.06.37.25 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Mar 2012 06:37:26 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.170 is neither permitted nor denied by best guess record for domain of sangwook.lee@linaro.org) client-ip=209.85.212.170; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.170 is neither permitted nor denied by best guess record for domain of sangwook.lee@linaro.org) smtp.mail=sangwook.lee@linaro.org Received: by wibhr17 with SMTP id hr17so804238wib.1 for ; Fri, 16 Mar 2012 06:37:25 -0700 (PDT) Received: by 10.180.73.143 with SMTP id l15mr4589517wiv.11.1331905045592; Fri, 16 Mar 2012 06:37:25 -0700 (PDT) Received: from localhost.localdomain (host86-147-184-180.range86-147.btcentralplus.com. [86.147.184.180]) by mx.google.com with ESMTPS id fz9sm13835162wib.3.2012.03.16.06.37.23 (version=SSLv3 cipher=OTHER); Fri, 16 Mar 2012 06:37:24 -0700 (PDT) From: Sangwook Lee To: linux-usb@vger.kernel.org Cc: gregkh@linuxfoundation.org, l.Majewski@samsung.com, linux-samsung-soc@vger.kernel.org, patches@linaro.org, linaro-dev@lists.linaro.org, Sangwook Lee Subject: [PATCH] usb: gadget: s3c-hsotg: fix kernel panic Date: Fri, 16 Mar 2012 13:35:20 +0000 Message-Id: <1331904920-19685-1-git-send-email-sangwook.lee@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQl49HKNLah3VtwuFlwOIhGYZi8C+678aZH03XCRZ8kDavpyDgU86mYvtvRzo+Uf822QEzqS Fix kernel panic from s3c_hsotg_udc_stop. if udc_is_newstyle is true, s3c_hsotg_udc_stop should not call disconnect, unbind. As running rmmod g_mass_storage, kernel panic happens. (composite_unbind+0x14/0x164 [g_mass_storage]) from [] (s3c_hsotg_udc_stop) This patch is based on Lukasz Majewski's patches: [PATCH 0/9] USB: s3c-hsotg: USB S3C-HSOTG driver fixes and code cleanu in order to test g_mass_storage in Origen board: Signed-off-by: Sangwook Lee Tested-by: Lukasz Majewski --- drivers/usb/gadget/s3c-hsotg.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 4262df8..9925661 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c @@ -2883,16 +2883,12 @@ static int s3c_hsotg_udc_stop(struct usb_gadget *gadget, for (ep = 0; ep < hsotg->num_of_eps; ep++) s3c_hsotg_ep_disable(&hsotg->eps[ep].ep); - call_gadget(hsotg, disconnect); - - driver->unbind(&hsotg->gadget); s3c_hsotg_phy_disable(hsotg); regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), hsotg->supplies); hsotg->driver = NULL; hsotg->gadget.speed = USB_SPEED_UNKNOWN; - - device_del(&hsotg->gadget.dev); + hsotg->gadget.dev.driver = NULL; dev_info(hsotg->dev, "unregistered gadget driver '%s'\n", driver->driver.name); @@ -3526,7 +3522,10 @@ static int __devexit s3c_hsotg_remove(struct platform_device *pdev) s3c_hsotg_delete_debug(hsotg); - usb_gadget_unregister_driver(hsotg->driver); + if (hsotg->driver) { + /* should have been done already by driver model core */ + usb_gadget_unregister_driver(hsotg->driver); + } free_irq(hsotg->irq, hsotg); iounmap(hsotg->regs); @@ -3540,6 +3539,7 @@ static int __devexit s3c_hsotg_remove(struct platform_device *pdev) clk_disable(hsotg->clk); clk_put(hsotg->clk); + device_unregister(&hsotg->gadget.dev); kfree(hsotg); return 0; }