From patchwork Thu Nov 13 06:58:11 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: 5293871 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 3658EC11AC for ; Thu, 13 Nov 2014 07:01:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6D6FC201E4 for ; Thu, 13 Nov 2014 07:01:57 +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 7FAF5201C7 for ; Thu, 13 Nov 2014 07:01:56 +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 1XooMj-0007xx-VU; Thu, 13 Nov 2014 06:58:49 +0000 Received: from mail-by2on0067.outbound.protection.outlook.com ([207.46.100.67] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XooMh-0007wT-VX for linux-arm-kernel@lists.infradead.org; Thu, 13 Nov 2014 06:58:48 +0000 Received: from BL2FFO11FD024.protection.gbl (10.173.160.32) by BL2FFO11HUB054.protection.gbl (10.173.161.154) with Microsoft SMTP Server (TLS) id 15.1.6.13; Thu, 13 Nov 2014 06:58:26 +0000 Received: from xsj-pvapsmtpgw01 (149.199.60.83) by BL2FFO11FD024.mail.protection.outlook.com (10.173.161.103) with Microsoft SMTP Server (TLS) id 15.1.6.13 via Frontend Transport; Thu, 13 Nov 2014 06:58:26 +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 1XooK7-0004Gx-Dz; Wed, 12 Nov 2014 22:56:07 -0800 From: Kedareswara rao Appana To: , , , , , Subject: [PATCH] can: Fix bug in suspend/resume Date: Thu, 13 Nov 2014 12:28:11 +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-21098.002 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)(189002)(199003)(6806004)(102836001)(229853001)(50986999)(2201001)(53416004)(104166001)(20776003)(46102003)(77156002)(50466002)(77096003)(104016003)(87286001)(92566001)(86362001)(50226001)(47776003)(74316001)(4396001)(107046002)(19580405001)(95666004)(44976005)(106466001)(21056001)(62966003)(99396003)(120916001)(64706001)(88136002)(87936001)(108616004)(48376002)(89996001)(19580395003)(31966008)(93916002)(107986001)(24736002)(23106004)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2FFO11HUB054; H:xsj-pvapsmtpgw01; FPR:; MLV:sfv; PTR:unknown-60-83.xilinx.com; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BL2FFO11HUB054; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA: BCL:0;PCL:0;RULEID:;SRVR:BL2FFO11HUB054; X-Forefront-PRVS: 0394259C80 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:BL2FFO11HUB054; X-OriginatorOrg: xilinx.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141112_225848_085759_427564C9 X-CRM114-Status: UNSURE ( 9.02 ) X-CRM114-Notice: Please train this message. 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=-3.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, 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 When accessing the priv structure use container_of instead of dev_get_drvdata. Enable the clocks in the suspend before accessing the registers of the CAN. Signed-off-by: Kedareswara rao Appana --- drivers/net/can/xilinx_can.c | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c index 5e8b560..63ef645 100644 --- a/drivers/net/can/xilinx_can.c +++ b/drivers/net/can/xilinx_can.c @@ -972,15 +972,30 @@ 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 platform_device *pdev = container_of(dev, + struct platform_device, dev); struct net_device *ndev = platform_get_drvdata(pdev); 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,7 +1014,8 @@ 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 platform_device *pdev = container_of(dev, + struct platform_device, dev); struct net_device *ndev = platform_get_drvdata(pdev); struct xcan_priv *priv = netdev_priv(ndev); int ret;