[PATCH] macb: convert platform data phy_irq_pin to an int

Subsystems: the rest

STALE5381d

9 messages, 4 authors, 2011-11-30 · open the first message on its own page

[PATCH] macb: convert platform data phy_irq_pin to an int

From: Jamie Iles <hidden>
Date: 2011-11-24 09:48:25

AT91 platforms have been updated to set the phy_irq_pin to -EINVAL if
not present, but phy_irq_pin is currently a u8.

Reported-by: Stephen Rothwell <redacted>
Cc: Jean-Christophe PLAGNIOL-VILLARD <redacted>
Cc: Nicolas Ferre <redacted>
Signed-off-by: Jamie Iles <redacted>
---
 include/linux/platform_data/macb.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/include/linux/platform_data/macb.h b/include/linux/platform_data/macb.h
index e7c748f..b081c72 100644
--- a/include/linux/platform_data/macb.h
+++ b/include/linux/platform_data/macb.h
@@ -10,7 +10,7 @@
 
 struct macb_platform_data {
 	u32		phy_mask;
-	u8		phy_irq_pin;	/* PHY IRQ */
+	int		phy_irq_pin;	/* PHY IRQ */
 	u8		is_rmii;	/* using RMII interface? */
 };
 
-- 
1.7.4.1

Re: [PATCH] macb: convert platform data phy_irq_pin to an int

From: Nicolas Ferre <hidden>
Date: 2011-11-24 10:47:55

On 11/24/2011 10:48 AM, Jamie Iles :
AT91 platforms have been updated to set the phy_irq_pin to -EINVAL if
not present, but phy_irq_pin is currently a u8.

Reported-by: Stephen Rothwell <redacted>
Cc: Jean-Christophe PLAGNIOL-VILLARD <redacted>
Cc: Nicolas Ferre <redacted>
Acked-by: Nicolas Ferre <redacted>
quoted hunk
Signed-off-by: Jamie Iles <redacted>
---
 include/linux/platform_data/macb.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/include/linux/platform_data/macb.h b/include/linux/platform_data/macb.h
index e7c748f..b081c72 100644
--- a/include/linux/platform_data/macb.h
+++ b/include/linux/platform_data/macb.h
@@ -10,7 +10,7 @@
 
 struct macb_platform_data {
 	u32		phy_mask;
-	u8		phy_irq_pin;	/* PHY IRQ */
+	int		phy_irq_pin;	/* PHY IRQ */
 	u8		is_rmii;	/* using RMII interface? */
 };
 

-- 
Nicolas Ferre

[PATCH] at91_ether: use gpio_is_valid for phy IRQ line

From: Nicolas Ferre <hidden>
Date: 2011-11-24 21:21:40

Use the generic gpiolib gpio_is_valid() function to test
if the phy IRQ line GPIO is actually provided.

For non-connected or non-existing phy IRQ lines, -EINVAL
value is used for phy_irq_pin field of struct at91_eth_data.

Signed-off-by: Nicolas Ferre <redacted>
---
 drivers/net/ethernet/cadence/at91_ether.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/cadence/at91_ether.c b/drivers/net/ethernet/cadence/at91_ether.c
index 56624d3..a1c4143 100644
--- a/drivers/net/ethernet/cadence/at91_ether.c
+++ b/drivers/net/ethernet/cadence/at91_ether.c
@@ -255,8 +255,7 @@ static void enable_phyirq(struct net_device *dev)
 	unsigned int dsintr, irq_number;
 	int status;
 
