[PATCH 4/4] net/smsc911x: Provide common clock functionality

Subsystems: networking drivers, smsc911x ethernet driver, the rest

STALE4959d

19 messages, 5 authors, 2013-01-17 · open the first message on its own page

[PATCH 4/4] net/smsc911x: Provide common clock functionality

From: Lee Jones <hidden>
Date: 2012-12-19 17:20:41

Some platforms provide clocks which require enabling before the
SMSC911x chip will power on. This patch uses the new common clk
framework to do just that. If no clock is provided, it will just
be ignored and the driver will continue to assume that no clock
is required for the chip to run successfully.

Cc: Steve Glendinning <steve.glendinning@shawell.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Lee Jones <redacted>
---
 drivers/net/ethernet/smsc/smsc911x.c |   31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index 4616bf2..f6196cd 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -33,6 +33,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/crc32.h>
+#include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/etherdevice.h>
@@ -144,6 +145,9 @@ struct smsc911x_data {
 
 	/* regulators */
 	struct regulator_bulk_data supplies[SMSC911X_NUM_SUPPLIES];
+
+	/* clock */
+	struct clk *clk;
 };
 
 /* Easy access to information */
@@ -369,7 +373,7 @@ out:
 }
 
 /*
- * enable resources, currently just regulators.
+ * enable regulator and clock resources.
  */
 static int smsc911x_enable_resources(struct platform_device *pdev)
 {
@@ -382,6 +386,13 @@ static int smsc911x_enable_resources(struct platform_device *pdev)
 	if (ret)
 		netdev_err(ndev, "failed to enable regulators %d\n",
 				ret);
+
+	if (pdata->clk) {
+		ret = clk_prepare_enable(pdata->clk);
+		if (ret < 0)
+			netdev_err(ndev, "failed to enable clock %d\n", ret);
+	}
+
 	return ret;
 }
 
@@ -396,6 +407,10 @@ static int smsc911x_disable_resources(struct platform_device *pdev)
 
 	ret = regulator_bulk_disable(ARRAY_SIZE(pdata->supplies),
 			pdata->supplies);
+
+	if (pdata->clk)
+		clk_disable_unprepare(pdata->clk);
+
 	return ret;
 }
 
@@ -421,6 +436,14 @@ static int smsc911x_request_resources(struct platform_device *pdev)
 	if (ret)
 		netdev_err(ndev, "couldn't get regulators %d\n",
 				ret);
+
+	/* Request clock */
+	pdata->clk = clk_get(&pdev->dev, NULL);
+	if (IS_ERR(pdata->clk)) {
+		netdev_warn(ndev, "couldn't get clock %d\n", PTR_ERR(pdata->clk));
+		pdata->clk = NULL;
+	}
+
 	return ret;
 }
 
@@ -436,6 +459,12 @@ static void smsc911x_free_resources(struct platform_device *pdev)
 	/* Free regulators */
 	regulator_bulk_free(ARRAY_SIZE(pdata->supplies),
 			pdata->supplies);
