[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <a44efc1fb0144cca9d0c4851cc51db25@BL2FFO11FD024.protection.gbl>
Date: Thu, 13 Nov 2014 12:28:11 +0530
From: Kedareswara rao Appana <appana.durga.rao@...inx.com>
To: <wg@...ndegger.com>, <mkl@...gutronix.de>,
<michal.simek@...inx.com>, <soren.brinkmann@...inx.com>,
<grant.likely@...aro.org>, <robh+dt@...nel.org>
CC: <linux-can@...r.kernel.org>, <netdev@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>, <devicetree@...r.kernel.org>,
Kedareswara rao Appana <appanad@...inx.com>
Subject: [PATCH] can: Fix bug in suspend/resume
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 <appanad@...inx.com>
---
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;
--
1.7.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists