From patchwork Fri Nov 14 08:16:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Appana Durga Kedareswara rao X-Patchwork-Id: 5303981 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 53D59C11AC for ; Fri, 14 Nov 2014 08:19:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 826A12017D for ; Fri, 14 Nov 2014 08:19:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AFAC820176 for ; Fri, 14 Nov 2014 08:19:09 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XpC3t-0003SE-LM; Fri, 14 Nov 2014 08:16:57 +0000 Received: from mail-bn1bon0087.outbound.protection.outlook.com ([157.56.111.87] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XpC3q-0003NW-1j for linux-arm-kernel@lists.infradead.org; Fri, 14 Nov 2014 08:16:54 +0000 Received: from BN1AFFO11FD055.protection.gbl (10.58.52.31) by BN1AFFO11HUB017.protection.gbl (10.58.52.127) with Microsoft SMTP Server (TLS) id 15.1.6.13; Fri, 14 Nov 2014 08:16:32 +0000 Received: from xsj-pvapsmtpgw01 (149.199.60.83) by BN1AFFO11FD055.mail.protection.outlook.com (10.58.53.70) with Microsoft SMTP Server (TLS) id 15.1.6.13 via Frontend Transport; Fri, 14 Nov 2014 08:16:31 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1XpC1E-00043t-2g; Fri, 14 Nov 2014 00:14:12 -0800 From: Kedareswara rao Appana To: , , , , , Subject: [PATCH v2] can: Fix bug in suspend/resume Date: Fri, 14 Nov 2014 13:46:19 +0530 X-Mailer: git-send-email 1.7.4 X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-7.5.0.1018-21102.003 X-TM-AS-User-Approved-Sender: Yes;Yes Message-ID: X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.83; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(438002)(199003)(189002)(46102003)(92566001)(4396001)(31966008)(47776003)(20776003)(19580405001)(50226001)(87286001)(87936001)(62966003)(44976005)(77156002)(77096003)(2201001)(88136002)(93916002)(102836001)(104166001)(50986999)(99396003)(86362001)(64706001)(120916001)(95666004)(21056001)(6806004)(33646002)(19580395003)(53416004)(48376002)(50466002)(106466001)(107046002)(104016003)(229853001)(89996001)(108616004)(107986001)(24736002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1AFFO11HUB017; H:xsj-pvapsmtpgw01; FPR:; MLV:sfv; PTR:unknown-60-83.xilinx.com; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BN1AFFO11HUB017; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA: BCL:0;PCL:0;RULEID:;SRVR:BN1AFFO11HUB017; X-Forefront-PRVS: 03950F25EC Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=appana.durga.rao@xilinx.com; X-Exchange-Antispam-Report-CFA: BCL:0;PCL:0;RULEID:;SRVR:BN1AFFO11HUB017; X-OriginatorOrg: xilinx.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141114_001654_227104_4BBC6993 X-CRM114-Status: GOOD ( 10.28 ) X-Spam-Score: -0.0 (/) Cc: devicetree@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-can@vger.kernel.org, Kedareswara rao Appana , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, T_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 The drvdata in the suspend/resume is of type struct net_device, not the platform device.Enable the clocks in the suspend before accessing the registers of the CAN. Signed-off-by: Kedareswara rao Appana --- Changes for v2: - Removed the struct platform_device* from suspend/resume as suggest by Lothar. - The clocks are getting disabled and un prepared at the end of the probe. In the suspend the driver is doing a register write.In order To do that register write we have to again enable and prepare the clocks. drivers/net/can/xilinx_can.c | 20 ++++++++++++++++---- 1 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c index 5e8b560..485262f 100644 --- a/drivers/net/can/xilinx_can.c +++ b/drivers/net/can/xilinx_can.c @@ -972,15 +972,28 @@ static const struct net_device_ops xcan_netdev_ops = { */ static int __maybe_unused xcan_suspend(struct device *dev) { - struct platform_device *pdev = dev_get_drvdata(dev); - struct net_device *ndev = platform_get_drvdata(pdev); + struct net_device *ndev = dev_get_drvdata(dev); struct xcan_priv *priv = netdev_priv(ndev); + int ret; if (netif_running(ndev)) { netif_stop_queue(ndev); netif_device_detach(ndev); } + ret = clk_prepare_enable(priv->can_clk); + if (ret) { + dev_err(dev, "unable to enable device clock\n"); + return ret; + } + + ret = clk_prepare_enable(priv->bus_clk); + if (ret) { + dev_err(dev, "unable to enable bus clock\n"); + clk_disable_unprepare(priv->can_clk); + return ret; + } + priv->write_reg(priv, XCAN_MSR_OFFSET, XCAN_MSR_SLEEP_MASK); priv->can.state = CAN_STATE_SLEEPING; @@ -999,8 +1012,7 @@ static int __maybe_unused xcan_suspend(struct device *dev) */ static int __maybe_unused xcan_resume(struct device *dev) { - struct platform_device *pdev = dev_get_drvdata(dev); - struct net_device *ndev = platform_get_drvdata(pdev); + struct net_device *ndev = dev_get_drvdata(dev); struct xcan_priv *priv = netdev_priv(ndev); int ret;