+
+	/* Free clock */
+	if (pdata->clk) {
+		clk_put(pdata->clk);
+		pdata->clk = NULL;
+	}
 }
 
 /* waits for MAC not busy, with timeout.  Only called by smsc911x_mac_read
-- 
1.7.9.5

Re: [PATCH 4/4] net/smsc911x: Provide common clock functionality

From: Linus Walleij <hidden>
Date: 2012-12-20 19:12:19

On Wed, Dec 19, 2012 at 6:19 PM, Lee Jones [off-list ref] wrote:
Some platforms provide clocks which require enabling before the
SMSC911x chip will power on. This patch uses the new common clk
framework to do just that. If no clock is provided, it will just
be ignored and the driver will continue to assume that no clock
is required for the chip to run successfully.

Cc: Steve Glendinning <steve.glendinning@shawell.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Lee Jones <redacted>
Seems to me like it'll do the trick.
Acked-by: Linus Walleij <redacted>

Yours,
Linus Walleij

Re: [PATCH 4/4] net/smsc911x: Provide common clock functionality

From: Russell King - ARM Linux <hidden>
Date: 2012-12-20 19:25:05

On Thu, Dec 20, 2012 at 08:12:08PM +0100, Linus Walleij wrote:
On Wed, Dec 19, 2012 at 6:19 PM, Lee Jones [off-list ref] wrote:
quoted
Some platforms provide clocks which require enabling before the
SMSC911x chip will power on. This patch uses the new common clk
framework to do just that. If no clock is provided, it will just
be ignored and the driver will continue to assume that no clock
is required for the chip to run successfully.

Cc: Steve Glendinning <steve.glendinning@shawell.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Lee Jones <redacted>
Seems to me like it'll do the trick.
Acked-by: Linus Walleij <redacted>
This looks fairly dangerous.  What about those platforms which use this
driver, but don't provide a clock for it?

It looks like this will result in those platforms losing their ethernet
support.  There's at least a bunch of the ARM evaluation boards which
make use of this driver...

Re: [PATCH 4/4] net/smsc911x: Provide common clock functionality

From: Lee Jones <hidden>
Date: 2012-12-20 20:41:05

On Thu, 20 Dec 2012, Russell King - ARM Linux wrote:
On Thu, Dec 20, 2012 at 08:12:08PM +0100, Linus Walleij wrote:
quoted
On Wed, Dec 19, 2012 at 6:19 PM, Lee Jones [off-list ref] wrote:
quoted
Some platforms provide clocks which require enabling before the
SMSC911x chip will power on. This patch uses the new common clk
framework to do just that. If no clock is provided, it will just
be ignored and the driver will continue to assume that no clock
is required for the chip to run successfully.

Cc: Steve Glendinning <steve.glendinning@shawell.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Lee Jones <redacted>
Seems to me like it'll do the trick.
Acked-by: Linus Walleij <redacted>
This looks fairly dangerous.  What about those platforms which use this
driver, but don't provide a clock for it?

It looks like this will result in those platforms losing their ethernet
support.  There's at least a bunch of the ARM evaluation boards which
make use of this driver...
Right, but nothing should regress. If no clock is provided the driver
moves on during the request and will refuse to prepare, enable and
disable there after. 

Unless I've made a mistake somewhere? If so, I'd be happy to fixup.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

Re: [PATCH 4/4] net/smsc911x: Provide common clock functionality

From: Russell King - ARM Linux <hidden>
Date: 2012-12-20 20:51:39

On Thu, Dec 20, 2012 at 08:35:14PM +0000, Lee Jones wrote:
On Thu, 20 Dec 2012, Russell King - ARM Linux wrote:
quoted
On Thu, Dec 20, 2012 at 08:12:08PM +0100, Linus Walleij wrote:
quoted
On Wed, Dec 19, 2012 at 6:19 PM, Lee Jones [off-list ref] wrote:
quoted
Some platforms provide clocks which require enabling before the
SMSC911x chip will power on. This patch uses the new common clk
framework to do just that. If no clock is provided, it will just
be ignored and the driver will continue to assume that no clock
is required for the chip to run successfully.

Cc: Steve Glendinning <steve.glendinning@shawell.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Lee Jones <redacted>
Seems to me like it'll do the trick.
Acked-by: Linus Walleij <redacted>
This looks fairly dangerous.  What about those platforms which use this
driver, but don't provide a clock for it?

It looks like this will result in those platforms losing their ethernet
support.  There's at least a bunch of the ARM evaluation boards which
make use of this driver...
Right, but nothing should regress. If no clock is provided the driver
moves on during the request and will refuse to prepare, enable and
disable there after. 

Unless I've made a mistake somewhere? If so, I'd be happy to fixup.
No, but... don't use NULL for that.  Use IS_ERR(pdata->clk) instead.

Re: [PATCH 4/4] net/smsc911x: Provide common clock functionality

From: Lee Jones <hidden>
Date: 2012-12-21 09:13:19

On Thu, 20 Dec 2012, Russell King - ARM Linux wrote:
On Thu, Dec 20, 2012 at 08:35:14PM +0000, Lee Jones wrote:
quoted
On Thu, 20 Dec 2012, Russell King - ARM Linux wrote:
quoted
On Thu, Dec 20, 2012 at 08:12:08PM +0100, Linus Walleij wrote:
quoted
On Wed, Dec 19, 2012 at 6:19 PM, Lee Jones [off-list ref] wrote:
quoted
Some platforms provide clocks which require enabling before the
SMSC911x chip will power on. This patch uses the new common clk
framework to do just that. If no clock is provided, it will just
be ignored and the driver will continue to assume that no clock
is required for the chip to run successfully.

Cc: Steve Glendinning <steve.glendinning@shawell.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Lee Jones <redacted>
Seems to me like it'll do the trick.
Acked-by: Linus Walleij <redacted>
This looks fairly dangerous.  What about those platforms which use this
driver, but don't provide a clock for it?

It looks like this will result in those platforms losing their ethernet
support.  There's at least a bunch of the ARM evaluation boards which
make use of this driver...
Right, but nothing should regress. If no clock is provided the driver
moves on during the request and will refuse to prepare, enable and
disable there after. 

Unless I've made a mistake somewhere? If so, I'd be happy to fixup.
No, but... don't use NULL for that.  Use IS_ERR(pdata->clk) instead.
I'm a bit confused. I do use IS_ERR, then if there was a problem
pdata->clk is set to NULL, then we test for NULL thereafter:
/* Request clock */
pdata->clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(pdata->clk)) {
        netdev_warn(ndev, "couldn't get clock %d\n", PTR_ERR(pdata->clk));
        pdata->clk = NULL;
}
Are you saying remove "pdata->clk = NULL;" and test for IS_ERR
every time?

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Re: [PATCH 4/4] net/smsc911x: Provide common clock functionality

