Netdev List
 help / color / mirror / Atom feed
From: Sekhar Nori <nsekhar-l0cyMroinI0@public.gmane.org>
To: "David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
Cc: <netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	<davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/@public.gmane.org>,
	Mike Turquette
	<mturquette-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Subject: [PATCH 2/2] net/davinci_emac: use clk_{prepare|unprepare}
Date: Tue, 27 Nov 2012 20:17:15 +0530	[thread overview]
Message-ID: <1354027635-32627-2-git-send-email-nsekhar@ti.com> (raw)
In-Reply-To: <1354027635-32627-1-git-send-email-nsekhar-l0cyMroinI0@public.gmane.org>

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 <mturquette-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Signed-off-by: Sekhar Nori <nsekhar-l0cyMroinI0@public.gmane.org>
---
 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;
 }
 
-- 
1.7.10.1

      parent reply	other threads:[~2012-11-27 14:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-27 14:47 [PATCH 1/2] net/davinci_emac: use devres APIs Sekhar Nori
     [not found] ` <1354027635-32627-1-git-send-email-nsekhar-l0cyMroinI0@public.gmane.org>
2012-11-27 14:47   ` Sekhar Nori [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1354027635-32627-2-git-send-email-nsekhar@ti.com \
    --to=nsekhar-l0cymroini0@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/@public.gmane.org \
    --cc=mturquette-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox