* [PATCH 2/2] net: phy: Fixed some checkpatch errors
2010-12-18 15:55 [PATCH 1/2] net: phy: balance disable/enable irq on change Jean-Michel Hautbois
@ 2010-12-18 15:55 ` Jean-Michel Hautbois
0 siblings, 0 replies; 5+ 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
Fixes some coding style issues (errors and warnings).
Signed-off-by: Jean-Michel Hautbois <jhautbois@gmail.com>
---
drivers/net/phy/phy.c | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index b28f2ac..69758b4 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -33,10 +33,10 @@
#include <linux/timer.h>
#include <linux/workqueue.h>
-#include <asm/atomic.h>
-#include <asm/io.h>
+#include <linux/atomic.h>
+#include <linux/io.h>
#include <asm/irq.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
/**
* phy_print_status - Convenience function to print out the current phy status
@@ -47,11 +47,11 @@ void phy_print_status(struct phy_device *phydev)
pr_info("PHY: %s - Link is %s", dev_name(&phydev->dev),
phydev->link ? "Up" : "Down");
if (phydev->link)
- printk(" - %d/%s", phydev->speed,
+ pr_info(" - %d/%s", phydev->speed,
DUPLEX_FULL == phydev->duplex ?
"Full" : "Half");
- printk("\n");
+ pr_info("\n");
}
EXPORT_SYMBOL(phy_print_status);
@@ -325,7 +325,7 @@ int phy_mii_ioctl(struct phy_device *phydev,
case SIOCSMIIREG:
if (mii_data->phy_id == phydev->addr) {
- switch(mii_data->reg_num) {
+ switch (mii_data->reg_num) {
case MII_BMCR:
if ((val & (BMCR_RESET|BMCR_ANENABLE)) == 0)
phydev->autoneg = AUTONEG_DISABLE;
@@ -352,7 +352,7 @@ int phy_mii_ioctl(struct phy_device *phydev,
}
phy_write(phydev, mii_data->reg_num, val);
-
+
if (mii_data->reg_num == MII_BMCR &&
val & BMCR_RESET &&
phydev->drv->config_init) {
@@ -471,7 +471,7 @@ static void phy_force_reduction(struct phy_device *phydev)
int idx;
idx = phy_find_setting(phydev->speed, phydev->duplex);
-
+
idx++;
idx = phy_find_valid(idx, phydev->supported);
@@ -732,6 +732,7 @@ out_unlock:
* will not reenable interrupts.
*/
}
+EXPORT_SYMBOL(phy_stop);
/**
@@ -762,7 +763,6 @@ void phy_start(struct phy_device *phydev)
}
mutex_unlock(&phydev->lock);
}
-EXPORT_SYMBOL(phy_stop);
EXPORT_SYMBOL(phy_start);
/**
@@ -782,7 +782,7 @@ void phy_state_machine(struct work_struct *work)
if (phydev->adjust_state)
phydev->adjust_state(phydev->attached_dev);
- switch(phydev->state) {
+ switch (phydev->state) {
case PHY_DOWN:
case PHY_STARTING:
case PHY_READY:
--
1.7.0.4
^ permalink raw reply related [flat|nested] 5+ 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; 5+ 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] 5+ messages in thread
* [PATCH 2/2] net: phy: Fixed some checkpatch errors
2010-12-18 18:38 [PATCH 1/2] net: phy: balance disable/enable irq on change Jean-Michel Hautbois
@ 2010-12-18 18:39 ` Jean-Michel Hautbois
0 siblings, 0 replies; 5+ messages in thread
From: Jean-Michel Hautbois @ 2010-12-18 18:39 UTC (permalink / raw)
To: davem
Cc: richard.cochran, shemminger, tj, randy.dunlap, netdev,
linux-kernel, Jean-Michel Hautbois
Fixes some coding style issues (errors and warnings).
Signed-off-by: Jean-Michel Hautbois <jhautbois@gmail.com>
---
drivers/net/phy/phy.c | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index b28f2ac..69758b4 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -33,10 +33,10 @@
#include <linux/timer.h>
#include <linux/workqueue.h>
-#include <asm/atomic.h>
-#include <asm/io.h>
+#include <linux/atomic.h>
+#include <linux/io.h>
#include <asm/irq.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
/**
* phy_print_status - Convenience function to print out the current phy status
@@ -47,11 +47,11 @@ void phy_print_status(struct phy_device *phydev)
pr_info("PHY: %s - Link is %s", dev_name(&phydev->dev),
phydev->link ? "Up" : "Down");
if (phydev->link)
- printk(" - %d/%s", phydev->speed,
+ pr_info(" - %d/%s", phydev->speed,
DUPLEX_FULL == phydev->duplex ?
"Full" : "Half");
- printk("\n");
+ pr_info("\n");
}
EXPORT_SYMBOL(phy_print_status);
@@ -325,7 +325,7 @@ int phy_mii_ioctl(struct phy_device *phydev,
case SIOCSMIIREG:
if (mii_data->phy_id == phydev->addr) {
- switch(mii_data->reg_num) {
+ switch (mii_data->reg_num) {
case MII_BMCR:
if ((val & (BMCR_RESET|BMCR_ANENABLE)) == 0)
phydev->autoneg = AUTONEG_DISABLE;
@@ -352,7 +352,7 @@ int phy_mii_ioctl(struct phy_device *phydev,
}
phy_write(phydev, mii_data->reg_num, val);
-
+
if (mii_data->reg_num == MII_BMCR &&
val & BMCR_RESET &&
phydev->drv->config_init) {
@@ -471,7 +471,7 @@ static void phy_force_reduction(struct phy_device *phydev)
int idx;
idx = phy_find_setting(phydev->speed, phydev->duplex);
-
+
idx++;
idx = phy_find_valid(idx, phydev->supported);
@@ -732,6 +732,7 @@ out_unlock:
* will not reenable interrupts.
*/
}
+EXPORT_SYMBOL(phy_stop);
/**
@@ -762,7 +763,6 @@ void phy_start(struct phy_device *phydev)
}
mutex_unlock(&phydev->lock);
}
-EXPORT_SYMBOL(phy_stop);
EXPORT_SYMBOL(phy_start);
/**
@@ -782,7 +782,7 @@ void phy_state_machine(struct work_struct *work)
if (phydev->adjust_state)
phydev->adjust_state(phydev->attached_dev);
- switch(phydev->state) {
+ switch (phydev->state) {
case PHY_DOWN:
case PHY_STARTING:
case PHY_READY:
--
1.7.0.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] net: phy: Fixed some checkpatch errors
2010-12-18 18:41 [PATCH 1/2] net: phy: balance disable/enable irq on change Jean-Michel Hautbois
@ 2010-12-18 18:41 ` Jean-Michel Hautbois
2010-12-19 9:19 ` Joe Perches
0 siblings, 1 reply; 5+ 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
Fixes some coding style issues (errors and warnings).
Signed-off-by: Jean-Michel Hautbois <jhautbois@gmail.com>
---
drivers/net/phy/phy.c | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 5f23e8e..d6a9b29 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -33,10 +33,10 @@
#include <linux/timer.h>
#include <linux/workqueue.h>
-#include <asm/atomic.h>
-#include <asm/io.h>
+#include <linux/atomic.h>
+#include <linux/io.h>
#include <asm/irq.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
/**
* phy_print_status - Convenience function to print out the current phy status
@@ -47,11 +47,11 @@ void phy_print_status(struct phy_device *phydev)
pr_info("PHY: %s - Link is %s", dev_name(&phydev->dev),
phydev->link ? "Up" : "Down");
if (phydev->link)
- printk(" - %d/%s", phydev->speed,
+ pr_info(" - %d/%s", phydev->speed,
DUPLEX_FULL == phydev->duplex ?
"Full" : "Half");
- printk("\n");
+ pr_info("\n");
}
EXPORT_SYMBOL(phy_print_status);
@@ -325,7 +325,7 @@ int phy_mii_ioctl(struct phy_device *phydev,
case SIOCSMIIREG:
if (mii_data->phy_id == phydev->addr) {
- switch(mii_data->reg_num) {
+ switch (mii_data->reg_num) {
case MII_BMCR:
if ((val & (BMCR_RESET|BMCR_ANENABLE)) == 0)
phydev->autoneg = AUTONEG_DISABLE;
@@ -352,7 +352,7 @@ int phy_mii_ioctl(struct phy_device *phydev,
}
phy_write(phydev, mii_data->reg_num, val);
-
+
if (mii_data->reg_num == MII_BMCR &&
val & BMCR_RESET &&
phydev->drv->config_init) {
@@ -471,7 +471,7 @@ static void phy_force_reduction(struct phy_device *phydev)
int idx;
idx = phy_find_setting(phydev->speed, phydev->duplex);
-
+
idx++;
idx = phy_find_valid(idx, phydev->supported);
@@ -732,6 +732,7 @@ out_unlock:
* will not reenable interrupts.
*/
}
+EXPORT_SYMBOL(phy_stop);
/**
@@ -762,7 +763,6 @@ void phy_start(struct phy_device *phydev)
}
mutex_unlock(&phydev->lock);
}
-EXPORT_SYMBOL(phy_stop);
EXPORT_SYMBOL(phy_start);
/**
@@ -782,7 +782,7 @@ void phy_state_machine(struct work_struct *work)
if (phydev->adjust_state)
phydev->adjust_state(phydev->attached_dev);
- switch(phydev->state) {
+ switch (phydev->state) {
case PHY_DOWN:
case PHY_STARTING:
case PHY_READY:
--
1.7.0.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] net: phy: Fixed some checkpatch errors
2010-12-18 18:41 ` [PATCH 2/2] net: phy: Fixed some checkpatch errors Jean-Michel Hautbois
@ 2010-12-19 9:19 ` Joe Perches
0 siblings, 0 replies; 5+ messages in thread
From: Joe Perches @ 2010-12-19 9:19 UTC (permalink / raw)
To: Jean-Michel Hautbois
Cc: davem, richard.cochran, shemminger, tj, randy.dunlap, netdev,
linux-kernel
On Sat, 2010-12-18 at 19:41 +0100, Jean-Michel Hautbois wrote:
> Fixes some coding style issues (errors and warnings).
Hi Jean-Michel.
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
[]
> @@ -47,11 +47,11 @@ void phy_print_status(struct phy_device *phydev)
> pr_info("PHY: %s - Link is %s", dev_name(&phydev->dev),
> phydev->link ? "Up" : "Down");
> if (phydev->link)
> - printk(" - %d/%s", phydev->speed,
> + pr_info(" - %d/%s", phydev->speed,
> DUPLEX_FULL == phydev->duplex ?
> "Full" : "Half");
>
> - printk("\n");
> + pr_info("\n");
This isn't the right way to fix this actually.
The first pr_info is not terminated with a newline,
so the second printk should be printk(KERN_CONT or
pr_cont instead.
Ideally, you would make a different change.
There should be just one printk/pr_info.
Fewer messages, couldn't be interleaved with other
simultaneous output, easier to grep, etc...
I think something like this would be better:
if (phydev->link)
pr_info("PHY: %s - Link is down\n", dev_name(&phydev->dev));
else
pr_info("PHY: %s - Link is up - %d/%s\n",
dev_name(&phydev->dev),
phydev->speed,
phydev->duplex == DUPLEX_FULL ? "Full" : "Half");
or maybe use dev_info like this:
if (phydev->link)
dev_info(&phydev->dev, "PHY: Link is down\n");
else
dev_info(&phydev->dev, "PHY: Link is up - %d/%s\n",
phydev->speed,
phydev->duplex == DUPLEX_FULL ? "Full" : "Half");
cheers, Joe
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-12-19 9:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-18 18:38 [PATCH 1/2] net: phy: balance disable/enable irq on change Jean-Michel Hautbois
2010-12-18 18:39 ` [PATCH 2/2] net: phy: Fixed some checkpatch errors Jean-Michel Hautbois
-- strict thread matches above, loose matches on Subject: below --
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
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
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).