From: Russell King - ARM Linux <hidden>
Date: 2012-12-21 09:25:51

On Fri, Dec 21, 2012 at 09:13:06AM +0000, Lee Jones wrote:
Are you saying remove "pdata->clk = NULL;" and test for IS_ERR
every time?
Exactly.

[PATCH 4/4 v2] net/smsc911x: Provide common clock functionality

From: Lee Jones <hidden>
Date: 2012-12-21 11:49:01

Some platforms provide clocks which require enabling before the
SMSC911x chip will power on. This patch uses the new common clk
framework to do just that. If no clock is provided, it will just
be ignored and the driver will continue to assume that no clock
is required for the chip to run successfully.

Cc: Steve Glendinning <steve.glendinning@shawell.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Lee Jones <redacted>
---
 drivers/net/ethernet/smsc/smsc911x.c |   29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index e112877..afa4d62 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -33,6 +33,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/crc32.h>
+#include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/etherdevice.h>
@@ -144,6 +145,9 @@ struct smsc911x_data {
 
 	/* regulators */
 	struct regulator_bulk_data supplies[SMSC911X_NUM_SUPPLIES];
+
+	/* clock */
+	struct clk *clk;
 };
 
 /* Easy access to information */
@@ -369,7 +373,7 @@ out:
 }
 
 /*
- * enable resources, currently just regulators.
+ * enable regulator and clock resources.
  */
 static int smsc911x_enable_resources(struct platform_device *pdev)
 {
@@ -382,6 +386,13 @@ static int smsc911x_enable_resources(struct platform_device *pdev)
 	if (ret)
 		netdev_err(ndev, "failed to enable regulators %d\n",
 				ret);
+
+	if (IS_ERR(pdata->clk)) {
+		ret = clk_prepare_enable(pdata->clk);
+		if (ret < 0)
+			netdev_err(ndev, "failed to enable clock %d\n", ret);
+	}
+
 	return ret;
 }
 
@@ -396,6 +407,10 @@ static int smsc911x_disable_resources(struct platform_device *pdev)
 
 	ret = regulator_bulk_disable(ARRAY_SIZE(pdata->supplies),
 			pdata->supplies);