-	irq_number = lp->board_data.phy_irq_pin;
-	if (!irq_number) {
+	if (!gpio_is_valid(lp->board_data.phy_irq_pin)) {
 		/*
 		 * PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L),
 		 * or board does not have it connected.
@@ -265,6 +264,7 @@ static void enable_phyirq(struct net_device *dev)
 		return;
 	}
 
+	irq_number = lp->board_data.phy_irq_pin;
 	status = request_irq(irq_number, at91ether_phy_interrupt, 0, dev->name, dev);
 	if (status) {
 		printk(KERN_ERR "at91_ether: PHY IRQ %d request failed - status %d!\n", irq_number, status);
@@ -319,8 +319,7 @@ static void disable_phyirq(struct net_device *dev)
 	unsigned int dsintr;
 	unsigned int irq_number;
 
-	irq_number = lp->board_data.phy_irq_pin;
-	if (!irq_number) {
+	if (!gpio_is_valid(lp->board_data.phy_irq_pin)) {
 		del_timer_sync(&lp->check_timer);
 		return;
 	}
@@ -365,6 +364,7 @@ static void disable_phyirq(struct net_device *dev)
 	disable_mdi();
 	spin_unlock_irq(&lp->lock);
 
+	irq_number = lp->board_data.phy_irq_pin;
 	free_irq(irq_number, dev);			/* Free interrupt handler */
 }
 
@@ -1077,7 +1077,7 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
 	netif_carrier_off(dev);		/* will be enabled in open() */
 
 	/* If board has no PHY IRQ, use a timer to poll the PHY */
-	if (!lp->board_data.phy_irq_pin) {
+	if (!gpio_is_valid(lp->board_data.phy_irq_pin)) {
 		init_timer(&lp->check_timer);
 		lp->check_timer.data = (unsigned long)dev;
 		lp->check_timer.function = at91ether_check_link;
@@ -1169,7 +1169,8 @@ static int __devexit at91ether_remove(struct platform_device *pdev)
 	struct net_device *dev = platform_get_drvdata(pdev);
 	struct at91_private *lp = netdev_priv(dev);
 
-	if (lp->board_data.phy_irq_pin >= 32)
+	if (gpio_is_valid(lp->board_data.phy_irq_pin) &&
+	    lp->board_data.phy_irq_pin >= 32)
 		gpio_free(lp->board_data.phy_irq_pin);
 
 	unregister_netdev(dev);
@@ -1188,11 +1189,12 @@ static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg)
 {
 	struct net_device *net_dev = platform_get_drvdata(pdev);
 	struct at91_private *lp = netdev_priv(net_dev);
-	int phy_irq = lp->board_data.phy_irq_pin;
 
 	if (netif_running(net_dev)) {
-		if (phy_irq)
+		if (gpio_is_valid(lp->board_data.phy_irq_pin)) {
+			int phy_irq = lp->board_data.phy_irq_pin;
 			disable_irq(phy_irq);
+		}
 
 		netif_stop_queue(net_dev);
 		netif_device_detach(net_dev);
@@ -1206,7 +1208,6 @@ static int at91ether_resume(struct platform_device *pdev)
 {
 	struct net_device *net_dev = platform_get_drvdata(pdev);
 	struct at91_private *lp = netdev_priv(net_dev);
-	int phy_irq = lp->board_data.phy_irq_pin;
 
 	if (netif_running(net_dev)) {
 		clk_enable(lp->ether_clk);
@@ -1214,8 +1215,10 @@ static int at91ether_resume(struct platform_device *pdev)
 		netif_device_attach(net_dev);
 		netif_start_queue(net_dev);
 
-		if (phy_irq)
+		if (gpio_is_valid(lp->board_data.phy_irq_pin)) {
+			int phy_irq = lp->board_data.phy_irq_pin;
 			enable_irq(phy_irq);
+		}
 	}
 	return 0;
 }
-- 
1.7.5.4

Re: [PATCH] at91_ether: use gpio_is_valid for phy IRQ line

From: Jamie Iles <hidden>
Date: 2011-11-24 22:28:36

Hi Nicolas,

On Thu, Nov 24, 2011 at 10:21:14PM +0100, Nicolas Ferre wrote:
quoted hunk
Use the generic gpiolib gpio_is_valid() function to test
if the phy IRQ line GPIO is actually provided.

For non-connected or non-existing phy IRQ lines, -EINVAL
value is used for phy_irq_pin field of struct at91_eth_data.

Signed-off-by: Nicolas Ferre <redacted>
---
 drivers/net/ethernet/cadence/at91_ether.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/cadence/at91_ether.c b/drivers/net/ethernet/cadence/at91_ether.c
index 56624d3..a1c4143 100644
--- a/drivers/net/ethernet/cadence/at91_ether.c
+++ b/drivers/net/ethernet/cadence/at91_ether.c
@@ -255,8 +255,7 @@ static void enable_phyirq(struct net_device *dev)
 	unsigned int dsintr, irq_number;
 	int status;
 
-	irq_number = lp->board_data.phy_irq_pin;
-	if (!irq_number) {
+	if (!gpio_is_valid(lp->board_data.phy_irq_pin)) {
 		/*
 		 * PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L),
 		 * or board does not have it connected.
@@ -265,6 +264,7 @@ static void enable_phyirq(struct net_device *dev)
 		return;
 	}
 
+	irq_number = lp->board_data.phy_irq_pin;
Does this need to be:

	irq_number = gpio_to_irq(lp->board_data.phy_irq_pin);

and the same for the other occurrences?  Otherwise this looks like the 
right thing to me.

Jamie

Re: [PATCH] at91_ether: use gpio_is_valid for phy IRQ line

From: Jean-Christophe PLAGNIOL-VILLARD <hidden>
Date: 2011-11-25 13:52:20

On 22:28 Thu 24 Nov     , Jamie Iles wrote:
Hi Nicolas,

On Thu, Nov 24, 2011 at 10:21:14PM +0100, Nicolas Ferre wrote:
quoted
Use the generic gpiolib gpio_is_valid() function to test
if the phy IRQ line GPIO is actually provided.

For non-connected or non-existing phy IRQ lines, -EINVAL
value is used for phy_irq_pin field of struct at91_eth_data.

Signed-off-by: Nicolas Ferre <redacted>
---
 drivers/net/ethernet/cadence/at91_ether.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/cadence/at91_ether.c b/drivers/net/ethernet/cadence/at91_ether.c
index 56624d3..a1c4143 100644
--- a/drivers/net/ethernet/cadence/at91_ether.c
+++ b/drivers/net/ethernet/cadence/at91_ether.c
@@ -255,8 +255,7 @@ static void enable_phyirq(struct net_device *dev)
 	unsigned int dsintr, irq_number;
 	int status;
 
-	irq_number = lp->board_data.phy_irq_pin;
-	if (!irq_number) {
+	if (!gpio_is_valid(lp->board_data.phy_irq_pin)) {
 		/*
 		 * PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L),
 		 * or board does not have it connected.
@@ -265,6 +264,7 @@ static void enable_phyirq(struct net_device *dev)
 		return;
 	}
 
+	irq_number = lp->board_data.phy_irq_pin;
Does this need to be:

	irq_number = gpio_to_irq(lp->board_data.phy_irq_pin);

and the same for the other occurrences?  Otherwise this looks like the 
right thing to me.
yes

Acked-by: Jean-Christophe PLAGNIOL-VILLARD <redacted>

Best Regards,
J.

Re: [PATCH] at91_ether: use gpio_is_valid for phy IRQ line

From: Nicolas Ferre <hidden>
Date: 2011-11-25 13:56:32

On 11/25/2011 02:47 PM, Jean-Christophe PLAGNIOL-VILLARD :
On 22:28 Thu 24 Nov     , Jamie Iles wrote:
quoted
Hi Nicolas,

On Thu, Nov 24, 2011 at 10:21:14PM +0100, Nicolas Ferre wrote:
quoted
Use the generic gpiolib gpio_is_valid() function to test
if the phy IRQ line GPIO is actually provided.

For non-connected or non-existing phy IRQ lines, -EINVAL
value is used for phy_irq_pin field of struct at91_eth_data.

Signed-off-by: Nicolas Ferre <redacted>
---
 drivers/net/ethernet/cadence/at91_ether.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/cadence/at91_ether.c b/drivers/net/ethernet/cadence/at91_ether.c
index 56624d3..a1c4143 100644
--- a/drivers/net/ethernet/cadence/at91_ether.c
+++ b/drivers/net/ethernet/cadence/at91_ether.c
@@ -255,8 +255,7 @@ static void enable_phyirq(struct net_device *dev)
 	unsigned int dsintr, irq_number;
 	int status;
 
-	irq_number = lp->board_data.phy_irq_pin;
-	if (!irq_number) {
+	if (!gpio_is_valid(lp->board_data.phy_irq_pin)) {
 		/*
 		 * PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L),
 		 * or board does not have it connected.
@@ -265,6 +264,7 @@ static void enable_phyirq(struct net_device *dev)
 		return;
 	}
 
+	irq_number = lp->board_data.phy_irq_pin;
Does this need to be:

	irq_number = gpio_to_irq(lp->board_data.phy_irq_pin);

and the same for the other occurrences?  Otherwise this looks like the 
right thing to me.
yes
True but I prefered to separate changes. As it was not addressed like
this in the code I clung to it. I will post an additional patch on top
of this one to add the gpio_to_irq() call.
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <redacted>
Best regards,
-- 
Nicolas Ferre

Re: [PATCH] at91_ether: use gpio_is_valid for phy IRQ line

From: David Miller <davem@davemloft.net>
Date: 2011-11-29 23:58:15

From: Nicolas Ferre <redacted>
Date: Thu, 24 Nov 2011 22:21:14 +0100
Use the generic gpiolib gpio_is_valid() function to test
if the phy IRQ line GPIO is actually provided.

For non-connected or non-existing phy IRQ lines, -EINVAL
value is used for phy_irq_pin field of struct at91_eth_data.

Signed-off-by: Nicolas Ferre <redacted>
I'm assuming this goes through the ARM tree, because in both of my networking
trees there is no ARM at91 implementation of gpio_is_valid().

Re: [PATCH] at91_ether: use gpio_is_valid for phy IRQ line

From: Jean-Christophe PLAGNIOL-VILLARD <hidden>
Date: 2011-11-30 04:53:53

On 18:53 Tue 29 Nov     , David Miller wrote:
From: Nicolas Ferre <redacted>
Date: Thu, 24 Nov 2011 22:21:14 +0100
quoted
Use the generic gpiolib gpio_is_valid() function to test
if the phy IRQ line GPIO is actually provided.

For non-connected or non-existing phy IRQ lines, -EINVAL
value is used for phy_irq_pin field of struct at91_eth_data.

Signed-off-by: Nicolas Ferre <redacted>
I'm assuming this goes through the ARM tree, because in both of my networking
trees there is no ARM at91 implementation of gpio_is_valid().
yes the depending patch series is in the arm-soc

can we have your ack or sob?

Best Regards,
J.

Re: [PATCH] at91_ether: use gpio_is_valid for phy IRQ line

From: David Miller <davem@davemloft.net>
Date: 2011-11-30 05:45:14

From: Jean-Christophe PLAGNIOL-VILLARD <redacted>
Date: Wed, 30 Nov 2011 05:44:03 +0100
On 18:53 Tue 29 Nov     , David Miller wrote:
quoted
From: Nicolas Ferre <redacted>
Date: Thu, 24 Nov 2011 22:21:14 +0100
quoted
Use the generic gpiolib gpio_is_valid() function to test
if the phy IRQ line GPIO is actually provided.

For non-connected or non-existing phy IRQ lines, -EINVAL
value is used for phy_irq_pin field of struct at91_eth_data.

Signed-off-by: Nicolas Ferre <redacted>
I'm assuming this goes through the ARM tree, because in both of my networking
trees there is no ARM at91 implementation of gpio_is_valid().
yes the depending patch series is in the arm-soc

can we have your ack or sob?
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