From patchwork Tue Aug 13 15:44:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 2843777 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D8204BF546 for ; Tue, 13 Aug 2013 15:48:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C67C620502 for ; Tue, 13 Aug 2013 15:48:44 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 903FE204CB for ; Tue, 13 Aug 2013 15:48:43 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V9Gn1-0004Yu-Gj; Tue, 13 Aug 2013 15:45:44 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V9GmU-0003nS-Rs; Tue, 13 Aug 2013 15:45:10 +0000 Received: from svenfoo.org ([82.94.215.22] helo=mail.zonque.de) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V9GmG-0003kg-8B for linux-arm-kernel@lists.infradead.org; Tue, 13 Aug 2013 15:44:57 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.zonque.de (Postfix) with ESMTP id 2C2D9C15FE; Tue, 13 Aug 2013 17:44:32 +0200 (CEST) Received: from mail.zonque.de ([127.0.0.1]) by localhost (rambrand.bugwerft.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jEJNQNcQmtFf; Tue, 13 Aug 2013 17:44:32 +0200 (CEST) Received: from tamtam.fritz.box (p5DDC5F3D.dip0.t-ipconnect.de [93.220.95.61]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.zonque.de (Postfix) with ESMTPSA id 865F4C1400; Tue, 13 Aug 2013 17:44:31 +0200 (CEST) From: Daniel Mack To: linux-usb@vger.kernel.org Subject: [PATCH v2] usb: musb dsps: fix pdev cast in suspend/resume Date: Tue, 13 Aug 2013 17:44:26 +0200 Message-Id: <1376408666-20075-1-git-send-email-zonque@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130813_114456_391489_E347C16A X-CRM114-Status: GOOD ( 10.43 ) X-Spam-Score: -0.3 (/) Cc: paul@pwsan.com, khilman@linaro.org, d-gerlach@ti.com, gregkh@linuxfoundation.org, balbi@ti.com, Daniel Mack , damodar.santhapuri@ti.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP dsps_suspend() and dsps_resume() are called with the device that has the glue assigned as drvdata. Using dev->parent seems wrong and causes a NULL pointer exception on an AM33xx board. The code was introduced by commit c68bb4c6 ("usb: musb: dsps: control module handling (quirk)") but I wonder whether it was ever used. As suggested by Felipe, this patch gets rid of the platform_device access entirely by using dev_get_drvdata(). Signed-off-by: Daniel Mack --- drivers/usb/musb/musb_dsps.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 5233804..16e36a3 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -692,8 +692,7 @@ static int dsps_remove(struct platform_device *pdev) #ifdef CONFIG_PM_SLEEP static int dsps_suspend(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev->parent); - struct dsps_glue *glue = platform_get_drvdata(pdev); + struct dsps_glue *glue = dev_get_drvdata(dev); const struct dsps_musb_wrapper *wrp = glue->wrp; int i; @@ -705,8 +704,7 @@ static int dsps_suspend(struct device *dev) static int dsps_resume(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev->parent); - struct dsps_glue *glue = platform_get_drvdata(pdev); + struct dsps_glue *glue = dev_get_drvdata(dev); const struct dsps_musb_wrapper *wrp = glue->wrp; int i;