+
+	if (IS_ERR(pdata->clk))
+		clk_disable_unprepare(pdata->clk);
+
 	return ret;
 }
 
@@ -421,6 +436,12 @@ static int smsc911x_request_resources(struct platform_device *pdev)
 	if (ret)
 		netdev_err(ndev, "couldn't get regulators %d\n",
 				ret);
+
+	/* Request clock */
+	pdata->clk = clk_get(&pdev->dev, NULL);
+	if (IS_ERR(pdata->clk))
+		netdev_warn(ndev, "couldn't get clock %li\n", PTR_ERR(pdata->clk));
+
 	return ret;
 }
 
@@ -436,6 +457,12 @@ static void smsc911x_free_resources(struct platform_device *pdev)
 	/* Free regulators */
 	regulator_bulk_free(ARRAY_SIZE(pdata->supplies),
 			pdata->supplies);
+
+	/* Free clock */
+	if (IS_ERR(pdata->clk)) {
+		clk_put(pdata->clk);
+		pdata->clk = NULL;
+	}
 }
 
 /* waits for MAC not busy, with timeout.  Only called by smsc911x_mac_read
-- 
1.7.9.5

Re: [PATCH 4/4 v2] net/smsc911x: Provide common clock functionality

From: Linus Walleij <hidden>
Date: 2012-12-26 00:51:10

On Fri, Dec 21, 2012 at 12:41 PM, Lee Jones [off-list ref] wrote:
+       if (IS_ERR(pdata->clk)) {
+               ret = clk_prepare_enable(pdata->clk);
+               if (ret < 0)
+                       netdev_err(ndev, "failed to enable clock %d\n", ret);
+       }
I think you got all of these backwards now, shouldn't it be if
(!IS_ERR(pdata->clk)) { } ...?

It's late here but enlighten me if I don't get it.
+       if (IS_ERR(pdata->clk))
+               clk_disable_unprepare(pdata->clk);
Dito.
+       /* Request clock */
+       pdata->clk = clk_get(&pdev->dev, NULL);
+       if (IS_ERR(pdata->clk))
+               netdev_warn(ndev, "couldn't get clock %li\n", PTR_ERR(pdata->clk));
This one seems correct though.
+       /* Free clock */
+       if (IS_ERR(pdata->clk)) {
+               clk_put(pdata->clk);
+               pdata->clk = NULL;
+       }
Should be !IS_ERR()

Yours,
Linus Walleij

[PATCH 4/4 v2] net/smsc911x: Provide common clock functionality

From: Lee Jones <hidden>
Date: 2012-12-27 19:31:24

No, you're right, I'm a moron.

Will fix up and resend when I'm back to work.

Sent from my mobile Linux device.
On Dec 26, 2012 12:51 AM, "Linus Walleij" [off-list ref] wrote:
On Fri, Dec 21, 2012 at 12:41 PM, Lee Jones [off-list ref] wrote:
quoted
+       if (IS_ERR(pdata->clk)) {
+               ret = clk_prepare_enable(pdata->clk);
+               if (ret < 0)
+                       netdev_err(ndev, "failed to enable clock %d\n",
ret);
quoted
+       }
I think you got all of these backwards now, shouldn't it be if
(!IS_ERR(pdata->clk)) { } ...?

It's late here but enlighten me if I don't get it.
quoted
+       if (IS_ERR(pdata->clk))
+               clk_disable_unprepare(pdata->clk);
Dito.
quoted
+       /* Request clock */
+       pdata->clk = clk_get(&pdev->dev, NULL);
+       if (IS_ERR(pdata->clk))
+               netdev_warn(ndev, "couldn't get clock %li\n",
PTR_ERR(pdata->clk));

This one seems correct though.
quoted
+       /* Free clock */
+       if (IS_ERR(pdata->clk)) {
+               clk_put(pdata->clk);
+               pdata->clk = NULL;
+       }
Should be !IS_ERR()

Yours,
Linus Walleij

