From patchwork Mon Mar 25 09:25:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sekhar Nori X-Patchwork-Id: 2329451 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) by patchwork1.kernel.org (Postfix) with ESMTP id B861C3FD8C for ; Mon, 25 Mar 2013 09:27:29 +0000 (UTC) Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id r2P9RTiJ000883 for ; Mon, 25 Mar 2013 04:27:29 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r2P9RTrj020520 for ; Mon, 25 Mar 2013 04:27:29 -0500 Received: from dlelxv23.itg.ti.com (172.17.1.198) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Mon, 25 Mar 2013 04:27:28 -0500 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 r2P9RSZQ024182 for ; Mon, 25 Mar 2013 04:27:28 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id C5A9D80626 for ; Mon, 25 Mar 2013 03:27:28 -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 36D3180626 for ; Mon, 25 Mar 2013 03:27:19 -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 r2P9RH4N003807; Mon, 25 Mar 2013 14:57:17 +0530 (IST) Received: from dbdp32.itg.ti.com (172.24.170.251) by dbde70.ent.ti.com (172.24.170.148) with Microsoft SMTP Server id 14.1.323.3; Mon, 25 Mar 2013 14:57:17 +0530 Received: from psplinux063.india.ti.com (smtpvbd.itg.ti.com [172.24.170.250]) by dbdp32.itg.ti.com (8.13.8/8.13.8) with ESMTP id r2P9QmpL014061; Mon, 25 Mar 2013 14:57:16 +0530 From: Sekhar Nori To: "David S. Miller" Subject: [PATCH net-next 2/2] net/davinci_emac: use clk_{prepare|unprepare} Date: Mon, 25 Mar 2013 14:55:47 +0530 Message-ID: <1364203547-2960-3-git-send-email-nsekhar@ti.com> X-Mailer: git-send-email 1.7.10.1 In-Reply-To: <1364203547-2960-1-git-send-email-nsekhar@ti.com> References: <1364203547-2960-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 b1349b5..436296c 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -350,6 +350,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 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 davinci_emac_remove(struct platform_device *pdev) unregister_netdev(ndev); free_netdev(ndev); + clk_unprepare(priv->clk); + return 0; }