All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: mdio: mux-meson-g12a: use __clk_is_enabled to simplify the code
@ 2023-01-26 20:39 ` Heiner Kallweit
  0 siblings, 0 replies; 5+ messages in thread
From: Heiner Kallweit @ 2023-01-26 20:39 UTC (permalink / raw)
  To: Andrew Lunn, Russell King - ARM Linux, David Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Neil Armstrong,
	Kevin Hilman, Jerome Brunet, Martin Blumenstingl
  Cc: netdev, linux-arm-kernel, open list:ARM/Amlogic Meson...

By using __clk_is_enabled () we can avoid defining an own variable for
tracking whether enable counter is zero.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/mdio/mdio-mux-meson-g12a.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/net/mdio/mdio-mux-meson-g12a.c b/drivers/net/mdio/mdio-mux-meson-g12a.c
index 1c1ed6e11..9d21fdf85 100644
--- a/drivers/net/mdio/mdio-mux-meson-g12a.c
+++ b/drivers/net/mdio/mdio-mux-meson-g12a.c
@@ -52,7 +52,6 @@
 #define MESON_G12A_MDIO_INTERNAL_ID 1
 
 struct g12a_mdio_mux {
-	bool pll_is_enabled;
 	void __iomem *regs;
 	void *mux_handle;
 	struct clk *pll;
@@ -152,14 +151,12 @@ static int g12a_enable_internal_mdio(struct g12a_mdio_mux *priv)
 	int ret;
 
 	/* Enable the phy clock */
-	if (!priv->pll_is_enabled) {
+	if (!__clk_is_enabled(priv->pll)) {
 		ret = clk_prepare_enable(priv->pll);
 		if (ret)
 			return ret;
 	}
 
-	priv->pll_is_enabled = true;
-
 	/* Initialize ephy control */
 	writel(EPHY_G12A_ID, priv->regs + ETH_PHY_CNTL0);
 	writel(FIELD_PREP(PHY_CNTL1_ST_MODE, 3) |
@@ -183,10 +180,8 @@ static int g12a_enable_external_mdio(struct g12a_mdio_mux *priv)
 	writel_relaxed(0x0, priv->regs + ETH_PHY_CNTL2);
 
 	/* Disable the phy clock if enabled */
-	if (priv->pll_is_enabled) {
+	if (__clk_is_enabled(priv->pll))
 		clk_disable_unprepare(priv->pll);
-		priv->pll_is_enabled = false;
-	}
 
 	return 0;
 }
@@ -338,7 +333,7 @@ static int g12a_mdio_mux_remove(struct platform_device *pdev)
 
 	mdio_mux_uninit(priv->mux_handle);
 
-	if (priv->pll_is_enabled)
+	if (__clk_is_enabled(priv->pll))
 		clk_disable_unprepare(priv->pll);
 
 	return 0;
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next] net: mdio: mux-meson-g12a: use __clk_is_enabled to simplify the code
@ 2023-01-26 20:39 ` Heiner Kallweit
  0 siblings, 0 replies; 5+ messages in thread
From: Heiner Kallweit @ 2023-01-26 20:39 UTC (permalink / raw)
  To: Andrew Lunn, Russell King - ARM Linux, David Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Neil Armstrong,
	Kevin Hilman, Jerome Brunet, Martin Blumenstingl
  Cc: netdev, linux-arm-kernel, open list:ARM/Amlogic Meson...