[PATCH 4/4 v3] net/smsc911x: Provide common clock functionality

From: Lee Jones <hidden>
Date: 2013-01-03 11:15:07

Some platforms provide clocks which require enabling before the
SMSC911x chip will power on. This patch uses the new common clk
framework to do just that. If no clock is provided, it will just
be ignored and the driver will continue to assume that no clock
is required for the chip to run successfully.

Cc: Steve Glendinning <steve.glendinning@shawell.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Lee Jones <redacted>
---
 drivers/net/ethernet/smsc/smsc911x.c |   29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index e112877..f9b6bb7 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -33,6 +33,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/crc32.h>
+#include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/etherdevice.h>
@@ -144,6 +145,9 @@ struct smsc911x_data {
 
 	/* regulators */
 	struct regulator_bulk_data supplies[SMSC911X_NUM_SUPPLIES];
+
+	/* clock */
+	struct clk *clk;
 };
 
 /* Easy access to information */
@@ -369,7 +373,7 @@ out:
 }
 
 /*
- * enable resources, currently just regulators.
+ * enable regulator and clock resources.
  */
 static int smsc911x_enable_resources(struct platform_device *pdev)
 {
@@ -382,6 +386,13 @@ static int smsc911x_enable_resources(struct platform_device *pdev)
 	if (ret)
 		netdev_err(ndev, "failed to enable regulators %d\n",
 				ret);
+
+	if (!IS_ERR(pdata->clk)) {
+		ret = clk_prepare_enable(pdata->clk);
+		if (ret < 0)
+			netdev_err(ndev, "failed to enable clock %d\n", ret);
+	}
+
 	return ret;
 }
 
@@ -396,6 +407,10 @@ static int smsc911x_disable_resources(struct platform_device *pdev)
 
 	ret = regulator_bulk_disable(ARRAY_SIZE(pdata->supplies),
 			pdata->supplies);
+
+	if (!IS_ERR(pdata->clk))
+		clk_disable_unprepare(pdata->clk);
+
 	return ret;
 }
 
@@ -421,6 +436,12 @@ static int smsc911x_request_resources(struct platform_device *pdev)
 	if (ret)
 		netdev_err(ndev, "couldn't get regulators %d\n",
 				ret);
+
+	/* Request clock */
+	pdata->clk = clk_get(&pdev->dev, NULL);
+	if (IS_ERR(pdata->clk))
+		netdev_warn(ndev, "couldn't get clock %li\n", PTR_ERR(pdata->clk));
+
 	return ret;
 }
 
@@ -436,6 +457,12 @@ static void smsc911x_free_resources(struct platform_device *pdev)
 	/* Free regulators */
 	regulator_bulk_free(ARRAY_SIZE(pdata->supplies),
 			pdata->supplies);
