From patchwork Tue Nov 27 14:47:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sekhar Nori X-Patchwork-Id: 1811341 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by patchwork2.kernel.org (Postfix) with ESMTP id E8033DF254 for ; Tue, 27 Nov 2012 14:47:45 +0000 (UTC) Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id qAREldL6019131 for ; Tue, 27 Nov 2012 08:47:42 -0600 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id qAREldkp015346 for ; Tue, 27 Nov 2012 08:47:39 -0600 Received: from dlelxv23.itg.ti.com (172.17.1.198) by dfle73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.1.323.3; Tue, 27 Nov 2012 08:47:39 -0600 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlelxv23.itg.ti.com (8.13.8/8.13.8) with ESMTP id qAREldBw004677 for ; Tue, 27 Nov 2012 08:47:39 -0600 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 6976E8062A for ; Tue, 27 Nov 2012 08:47:39 -0600 (CST) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dbdp20.itg.ti.com (dbdp20.itg.ti.com [172.24.170.38]) by linux.omap.com (Postfix) with ESMTP id 636628062A for ; Tue, 27 Nov 2012 08:47:32 -0600 (CST) Received: from DBDE70.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id qARElUjA011072; Tue, 27 Nov 2012 20:17:30 +0530 (IST) Received: from dbdp33.itg.ti.com (172.24.170.252) by dbde70.ent.ti.com (172.24.170.148) with Microsoft SMTP Server id 14.1.323.3; Tue, 27 Nov 2012 20:17:30 +0530 Received: from psplinux063 (smtpvbd.itg.ti.com [172.24.170.250]) by dbdp33.itg.ti.com (8.13.8/8.13.8) with ESMTP id qARElRnr025312; Tue, 27 Nov 2012 20:17:27 +0530 Received: from a0875516 by psplinux063 with local (Exim 4.71) (envelope-from ) id 1TdMRb-0008V9-3r; Tue, 27 Nov 2012 20:17:27 +0530 From: Sekhar Nori To: "David S. Miller" Subject: [PATCH 2/2] net/davinci_emac: use clk_{prepare|unprepare} Date: Tue, 27 Nov 2012 20:17:15 +0530 Message-ID: <1354027635-32627-2-git-send-email-nsekhar@ti.com> X-Mailer: git-send-email 1.7.10.1 In-Reply-To: <1354027635-32627-1-git-send-email-nsekhar@ti.com> References: <1354027635-32627-1-git-send-email-nsekhar@ti.com> MIME-Version: 1.0 CC: , , Mike Turquette X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: Errors-To: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com Use clk_prepare()/clk_unprepare() in the driver since common clock framework needs these to be called before clock is enabled. This is in preparation of common clock framework migration for DaVinci. Cc: Mike Turquette Signed-off-by: Sekhar Nori --- drivers/net/ethernet/ti/davinci_emac.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index 7be04dc..e7b3b94 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -352,6 +352,7 @@ struct emac_priv { /*platform specific members*/ void (*int_enable) (void); void (*int_disable) (void); + struct clk *clk; }; /* EMAC TX Host Error description strings */ @@ -1870,19 +1871,29 @@ static int __devinit davinci_emac_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to get EMAC clock\n"); return -EBUSY; } + + rc = clk_prepare(emac_clk); + if (rc) { + dev_err(&pdev->dev, "emac clock prepare failed.\n"); + return rc; + } + emac_bus_frequency = clk_get_rate(emac_clk); /* TODO: Probe PHY here if possible */ ndev = alloc_etherdev(sizeof(struct emac_priv)); - if (!ndev) - return -ENOMEM; + if (!ndev) { + rc = -ENOMEM; + goto no_etherdev; + } platform_set_drvdata(pdev, ndev); priv = netdev_priv(ndev); priv->pdev = pdev; priv->ndev = ndev; priv->msg_enable = netif_msg_init(debug_level, DAVINCI_EMAC_DEBUG); + priv->clk = emac_clk; spin_lock_init(&priv->lock); @@ -2020,6 +2031,8 @@ no_cpdma_chan: cpdma_ctlr_destroy(priv->dma); no_pdata: free_netdev(ndev); +no_etherdev: + clk_unprepare(emac_clk); return rc; } @@ -2048,6 +2061,8 @@ static int __devexit davinci_emac_remove(struct platform_device *pdev) unregister_netdev(ndev); free_netdev(ndev); + clk_unprepare(priv->clk); + return 0; }