From patchwork Thu Sep 13 07:28:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "AnilKumar, Chimata" X-Patchwork-Id: 1450591 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 6540240AB5 for ; Thu, 13 Sep 2012 07:29:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756336Ab2IMH3n (ORCPT ); Thu, 13 Sep 2012 03:29:43 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:51206 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754229Ab2IMH3l (ORCPT ); Thu, 13 Sep 2012 03:29:41 -0400 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id q8D7TUmj029219; Thu, 13 Sep 2012 02:29:30 -0500 Received: from DBDE71.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id q8D7TRXd018133; Thu, 13 Sep 2012 12:59:29 +0530 (IST) Received: from dbdp32.itg.ti.com (172.24.170.251) by DBDE71.ent.ti.com (172.24.170.149) with Microsoft SMTP Server id 14.1.323.3; Thu, 13 Sep 2012 12:59:27 +0530 Received: from localhost.localdomain (dbdp20.itg.ti.com [172.24.170.38]) by dbdp32.itg.ti.com (8.13.8/8.13.8) with ESMTP id q8D7TOLv001814; Thu, 13 Sep 2012 12:59:25 +0530 From: AnilKumar Ch To: , , CC: , , , , AnilKumar Ch Subject: [PATCH] can: c_can: Move pm_runtime_enable/disable calls to common code Date: Thu, 13 Sep 2012 12:58:12 +0530 Message-ID: <1347521292-28751-1-git-send-email-anilkumar@ti.com> X-Mailer: git-send-email 1.7.0.4 MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Move pm_runtime_enable/disable calls to c_can.c driver. Current implementation is such that platform driver is doing pm_runtime enable/disable and core driver is doing put_sync/get_sync. PM runtime calls should be invoked if there is a valid device pointer from platform driver so moving enable/disable calls to core driver. Signed-off-by: AnilKumar Ch --- Incorporated Kevin's comments on "can: c_can: Add runtime PM support to Bosch C_CAN/D_CAN controller" patch. This patch is tested on AM335x-EVM and cleanly applies on linux-can master drivers/net/can/c_can/c_can.c | 18 +++++++++++++++++- drivers/net/can/c_can/c_can_platform.c | 5 ----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c index aa6c5eb..e472975 100644 --- a/drivers/net/can/c_can/c_can.c +++ b/drivers/net/can/c_can/c_can.c @@ -1155,10 +1155,23 @@ static const struct net_device_ops c_can_netdev_ops = { int register_c_can_dev(struct net_device *dev) { + int ret; + struct c_can_priv *priv = netdev_priv(dev); + + if (priv->device) + pm_runtime_enable(priv->device); + dev->flags |= IFF_ECHO; /* we support local echo */ dev->netdev_ops = &c_can_netdev_ops; - return register_candev(dev); + ret = register_candev(dev); + if (ret) { + if (priv->device) + pm_runtime_disable(priv->device); + return ret; + } + + return 0; } EXPORT_SYMBOL_GPL(register_c_can_dev); @@ -1170,6 +1183,9 @@ void unregister_c_can_dev(struct net_device *dev) c_can_enable_all_interrupts(priv, DISABLE_ALL_INTERRUPTS); unregister_candev(dev); + + if (priv->device) + pm_runtime_disable(priv->device); } EXPORT_SYMBOL_GPL(unregister_c_can_dev); diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c index c351975..491101a 100644 --- a/drivers/net/can/c_can/c_can_platform.c +++ b/drivers/net/can/c_can/c_can_platform.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -185,8 +184,6 @@ static int __devinit c_can_plat_probe(struct platform_device *pdev) goto exit_free_device; } - pm_runtime_enable(&pdev->dev); - dev->irq = irq; priv->base = addr; priv->device = &pdev->dev; @@ -209,7 +206,6 @@ static int __devinit c_can_plat_probe(struct platform_device *pdev) exit_clear_drvdata: platform_set_drvdata(pdev, NULL); - pm_runtime_disable(&pdev->dev); exit_free_device: free_c_can_dev(dev); exit_iounmap: @@ -239,7 +235,6 @@ static int __devexit c_can_plat_remove(struct platform_device *pdev) mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); release_mem_region(mem->start, resource_size(mem)); - pm_runtime_disable(&pdev->dev); clk_put(priv->priv); return 0;