+
+	/* Free clock */
+	if (!IS_ERR(pdata->clk)) {
+		clk_put(pdata->clk);
+		pdata->clk = NULL;
+	}
 }
 
 /* waits for MAC not busy, with timeout.  Only called by smsc911x_mac_read
-- 
1.7.9.5

Re: [PATCH 4/4 v3] net/smsc911x: Provide common clock functionality

From: Linus Walleij <hidden>
Date: 2013-01-03 14:28:44

On Thu, Jan 3, 2013 at 12:14 PM, Lee Jones [off-list ref] wrote:
Some platforms provide clocks which require enabling before the
SMSC911x chip will power on. This patch uses the new common clk
framework to do just that. If no clock is provided, it will just
be ignored and the driver will continue to assume that no clock
is required for the chip to run successfully.

Cc: Steve Glendinning <steve.glendinning@shawell.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Lee Jones <redacted>
Looks all right to me now:
Reviewed-by: Linus Walleij <redacted>

Yours,
Linus Walleij

Re: [PATCH 4/4 v3] net/smsc911x: Provide common clock functionality

From: Lee Jones <hidden>
Date: 2013-01-07 14:16:56

On Thu, 03 Jan 2013, Linus Walleij wrote:
On Thu, Jan 3, 2013 at 12:14 PM, Lee Jones [off-list ref] wrote:
quoted
Some platforms provide clocks which require enabling before the
SMSC911x chip will power on. This patch uses the new common clk
framework to do just that. If no clock is provided, it will just
be ignored and the driver will continue to assume that no clock
is required for the chip to run successfully.

Cc: Steve Glendinning <steve.glendinning@shawell.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Lee Jones <redacted>
Looks all right to me now:
Reviewed-by: Linus Walleij <redacted>
Great, thanks Linus.

Who will take this patch now?

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

Re: [PATCH 4/4 v3] net/smsc911x: Provide common clock functionality

From: Lee Jones <hidden>
Date: 2013-01-09 08:56:01

On Thu, 03 Jan 2013, Linus Walleij wrote:
On Thu, Jan 3, 2013 at 12:14 PM, Lee Jones [off-list ref] wrote:
quoted
Some platforms provide clocks which require enabling before the
SMSC911x chip will power on. This patch uses the new common clk
framework to do just that. If no clock is provided, it will just
be ignored and the driver will continue to assume that no clock
is required for the chip to run successfully.

Cc: Steve Glendinning <steve.glendinning@shawell.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Lee Jones <redacted>
Looks all right to me now:
Reviewed-by: Linus Walleij <redacted>
I still need a maintiner Ack for this before I can push it.

Anyone?

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

Re: [PATCH 4/4] net/smsc911x: Provide common clock functionality

From: Lee Jones <hidden>
Date: 2013-01-09 08:57:04

On Wed, 19 Dec 2012, Lee Jones wrote:
quoted hunk
Some platforms provide clocks which require enabling before the
SMSC911x chip will power on. This patch uses the new common clk
framework to do just that. If no clock is provided, it will just
be ignored and the driver will continue to assume that no clock
is required for the chip to run successfully.

Cc: Steve Glendinning <steve.glendinning@shawell.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Lee Jones <redacted>
---
 drivers/net/ethernet/smsc/smsc911x.c |   31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index 4616bf2..f6196cd 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -33,6 +33,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/crc32.h>
+#include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/etherdevice.h>
@@ -144,6 +145,9 @@ struct smsc911x_data {
 
 	/* regulators */
 	struct regulator_bulk_data supplies[SMSC911X_NUM_SUPPLIES];
+
+	/* clock */
+	struct clk *clk;
 };
 
 /* Easy access to information */
@@ -369,7 +373,7 @@ out:
 }
 
 /*
- * enable resources, currently just regulators.
+ * enable regulator and clock resources.
  */
 static int smsc911x_enable_resources(struct platform_device *pdev)
 {
@@ -382,6 +386,13 @@ static int smsc911x_enable_resources(struct platform_device *pdev)
 	if (ret)
 		netdev_err(ndev, "failed to enable regulators %d\n",
 				ret);
+
+	if (pdata->clk) {
+		ret = clk_prepare_enable(pdata->clk);
+		if (ret < 0)
+			netdev_err(ndev, "failed to enable clock %d\n", ret);
+	}
+
 	return ret;
 }
 
@@ -396,6 +407,10 @@ static int smsc911x_disable_resources(struct platform_device *pdev)
 
 	ret = regulator_bulk_disable(ARRAY_SIZE(pdata->supplies),
 			pdata->supplies);
+
+	if (pdata->clk)
+		clk_disable_unprepare(pdata->clk);
+
 	return ret;
 }
 
@@ -421,6 +436,14 @@ static int smsc911x_request_resources(struct platform_device *pdev)
 	if (ret)
 		netdev_err(ndev, "couldn't get regulators %d\n",
 				ret);
+
+	/* Request clock */
+	pdata->clk = clk_get(&pdev->dev, NULL);
+	if (IS_ERR(pdata->clk)) {
+		netdev_warn(ndev, "couldn't get clock %d\n", PTR_ERR(pdata->clk));
+		pdata->clk = NULL;
+	}
+
 	return ret;
 }
 
