netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] net: phy: balance disable/enable irq on change
@ 2010-12-18 15:55 Jean-Michel Hautbois
  2010-12-18 15:55 ` [PATCH 2/2] net: phy: Fixed some checkpatch errors Jean-Michel Hautbois
  2010-12-18 16:47 ` [PATCH 1/2] net: phy: balance disable/enable irq on change Ben Hutchings
  0 siblings, 2 replies; 6+ messages in thread
From: Jean-Michel Hautbois @ 2010-12-18 15:55 UTC (permalink / raw)
  To: davem
  Cc: richard.cochran, shemminger, tj, randy.dunlap, netdev,
	linux-kernel, Jean-Michel Hautbois

When phy interface changes its status, it calls phy_change() function.
This function calls the interrupt disabling functions for the driver registered, but if this driver doesn't implement it, there is no IRQ disabling. After doing the work, we call enable_irq and not the respective driver function. This fixes it, as it could lead to an unbalanced IRQ.

Signed-off-by: Jean-Michel Hautbois <jhautbois@gmail.com>
---
 drivers/net/phy/phy.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 7670aac..b28f2ac 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -89,7 +89,8 @@ static int phy_config_interrupt(struct phy_device *phydev, u32 interrupts)
 	phydev->interrupts = interrupts;
 	if (phydev->drv->config_intr)
 		err = phydev->drv->config_intr(phydev);
-
+	else
+		err = -ENOSYS;
 	return err;
 }
 
@@ -541,6 +542,10 @@ static int phy_enable_interrupts(struct phy_device *phydev)
 		return err;
 
 	err = phy_config_interrupt(phydev, PHY_INTERRUPT_ENABLED);
+	if (err == -ENOSYS) {
+		err = 0;
+		enable_irq(phydev->irq);
+	}
 
 	return err;
 }
@@ -556,7 +561,10 @@ static int phy_disable_interrupts(struct phy_device *phydev)
 	/* Disable PHY interrupts */
 	err = phy_config_interrupt(phydev, PHY_INTERRUPT_DISABLED);
 
-	if (err)
+	if (err == -ENOSYS) {
+		err = 0;
+		disable_irq(phydev->irq);
+	} else if (err != 0)
 		goto phy_err;
 
 	/* Clear the interrupt */
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH 1/2] net: phy: balance disable/enable irq on change
@ 2010-12-18 18:38 Jean-Michel Hautbois
  2010-12-18 18:39 ` [PATCH 2/2] net: phy: Fixed some checkpatch errors Jean-Michel Hautbois
  0 siblings, 1 reply; 6+ messages in thread
From: Jean-Michel Hautbois @ 2010-12-18 18:38 UTC (permalink / raw)
  To: davem
  Cc: richard.cochran, shemminger, tj, randy.dunlap, netdev,
	linux-kernel, Jean-Michel Hautbois

When phy interface changes its status, it calls phy_change() function.
This function calls the interrupt disabling functions for the driver registered, but if this driver doesn't implement it, there is no IRQ disabling. After doing the work, we call enable_irq and not the respective driver function. This fixes it, as it could lead to an unbalanced IRQ.

Signed-off-by: Jean-Michel Hautbois <jhautbois@gmail.com>
---
 drivers/net/phy/phy.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 7670aac..b28f2ac 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -89,7 +89,8 @@ static int phy_config_interrupt(struct phy_device *phydev, u32 interrupts)
 	phydev->interrupts = interrupts;
 	if (phydev->drv->config_intr)
 		err = phydev->drv->config_intr(phydev);
-
+	else
+		err = -ENOSYS;
 	return err;
 }
 
@@ -541,6 +542,10 @@ static int phy_enable_interrupts(struct phy_device *phydev)
 		return err;
 
 	err = phy_config_interrupt(phydev, PHY_INTERRUPT_ENABLED);
+	if (err == -ENOSYS) {
+		err = 0;
+		enable_irq(phydev->irq);
+	}
 
 	return err;
 }
@@ -556,7 +561,10 @@ static int phy_disable_interrupts(struct phy_device *phydev)
 	/* Disable PHY interrupts */
 	err = phy_config_interrupt(phydev, PHY_INTERRUPT_DISABLED);
 
-	if (err)
+	if (err == -ENOSYS) {
+		err = 0;
+		disable_irq(phydev->irq);
+	} else if (err != 0)
 		goto phy_err;
 
 	/* Clear the interrupt */
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH 1/2] net: phy: balance disable/enable irq on change
@ 2010-12-18 18:41 Jean-Michel Hautbois
  2010-12-18 18:41 ` [PATCH 2/2] net: phy: Fixed some checkpatch errors Jean-Michel Hautbois
  0 siblings, 1 reply; 6+ messages in thread
From: Jean-Michel Hautbois @ 2010-12-18 18:41 UTC (permalink / raw)
  To: davem
  Cc: richard.cochran, shemminger, tj, randy.dunlap, netdev,
	linux-kernel, Jean-Michel Hautbois

When phy interface changes its status, it calls phy_change() function.
This function calls the interrupt disabling functions for the driver
registered, but if this driver doesn't implement it, there is no IRQ
disabling. After doing the work, we call enable_irq and not the
respective driver function. This fixes it, as it could lead to an
unbalanced IRQ. Error code changed to EOPNOTSUPP.

Signed-off-by: Jean-Michel Hautbois <jhautbois@gmail.com>
---
 drivers/net/phy/phy.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 7670aac..5f23e8e 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -89,7 +89,8 @@ static int phy_config_interrupt(struct phy_device *phydev, u32 interrupts)
 	phydev->interrupts = interrupts;
 	if (phydev->drv->config_intr)
 		err = phydev->drv->config_intr(phydev);
-
+	else
+		err = -EOPNOTSUPP;
 	return err;
 }
 
@@ -541,6 +542,10 @@ static int phy_enable_interrupts(struct phy_device *phydev)
 		return err;
 
 	err = phy_config_interrupt(phydev, PHY_INTERRUPT_ENABLED);
+	if (err == -EOPNOTSUPP) {
+		err = 0;
+		enable_irq(phydev->irq);
+	}
 
 	return err;
 }
@@ -556,7 +561,10 @@ static int phy_disable_interrupts(struct phy_device *phydev)
 	/* Disable PHY interrupts */
 	err = phy_config_interrupt(phydev, PHY_INTERRUPT_DISABLED);
 
-	if (err)
+	if (err == -EOPNOTSUPP) {
+		err = 0;
+		disable_irq(phydev->irq);
+	} else if (err != 0)
 		goto phy_err;
 
 	/* Clear the interrupt */
-- 
1.7.0.4

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

end of thread, other threads:[~2010-12-19  9:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-18 15:55 [PATCH 1/2] net: phy: balance disable/enable irq on change Jean-Michel Hautbois
2010-12-18 15:55 ` [PATCH 2/2] net: phy: Fixed some checkpatch errors Jean-Michel Hautbois
2010-12-18 16:47 ` [PATCH 1/2] net: phy: balance disable/enable irq on change Ben Hutchings
  -- strict thread matches above, loose matches on Subject: below --
2010-12-18 18:38 Jean-Michel Hautbois
2010-12-18 18:39 ` [PATCH 2/2] net: phy: Fixed some checkpatch errors Jean-Michel Hautbois
2010-12-18 18:41 [PATCH 1/2] net: phy: balance disable/enable irq on change Jean-Michel Hautbois
2010-12-18 18:41 ` [PATCH 2/2] net: phy: Fixed some checkpatch errors Jean-Michel Hautbois
2010-12-19  9:19   ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).