By using __clk_is_enabled () we can avoid defining an own variable for
tracking whether enable counter is zero.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/mdio/mdio-mux-meson-g12a.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/net/mdio/mdio-mux-meson-g12a.c b/drivers/net/mdio/mdio-mux-meson-g12a.c
index 1c1ed6e11..9d21fdf85 100644
--- a/drivers/net/mdio/mdio-mux-meson-g12a.c
+++ b/drivers/net/mdio/mdio-mux-meson-g12a.c
@@ -52,7 +52,6 @@
 #define MESON_G12A_MDIO_INTERNAL_ID 1
 
 struct g12a_mdio_mux {
-	bool pll_is_enabled;
 	void __iomem *regs;
 	void *mux_handle;
 	struct clk *pll;
@@ -152,14 +151,12 @@ static int g12a_enable_internal_mdio(struct g12a_mdio_mux *priv)
 	int ret;
 
 	/* Enable the phy clock */
-	if (!priv->pll_is_enabled) {
+	if (!__clk_is_enabled(priv->pll)) {
 		ret = clk_prepare_enable(priv->pll);
 		if (ret)
 			return ret;
 	}
 
-	priv->pll_is_enabled = true;
-
 	/* Initialize ephy control */
 	writel(EPHY_G12A_ID, priv->regs + ETH_PHY_CNTL0);
 	writel(FIELD_PREP(PHY_CNTL1_ST_MODE, 3) |
@@ -183,10 +180,8 @@ static int g12a_enable_external_mdio(struct g12a_mdio_mux *priv)
 	writel_relaxed(0x0, priv->regs + ETH_PHY_CNTL2);
 
 	/* Disable the phy clock if enabled */
-	if (priv->pll_is_enabled) {
+	if (__clk_is_enabled(priv->pll))
 		clk_disable_unprepare(priv->pll);
-		priv->pll_is_enabled = false;
-	}
 
 	return 0;
 }
@@ -338,7 +333,7 @@ static int g12a_mdio_mux_remove(struct platform_device *pdev)
 
 	mdio_mux_uninit(priv->mux_handle);
 
-	if (priv->pll_is_enabled)
+	if (__clk_is_enabled(priv->pll))
 		clk_disable_unprepare(priv->pll);
 
 	return 0;
-- 
2.39.1


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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next] net: mdio: mux-meson-g12a: use __clk_is_enabled to simplify the code
@ 2023-01-26 20:39 ` Heiner Kallweit
  0 siblings, 0 replies; 5+ messages in thread
From: Heiner Kallweit @ 2023-01-26 20:39 UTC (permalink / raw)
  To: Andrew Lunn, Russell King - ARM Linux, David Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Neil Armstrong,
	Kevin Hilman, Jerome Brunet, Martin Blumenstingl
  Cc: netdev, linux-arm-kernel, open list:ARM/Amlogic Meson...

By using __clk_is_enabled () we can avoid defining an own variable for
tracking whether enable counter is zero.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/mdio/mdio-mux-meson-g12a.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/net/mdio/mdio-mux-meson-g12a.c b/drivers/net/mdio/mdio-mux-meson-g12a.c
index 1c1ed6e11..9d21fdf85 100644
--- a/drivers/net/mdio/mdio-mux-meson-g12a.c
+++ b/drivers/net/mdio/mdio-mux-meson-g12a.c
@@ -52,7 +52,6 @@
 #define MESON_G12A_MDIO_INTERNAL_ID 1
 
 struct g12a_mdio_mux {
-	bool pll_is_enabled;
 	void __iomem *regs;
 	void *mux_handle;
 	struct clk *pll;
@@ -152,14 +151,12 @@ static int g12a_enable_internal_mdio(struct g12a_mdio_mux *priv)
 	int ret;
 
 	/* Enable the phy clock */
-	if (!priv->pll_is_enabled) {
+	if (!__clk_is_enabled(priv->pll)) {
 		ret = clk_prepare_enable(priv->pll);
 		if (ret)
 			return ret;
 	}
 
-	priv->pll_is_enabled = true;
-
 	/* Initialize ephy control */
 	writel(EPHY_G12A_ID, priv->regs + ETH_PHY_CNTL0);
 	writel(FIELD_PREP(PHY_CNTL1_ST_MODE, 3) |
@@ -183,10 +180,8 @@ static int g12a_enable_external_mdio(struct g12a_mdio_mux *priv)
 	writel_relaxed(0x0, priv->regs + ETH_PHY_CNTL2);
 
 	/* Disable the phy clock if enabled */
-	if (priv->pll_is_enabled) {
+	if (__clk_is_enabled(priv->pll))
 		clk_disable_unprepare(priv->pll);
-		priv->pll_is_enabled = false;
-	}
 
 	return 0;
 }
@@ -338,7 +333,7 @@ static int g12a_mdio_mux_remove(struct platform_device *pdev)
 
 	mdio_mux_uninit(priv->mux_handle);
 
-	if (priv->pll_is_enabled)
+	if (__clk_is_enabled(priv->pll))
 		clk_disable_unprepare(priv->pll);
 
 	return 0;
-- 
2.39.1


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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] net: mdio: mux-meson-g12a: use __clk_is_enabled to simplify the code
  2023-01-26 20:39 ` Heiner Kallweit
@ 2023-01-31  4:59   ` Jakub Kicinski
  -1 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2023-01-31  4:59 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: Andrew Lunn, Russell King - ARM Linux, David Miller,
	Eric Dumazet, Paolo Abeni, Neil Armstrong, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl, netdev, linux-arm-kernel,
	open list:ARM/Amlogic Meson...

On Thu, 26 Jan 2023 21:39:16 +0100 Heiner Kallweit wrote:
> By using __clk_is_enabled () we can avoid defining an own variable for
> tracking whether enable counter is zero.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

Appears to have been applied, thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] net: mdio: mux-meson-g12a: use __clk_is_enabled to simplify the code
@ 2023-01-31  4:59   ` Jakub Kicinski
  0 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2023-01-31  4:59 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: Andrew Lunn, Russell King - ARM Linux, David Miller,
	Eric Dumazet, Paolo Abeni, Neil Armstrong, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl, netdev, linux-arm-kernel,
	open list:ARM/Amlogic Meson...

On Thu, 26 Jan 2023 21:39:16 +0100 Heiner Kallweit wrote:
> By using __clk_is_enabled () we can avoid defining an own variable for
> tracking whether enable counter is zero.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

Appears to have been applied, thanks!

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-01-31  5:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-26 20:39 [PATCH net-next] net: mdio: mux-meson-g12a: use __clk_is_enabled to simplify the code Heiner Kallweit
2023-01-26 20:39 ` Heiner Kallweit
2023-01-26 20:39 ` Heiner Kallweit
2023-01-31  4:59 ` Jakub Kicinski
2023-01-31  4:59   ` Jakub Kicinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.