@@ -436,6 +459,12 @@ static void smsc911x_free_resources(struct platform_device *pdev)
 	/* Free regulators */
 	regulator_bulk_free(ARRAY_SIZE(pdata->supplies),
 			pdata->supplies);
+
+	/* Free clock */
+	if (pdata->clk) {
+		clk_put(pdata->clk);
+		pdata->clk = NULL;
+	}
 }
 
 /* waits for MAC not busy, with timeout.  Only called by smsc911x_mac_read
-- 
1.7.9.5
I still need a maintiner Ack for this before I can push it.

Mike?

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

Re: [PATCH 4/4 v3] net/smsc911x: Provide common clock functionality

From: Ulf Hansson <hidden>
Date: 2013-01-09 16:32:23

On 9 January 2013 09:55, Lee Jones [off-list ref] wrote:
On Thu, 03 Jan 2013, Linus Walleij wrote:
quoted
On Thu, Jan 3, 2013 at 12:14 PM, Lee Jones [off-list ref] wrote:
quoted
Some platforms provide clocks which require enabling before the
SMSC911x chip will power on. This patch uses the new common clk
framework to do just that. If no clock is provided, it will just
be ignored and the driver will continue to assume that no clock
is required for the chip to run successfully.

Cc: Steve Glendinning <steve.glendinning@shawell.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Lee Jones <redacted>
Looks all right to me now:
Reviewed-by: Linus Walleij <redacted>
I still need a maintiner Ack for this before I can push it.

Anyone?

--
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Reviewed-by: Ulf Hansson <redacted>

Re: [PATCH 4/4 v3] net/smsc911x: Provide common clock functionality

From: Linus Walleij <hidden>
Date: 2013-01-17 10:25:23

On Wed, Jan 9, 2013 at 9:55 AM, Lee Jones [off-list ref] wrote:
On Thu, 03 Jan 2013, Linus Walleij wrote:
quoted
On Thu, Jan 3, 2013 at 12:14 PM, Lee Jones [off-list ref] wrote:
quoted
Some platforms provide clocks which require enabling before the
SMSC911x chip will power on. This patch uses the new common clk
framework to do just that. If no clock is provided, it will just
be ignored and the driver will continue to assume that no clock
is required for the chip to run successfully.

Cc: Steve Glendinning <steve.glendinning@shawell.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Lee Jones <redacted>
Looks all right to me now:
Reviewed-by: Linus Walleij <redacted>
I still need a maintiner Ack for this before I can push it.

Anyone?
Steve is there sometimes. But I'd ask David Miller to ACK
it if he's OK with the change.

Yours,
Linus Walleij

Re: [PATCH 4/4 v3] net/smsc911x: Provide common clock functionality

From: Lee Jones <hidden>
Date: 2013-01-17 10:47:54

quoted
quoted
quoted
Some platforms provide clocks which require enabling before the
SMSC911x chip will power on. This patch uses the new common clk
framework to do just that. If no clock is provided, it will just
be ignored and the driver will continue to assume that no clock
is required for the chip to run successfully.

Cc: Steve Glendinning <steve.glendinning@shawell.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Lee Jones <redacted>
Looks all right to me now:
Reviewed-by: Linus Walleij <redacted>
I still need a maintiner Ack for this before I can push it.

Anyone?
Steve is there sometimes. But I'd ask David Miller to ACK
it if he's OK with the change.

Yours,
Linus Walleij
Hi David,

Does this [1] patch look okay to you too?

It's the last Ack I require before I can push the set.

[1] https://patchwork.kernel.org/patch/1926971/

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

Re: [PATCH 4/4 v3] net/smsc911x: Provide common clock functionality

From: David Miller <davem@davemloft.net>
Date: 2013-01-17 19:37:11

From: Lee Jones <redacted>
Date: Thu, 17 Jan 2013 10:47:44 +0000
https://patchwork.kernel.org/patch/1926971/
I'm fine with this:

Acked-by: David S. Miller <davem@davemloft.net>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help