ibm_newemac: Allow the "no flow control" EMAC feature to work
Subsystems (2)
PATCH 1/3 ibm_newemac: Allow the "no flow control" EMAC feature to work
In reply to a message not in the archiveSome PowerPC 40x chips have errata that force us not to use the integrated flow control. We have the feature defined, but it currently can't be used because it is never added to EMAC_FTRS_POSSIBLE.
This adds a Kconfig option for affected platforms to select and puts the feature in the EMAC_FTRS_POSSIBLE list. This is set for PowerPC 405EZ platforms as well.
--- drivers/net/ibm_newemac/Kconfig | 4 ++++ drivers/net/ibm_newemac/core.c | 2 ++ drivers/net/ibm_newemac/core.h | 3 +++ 3 files changed, 9 insertions(+), 0 deletions(-)
drivers/net/ibm_newemac/Kconfig +4 -0
@@ -62,3 +62,7 @@ config IBM_NEW_EMAC_TAH config IBM_NEW_EMAC_EMAC4 bool default n + +config IBM_NEW_EMAC_NO_FLOW_CTRL + bool + default n
drivers/net/ibm_newemac/core.c +2 -0
@@ -2567,6 +2567,8 @@ static int __devinit emac_init_config(struct emac_instance *dev)if (of_device_is_compatible (np,"ibm,emac-440ep" ) ||of_device_is_compatible (np,"ibm,emac-440gr" )) dev->features |=EMAC_FTR_440EP_PHY_CLK_FIX ; +if (of_device_is_compatible (np,"ibm,emac-405ez" )) + dev->features |= EMAC_FTR_NO_FLOW_CONTROL_40x; }/* Fixup some feature bits based on the device tree */
drivers/net/ibm_newemac/core.h +3 -0
@@ -341,6 +341,9 @@ enum {#ifdef CONFIG_IBM_NEW_EMAC_RGMII EMAC_FTR_HAS_RGMII |#endif +#ifdef CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL + EMAC_FTR_NO_FLOW_CONTROL_40x | +#endif EMAC_FTR_440EP_PHY_CLK_FIX, };
Signature · 1 line
1.5.5.1
PATCH 2/3 ibm_newemac: Introduce mal_has_feature
In reply to a message not in the archiveThere are some PowerPC SoCs that do odd things with the MAL handling. In order to accommodate them, we need to introduce a feature mechanism that is similar to the existing emac_has_feature function.
This adds a feature variable to the mal_instance structure, and adds a mal_has_feature function with some feature definitions. These are guarded by Kconfig options that are selected by the affected platforms.
--- drivers/net/ibm_newemac/Kconfig | 8 ++++++++ drivers/net/ibm_newemac/mal.h | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 0 deletions(-)
drivers/net/ibm_newemac/Kconfig +8 -0
@@ -66,3 +66,11 @@ config IBM_NEW_EMAC_EMAC4 config IBM_NEW_EMAC_NO_FLOW_CTRL bool default n + +config IBM_NEW_EMAC_MAL_CLR_ICINTSTAT + bool + default n + +config IBM_NEW_EMAC_MAL_COMMON_ERR + bool + default n
drivers/net/ibm_newemac/mal.h +37 -0
@@ -213,6 +213,8 @@ struct mal_instance {struct of_device *ofdev;int index;spinlock_t lock; + +unsigned int features; };static inline u32 get_mal_dcrn (struct mal_instance *mal,int reg)
@@ -225,6 +227,41 @@ static inline void set_mal_dcrn(struct mal_instance *mal, int reg, u32 val)dcr_write (mal->dcr_host, reg, val); } +/* Features of various MAL implementations */ + +/* Dummy feature bit so the enum works properly */ +#define MAL_FTR_DUMMY 0x00000001 + +/* Set if you have interrupt coalescing and you have to clear the SDR +* register for TXEOB and RXEOB interrupts to work +*/ +#define MAL_FTR_CLEAR_ICINTSTAT 0x00000002 + +/* Set if your MAL has SERR, TXDE, and RXDE OR'd into a single UIC +* interrupt +*/ +#define MAL_FTR_COMMON_ERR_INT 0x00000004 + +enum { +MAL_FTRS_ALWAYS =0 , + + MAL_FTRS_POSSIBLE = +#ifdef CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT + MAL_FTR_CLEAR_ICINTSTAT | +#endif +#ifdef CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR + MAL_FTR_COMMON_ERR_INT | +#endif +MAL_FTR_DUMMY , +}; + +static inline int mal_has_feature (struct mal_instance *dev, +unsigned long feature) +{ +return (MAL_FTRS_ALWAYS & feature) || + (MAL_FTRS_POSSIBLE & dev->features & feature); +} +/* Register MAL devices */ int mal_init (void );void mal_exit (void );
Signature · 1 line
1.5.5.1
PATCH 3/3 ibm_newemac: MAL support for PowerPC 405EZ
In reply to a message not in the archiveThe PowerPC 405EZ SoC has some differences in the interrupt layout and handling for the MAL. The SERR, TXDE, and RXDE interrupts are OR'd into a single interrupt. Also, due to the possibility for interrupt coalescing, the TXEOB and RXEOB interrupts require an interrupt bit to be cleared in the ICINTSTAT SDR.
This sets the proper MAL feature bits for 405EZ boards, and adds a common shared handler for SERR, TXDE, and RXDE. This has been adapted from code originally written by Stefan Roese.
--- drivers/net/ibm_newemac/mal.c | 98 ++++++++++++++++++++++++++++++++-------- 1 files changed, 78 insertions(+), 20 deletions(-)
drivers/net/ibm_newemac/mal.c +78 -20
@@ -28,6 +28,7 @@#include <linux/delay.h> #include "core.h" +#include <asm/dcr-regs.h> static int mal_count;
@@ -279,6 +280,9 @@ static irqreturn_t mal_txeob(int irq, void *dev_instance)mal_schedule_poll (mal);set_mal_dcrn (mal,MAL_TXEOBISR , r); +if (mal_has_feature (mal,MAL_FTR_CLEAR_ICINTSTAT )) +mtdcri (SDR0 ,0x4510 , (mfdcri (SDR0 ,0x4510 ) |0x60000000 )); +return IRQ_HANDLED ; }
@@ -293,6 +297,9 @@ static irqreturn_t mal_rxeob(int irq, void *dev_instance)mal_schedule_poll (mal);set_mal_dcrn (mal,MAL_RXEOBISR , r); +if (mal_has_feature (mal,MAL_FTR_CLEAR_ICINTSTAT )) +mtdcri (SDR0 ,0x4510 , (mfdcri (SDR0 ,0x4510 ) |0x80000000 )); +return IRQ_HANDLED ; }
@@ -336,6 +343,25 @@ static irqreturn_t mal_rxde(int irq, void *dev_instance)return IRQ_HANDLED ; } +static irqreturn_t mal_int (int irq,void *dev_instance) +{ +struct mal_instance *mal = dev_instance; +u32 esr =get_mal_dcrn (mal,MAL_ESR ); + +if (esr &MAL_ESR_EVB ) { +/* descriptor error */ +if (esr &MAL_ESR_DE ) { +if (esr &MAL_ESR_CIDT ) +return (mal_rxde (irq, dev_instance)); +else +return (mal_txde (irq, dev_instance)); + }else {/* SERR */ +return (mal_serr (irq, dev_instance)); + } + } +return IRQ_HANDLED ; +} +void mal_poll_disable (struct mal_instance *mal,struct mal_commac *commac) {/* Spinlock-type semantics: only one caller disable poll at a time */
@@ -542,11 +568,22 @@ static int __devinit mal_probe(struct of_device *ofdev, goto fail; } - mal->txeob_irq =irq_of_parse_and_map (ofdev->node,0 ); - mal->rxeob_irq =irq_of_parse_and_map (ofdev->node,1 ); - mal->serr_irq =irq_of_parse_and_map (ofdev->node,2 ); - mal->txde_irq =irq_of_parse_and_map (ofdev->node,3 ); - mal->rxde_irq =irq_of_parse_and_map (ofdev->node,4 ); +if (of_device_is_compatible (ofdev->node,"ibm,mcmal-405ez" )) + mal->features |= (MAL_FTR_CLEAR_ICINTSTAT |MAL_FTR_COMMON_ERR_INT ); + +if (mal_has_feature (mal,MAL_FTR_COMMON_ERR_INT )) { + mal->txeob_irq =irq_of_parse_and_map (ofdev->node,0 ); + mal->rxeob_irq =irq_of_parse_and_map (ofdev->node,1 ); + mal->serr_irq =irq_of_parse_and_map (ofdev->node,2 ); + mal->txde_irq = mal->rxde_irq = mal->serr_irq; + }else { + mal->txeob_irq =irq_of_parse_and_map (ofdev->node,0 ); + mal->rxeob_irq =irq_of_parse_and_map (ofdev->node,1 ); + mal->serr_irq =irq_of_parse_and_map (ofdev->node,2 ); + mal->txde_irq =irq_of_parse_and_map (ofdev->node,3 ); + mal->rxde_irq =irq_of_parse_and_map (ofdev->node,4 ); + } +if (mal->txeob_irq ==NO_IRQ || mal->rxeob_irq ==NO_IRQ || mal->serr_irq ==NO_IRQ || mal->txde_irq ==NO_IRQ || mal->rxde_irq ==NO_IRQ ) {
@@ -608,21 +645,42 @@ static int __devinit mal_probe(struct of_device *ofdev,sizeof (struct mal_descriptor ) * mal_rx_bd_offset(mal, i)); - err =request_irq (mal->serr_irq, mal_serr,0 ,"MAL SERR" , mal); -if (err) - goto fail2; - err =request_irq (mal->txde_irq, mal_txde,0 ,"MAL TX DE" , mal); -if (err) - goto fail3; - err =request_irq (mal->txeob_irq, mal_txeob,0 ,"MAL TX EOB" , mal); -if (err) - goto fail4; - err =request_irq (mal->rxde_irq, mal_rxde,0 ,"MAL RX DE" , mal); -if (err) - goto fail5; - err =request_irq (mal->rxeob_irq, mal_rxeob,0 ,"MAL RX EOB" , mal); -if (err) - goto fail6; +if (mal_has_feature (mal,MAL_FTR_COMMON_ERR_INT )) { + err =request_irq (mal->serr_irq, mal_int,IRQF_SHARED , +"MAL SERR" , mal); +if (err) + goto fail2; + err =request_irq (mal->txde_irq, mal_int,IRQF_SHARED , +"MAL TX DE" , mal); +if (err) + goto fail3; + err =request_irq (mal->txeob_irq, mal_txeob,0 ,"MAL TX EOB" , mal); +if (err) + goto fail4; + err =request_irq (mal->rxde_irq, mal_int,IRQF_SHARED , +"MAL RX DE" , mal); +if (err) + goto fail5; + err =request_irq (mal->rxeob_irq, mal_rxeob,0 ,"MAL RX EOB" , mal); +if (err) + goto fail6; + }else { + err =request_irq (mal->serr_irq, mal_serr,0 ,"MAL SERR" , mal); +if (err) + goto fail2; + err =request_irq (mal->txde_irq, mal_txde,0 ,"MAL TX DE" , mal); +if (err) + goto fail3; + err =request_irq (mal->txeob_irq, mal_txeob,0 ,"MAL TX EOB" , mal); +if (err) + goto fail4; + err =request_irq (mal->rxde_irq, mal_rxde,0 ,"MAL RX DE" , mal); +if (err) + goto fail5; + err =request_irq (mal->rxeob_irq, mal_rxeob,0 ,"MAL RX EOB" , mal); +if (err) + goto fail6; + }/* Enable all MAL SERR interrupt sources */ if (mal->version ==2 )
Signature · 1 line
1.5.5.1
Re: [PATCH 3/3] ibm_newemac: MAL support for PowerPC 405EZ
Quoted 51 lines · Josh Boyer
The PowerPC 405EZ SoC has some differences in the interrupt layout and handling for the MAL. The SERR, TXDE, and RXDE interrupts are OR'd into a single interrupt. Also, due to the possibility for interrupt coalescing, the TXEOB and RXEOB interrupts require an interrupt bit to be cleared in the ICINTSTAT SDR.
This sets the proper MAL feature bits for 405EZ boards, and adds a common shared handler for SERR, TXDE, and RXDE. This has been adapted from code originally written by Stefan Roese.
Signed-off-by Josh Boyer <[email protected]>--- drivers/net/ibm_newemac/mal.c | 98 ++++++++++++++++++++++++++++++++-------- 1 files changed, 78 insertions(+), 20 deletions(-)drivers/net/ibm_newemac/mal.c +7
-0@@ -28,6 +28,7 @@#include <linux/delay.h> #include "core.h" +#include <asm/dcr-regs.h> static int mal_count;@@ -279,6 +280,9 @@ static irqreturn_t mal_txeob(int irq, void *dev_instance)mal_schedule_poll (mal);set_mal_dcrn (mal,MAL_TXEOBISR , r); +if (mal_has_feature (mal,MAL_FTR_CLEAR_ICINTSTAT )) +mtdcri (SDR0 ,0x4510 , (mfdcri (SDR0 ,0x4510 ) |0x60000000 )); +return IRQ_HANDLED ; }@@ -293,6 +297,9 @@ static irqreturn_t mal_rxeob(int irq, void *dev_instance)mal_schedule_poll (mal);set_mal_dcrn (mal,MAL_RXEOBISR , r); +if (mal_has_feature (mal,MAL_FTR_CLEAR_ICINTSTAT )) +mtdcri (SDR0 ,0x4510 , (mfdcri (SDR0 ,0x4510 ) |0x80000000 )); +return IRQ_HANDLED ; }@@ -336,6 +343,25 @@ static irqreturn_t mal_rxde(int irq, void *dev_instance)return IRQ_HANDLED ; }
drivers/net/ibm_newemac/mal.c static irqreturn_t mal_rxde(int irq, void *dev_instance) · line 355
Quoted 10 lines
drivers/net/ibm_newemac/mal.c +10
-0+static irqreturn_t mal_int (int irq,void *dev_instance) +{ +struct mal_instance *mal = dev_instance; +u32 esr =get_mal_dcrn (mal,MAL_ESR ); + +if (esr &MAL_ESR_EVB ) { +/* descriptor error */ +if (esr &MAL_ESR_DE ) { +if (esr &MAL_ESR_CIDT ) +return (mal_rxde (irq, dev_instance));
Return statements shouldn't be enlosed in brackets according to checkpatch.pl. Also in a few other places.
Quoted 13 lines
drivers/net/ibm_newemac/mal.c +9
-0+else +return (mal_txde (irq, dev_instance)); + }else {/* SERR */ +return (mal_serr (irq, dev_instance)); + } + } +return IRQ_HANDLED ; +} +void mal_poll_disable (struct mal_instance *mal,struct mal_commac *commac) {/* Spinlock-type semantics: only one caller disable poll at a time */
drivers/net/ibm_newemac/mal.c static int __devinit mal_probe(struct of_device *ofdev, · line 572
Quoted 10 lines
drivers/net/ibm_newemac/mal.c +2
-5@@ -542,11 +568,22 @@ static int __devinit mal_probe(struct of_device *ofdev, goto fail; } - mal->txeob_irq =irq_of_parse_and_map (ofdev->node,0 ); - mal->rxeob_irq =irq_of_parse_and_map (ofdev->node,1 ); - mal->serr_irq =irq_of_parse_and_map (ofdev->node,2 ); - mal->txde_irq =irq_of_parse_and_map (ofdev->node,3 ); - mal->rxde_irq =irq_of_parse_and_map (ofdev->node,4 ); +if (of_device_is_compatible (ofdev->node,"ibm,mcmal-405ez" )) + mal->features |= (MAL_FTR_CLEAR_ICINTSTAT |MAL_FTR_COMMON_ERR_INT );
The above like is >80 characters wide.
But I'm not sure that anyone cares.
drivers/net/ibm_newemac/mal.c static int __devinit mal_probe(struct of_device *ofdev, · line 585
Quoted 13 lines
drivers/net/ibm_newemac/mal.c +13
-0+ +if (mal_has_feature (mal,MAL_FTR_COMMON_ERR_INT )) { + mal->txeob_irq =irq_of_parse_and_map (ofdev->node,0 ); + mal->rxeob_irq =irq_of_parse_and_map (ofdev->node,1 ); + mal->serr_irq =irq_of_parse_and_map (ofdev->node,2 ); + mal->txde_irq = mal->rxde_irq = mal->serr_irq; + }else { + mal->txeob_irq =irq_of_parse_and_map (ofdev->node,0 ); + mal->rxeob_irq =irq_of_parse_and_map (ofdev->node,1 ); + mal->serr_irq =irq_of_parse_and_map (ofdev->node,2 ); + mal->txde_irq =irq_of_parse_and_map (ofdev->node,3 ); + mal->rxde_irq =irq_of_parse_and_map (ofdev->node,4 ); + }
It seems that that first three calls to irq_of_parse_and_map() could be moved outside of the if/else clause.
mal->txeob_irq = irq_of_parse_and_map(ofdev->node, 0);
mal->rxeob_irq = irq_of_parse_and_map(ofdev->node, 1);
mal->serr_irq = irq_of_parse_and_map(ofdev->node, 2);
if (mal_has_feature(mal, MAL_FTR_COMMON_ERR_INT)) {
mal->txde_irq = mal->rxde_irq = mal->serr_irq;
} else {
mal->txde_irq = irq_of_parse_and_map(ofdev->node, 3);
mal->rxde_irq = irq_of_parse_and_map(ofdev->node, 4);
}Quoted 49 lines
drivers/net/ibm_newemac/mal.c +27
-15+if (mal->txeob_irq ==NO_IRQ || mal->rxeob_irq ==NO_IRQ || mal->serr_irq ==NO_IRQ || mal->txde_irq ==NO_IRQ || mal->rxde_irq ==NO_IRQ ) {@@ -608,21 +645,42 @@ static int __devinit mal_probe(struct of_device *ofdev,sizeof (struct mal_descriptor ) * mal_rx_bd_offset(mal, i)); - err =request_irq (mal->serr_irq, mal_serr,0 ,"MAL SERR" , mal); -if (err) - goto fail2; - err =request_irq (mal->txde_irq, mal_txde,0 ,"MAL TX DE" , mal); -if (err) - goto fail3; - err =request_irq (mal->txeob_irq, mal_txeob,0 ,"MAL TX EOB" , mal); -if (err) - goto fail4; - err =request_irq (mal->rxde_irq, mal_rxde,0 ,"MAL RX DE" , mal); -if (err) - goto fail5; - err =request_irq (mal->rxeob_irq, mal_rxeob,0 ,"MAL RX EOB" , mal); -if (err) - goto fail6; +if (mal_has_feature (mal,MAL_FTR_COMMON_ERR_INT )) { + err =request_irq (mal->serr_irq, mal_int,IRQF_SHARED , +"MAL SERR" , mal); +if (err) + goto fail2; + err =request_irq (mal->txde_irq, mal_int,IRQF_SHARED , +"MAL TX DE" , mal); +if (err) + goto fail3; + err =request_irq (mal->txeob_irq, mal_txeob,0 ,"MAL TX EOB" , mal); +if (err) + goto fail4; + err =request_irq (mal->rxde_irq, mal_int,IRQF_SHARED , +"MAL RX DE" , mal); +if (err) + goto fail5; + err =request_irq (mal->rxeob_irq, mal_rxeob,0 ,"MAL RX EOB" , mal); +if (err) + goto fail6; + }else { + err =request_irq (mal->serr_irq, mal_serr,0 ,"MAL SERR" , mal); +if (err) + goto fail2; + err =request_irq (mal->txde_irq, mal_txde,0 ,"MAL TX DE" , mal); +if (err) + goto fail3;
drivers/net/ibm_newemac/mal.c static int __devinit mal_probe(struct of_device *ofdev, · line 683
Quoted 10 lines
drivers/net/ibm_newemac/mal.c +10
-0+ err =request_irq (mal->txeob_irq, mal_txeob,0 ,"MAL TX EOB" , mal); +if (err) + goto fail4; + err =request_irq (mal->rxde_irq, mal_rxde,0 ,"MAL RX DE" , mal); +if (err) + goto fail5; + err =request_irq (mal->rxeob_irq, mal_rxeob,0 ,"MAL RX EOB" , mal); +if (err) + goto fail6; + }
There seems to be a lot of repention in the above if/else clauses. I wonder if something like this might be nicer.
if (mal_has_feature(mal, MAL_FTR_COMMON_ERR_INT)) {
irqflags = IRQF_SHARED;
hdlr_serr = hdlr_txde = hdlr_rxde = mal_int;
} else {
irqflags = 0;
hdlr_serr = mal_serr;
hdlr_txde = mal_txde;
hdlr_rxde = mal_rxde;
}
err = request_irq(mal->serr_irq, hdlr_serr, irqflags, "MAL SERR", mal);
if (err)
goto fail2;
err = request_irq(mal->txde_irq, hdlr_txde, irqflags, "MAL TX DE", mal);
if (err)
goto fail3;
err = request_irq(mal->txeob_irq, mal_txeob, 0, "MAL TX EOB", mal);
if (err)
goto fail4;
err = request_irq(mal->rxde_irq, hdlr_rxde, irqflags, "MAL RX DE", mal);
if (err)
goto fail5;
err = request_irq(mal->rxeob_irq, mal_rxeob, 0, "MAL RX EOB", mal);
if (err)
goto fail6;Quoted 9 lines
drivers/net/ibm_newemac/mal.c +0
-0/* Enable all MAL SERR interrupt sources */ if (mal->version ==2 )Signature · 5 lines
1.5.5.1 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/3] ibm_newemac: Introduce mal_has_feature
In reply to Josh BoyerQuoted 9 lines · Josh Boyer
There are some PowerPC SoCs that do odd things with the MAL handling. In order to accommodate them, we need to introduce a feature mechanism that is similar to the existing
emac_has_featurefunction.This adds a feature variable to the
mal_instancestructure, and adds amal_has_featurefunction with some feature definitions. These are guarded byKconfigoptions that are selected by the affected platforms.Signed-of-by Josh Boyer <[email protected]>
You also add an actual feature (CLR_ICINSTAT). You should document that or move it to a separate patch.
drivers/net/ibm_newemac/mal.h static inline void set_mal_dcrn(struct mal_instance *mal, int reg, u32 val) · line 233
Quoted 4 lines
drivers/net/ibm_newemac/mal.h +4
-0+/* Features of various MAL implementations */ + +/* Dummy feature bit so the enum works properly */ +#define MAL_FTR_DUMMY 0x00000001
Nah. Just stick an | 0 in the enum to make it happy.
Cheers,
Ben.
Re: [PATCH 2/3] ibm_newemac: Introduce mal_has_feature
Quoted 5 lines · On Fri, 05 Sep 2008 13:19:23 +1000 Benjamin Herrenschmidt…
Quoted 4 lines · Josh Boyer
There are some PowerPC SoCs that do odd things with the MAL handling. In order to accommodate them, we need to introduce a feature mechanism that is similar to the existing
emac_has_featurefunction.
Quoted 8 lines
Quoted 5 lines
This adds a feature variable to the
mal_instancestructure, and adds amal_has_featurefunction with some feature definitions. These are guarded byKconfigoptions that are selected by the affected platforms.Signed-of-by Josh Boyer <[email protected]>You also add an actual feature (
CLR_ICINSTAT). You should document that or move it to a separate patch.
I add two features. And I so in the commit log, though I didn't actually say what those do. I can fix that up.
Quoted 7 lines
drivers/net/ibm_newemac/mal.h static inline void set_mal_dcrn(struct mal_instance *mal, int reg, u32 val) · line 233
Quoted 5 lines
drivers/net/ibm_newemac/mal.h +4
-0+/* Features of various MAL implementations */ + +/* Dummy feature bit so the enum works properly */ +#define MAL_FTR_DUMMY 0x00000001Nah. Just stick an | 0 in the enum to make it happy.
OK. I did that originally, but for some reason I wanted to avoid having FTRS_ALWAYS and FTRS_POSSIBLE be equal if none of the Kconfig options were set. I can't remember why though.
josh
Re: [PATCH 3/3] ibm_newemac: MAL support for PowerPC 405EZ
In reply to Simon HormanQuoted 5 lines · On Fri, 5 Sep 2008 12:10:37 +1000 Simon Horman <[email protected]> wrote:
Quoted 5 lines
drivers/net/ibm_newemac/mal.c +5
-0+static irqreturn_t mal_int (int irq,void *dev_instance) +{ +struct mal_instance *mal = dev_instance; +u32 esr =get_mal_dcrn (mal,MAL_ESR ); +
Quoted 8 lines
drivers/net/ibm_newemac/mal.c static irqreturn_t mal_rxde(int irq, void *dev_instance) · line 355
Quoted 5 lines
drivers/net/ibm_newemac/mal.c +5
-0+if (esr &MAL_ESR_EVB ) { +/* descriptor error */ +if (esr &MAL_ESR_DE ) { +if (esr &MAL_ESR_CIDT ) +return (mal_rxde (irq, dev_instance));Return statements shouldn't be enlosed in brackets according to checkpatch.pl. Also in a few other places.
I hate checkpatch, but that's easy enough to fix. Though I don't see what other places I add with that mistake.
Quoted 16 lines
Quoted 16 lines
drivers/net/ibm_newemac/mal.c +9
-0+else +return (mal_txde (irq, dev_instance)); + }else {/* SERR */ +return (mal_serr (irq, dev_instance)); + } + } +return IRQ_HANDLED ; +} +void mal_poll_disable (struct mal_instance *mal,struct mal_commac *commac) {/* Spinlock-type semantics: only one caller disable poll at a time */ @@ -542,11 +568,22 @@ static int __devinit mal_probe(struct of_device *ofdev, goto fail; }
Quoted 10 lines
drivers/net/ibm_newemac/mal.c static int __devinit mal_probe(struct of_device *ofdev, · line 572
Quoted 7 lines
drivers/net/ibm_newemac/mal.c +2
-5- mal->txeob_irq =irq_of_parse_and_map (ofdev->node,0 ); - mal->rxeob_irq =irq_of_parse_and_map (ofdev->node,1 ); - mal->serr_irq =irq_of_parse_and_map (ofdev->node,2 ); - mal->txde_irq =irq_of_parse_and_map (ofdev->node,3 ); - mal->rxde_irq =irq_of_parse_and_map (ofdev->node,4 ); +if (of_device_is_compatible (ofdev->node,"ibm,mcmal-405ez" )) + mal->features |= (MAL_FTR_CLEAR_ICINTSTAT |MAL_FTR_COMMON_ERR_INT );The above like is >80 characters wide.
But I'm not sure that anyone cares.
I don't. If Ben complains I'll change it.
Quoted 17 lines
drivers/net/ibm_newemac/mal.c static int __devinit mal_probe(struct of_device *ofdev, · line 585
Quoted 13 lines
drivers/net/ibm_newemac/mal.c +13
-0+ +if (mal_has_feature (mal,MAL_FTR_COMMON_ERR_INT )) { + mal->txeob_irq =irq_of_parse_and_map (ofdev->node,0 ); + mal->rxeob_irq =irq_of_parse_and_map (ofdev->node,1 ); + mal->serr_irq =irq_of_parse_and_map (ofdev->node,2 ); + mal->txde_irq = mal->rxde_irq = mal->serr_irq; + }else { + mal->txeob_irq =irq_of_parse_and_map (ofdev->node,0 ); + mal->rxeob_irq =irq_of_parse_and_map (ofdev->node,1 ); + mal->serr_irq =irq_of_parse_and_map (ofdev->node,2 ); + mal->txde_irq =irq_of_parse_and_map (ofdev->node,3 ); + mal->rxde_irq =irq_of_parse_and_map (ofdev->node,4 ); + }It seems that that first three calls to
irq_of_parse_and_map()could be moved outside of the if/else clause.
Quoted 9 lines
mal->txeob_irq = irq_of_parse_and_map(ofdev->node, 0);
mal->rxeob_irq = irq_of_parse_and_map(ofdev->node, 1);
mal->serr_irq = irq_of_parse_and_map(ofdev->node, 2);
if (mal_has_feature(mal, MAL_FTR_COMMON_ERR_INT)) {
mal->txde_irq = mal->rxde_irq = mal->serr_irq;
} else {
mal->txde_irq = irq_of_parse_and_map(ofdev->node, 3);
mal->rxde_irq = irq_of_parse_and_map(ofdev->node, 4);
}Indeed they could. Good catch.
Quoted 79 lines
Quoted 49 lines
drivers/net/ibm_newemac/mal.c +27
-15+if (mal->txeob_irq ==NO_IRQ || mal->rxeob_irq ==NO_IRQ || mal->serr_irq ==NO_IRQ || mal->txde_irq ==NO_IRQ || mal->rxde_irq ==NO_IRQ ) {@@ -608,21 +645,42 @@ static int __devinit mal_probe(struct of_device *ofdev,sizeof (struct mal_descriptor ) * mal_rx_bd_offset(mal, i)); - err =request_irq (mal->serr_irq, mal_serr,0 ,"MAL SERR" , mal); -if (err) - goto fail2; - err =request_irq (mal->txde_irq, mal_txde,0 ,"MAL TX DE" , mal); -if (err) - goto fail3; - err =request_irq (mal->txeob_irq, mal_txeob,0 ,"MAL TX EOB" , mal); -if (err) - goto fail4; - err =request_irq (mal->rxde_irq, mal_rxde,0 ,"MAL RX DE" , mal); -if (err) - goto fail5; - err =request_irq (mal->rxeob_irq, mal_rxeob,0 ,"MAL RX EOB" , mal); -if (err) - goto fail6; +if (mal_has_feature (mal,MAL_FTR_COMMON_ERR_INT )) { + err =request_irq (mal->serr_irq, mal_int,IRQF_SHARED , +"MAL SERR" , mal); +if (err) + goto fail2; + err =request_irq (mal->txde_irq, mal_int,IRQF_SHARED , +"MAL TX DE" , mal); +if (err) + goto fail3; + err =request_irq (mal->txeob_irq, mal_txeob,0 ,"MAL TX EOB" , mal); +if (err) + goto fail4; + err =request_irq (mal->rxde_irq, mal_int,IRQF_SHARED , +"MAL RX DE" , mal); +if (err) + goto fail5; + err =request_irq (mal->rxeob_irq, mal_rxeob,0 ,"MAL RX EOB" , mal); +if (err) + goto fail6; + }else { + err =request_irq (mal->serr_irq, mal_serr,0 ,"MAL SERR" , mal); +if (err) + goto fail2; + err =request_irq (mal->txde_irq, mal_txde,0 ,"MAL TX DE" , mal); +if (err) + goto fail3;drivers/net/ibm_newemac/mal.c static int __devinit mal_probe(struct of_device *ofdev, · line 683
Quoted 10 lines
drivers/net/ibm_newemac/mal.c +10
-0+ err =request_irq (mal->txeob_irq, mal_txeob,0 ,"MAL TX EOB" , mal); +if (err) + goto fail4; + err =request_irq (mal->rxde_irq, mal_rxde,0 ,"MAL RX DE" , mal); +if (err) + goto fail5; + err =request_irq (mal->rxeob_irq, mal_rxeob,0 ,"MAL RX EOB" , mal); +if (err) + goto fail6; + }There seems to be a lot of repention in the above if/else clauses. I wonder if something like this might be nicer.
if (mal_has_feature(mal, MAL_FTR_COMMON_ERR_INT)) { irqflags = IRQF_SHARED; hdlr_serr = hdlr_txde = hdlr_rxde = mal_int; } else { irqflags = 0; hdlr_serr = mal_serr; hdlr_txde = mal_txde; hdlr_rxde = mal_rxde; } err = request_irq(mal->serr_irq, hdlr_serr, irqflags, "MAL SERR", mal); if (err) goto fail2; err = request_irq(mal->txde_irq, hdlr_txde, irqflags, "MAL TX DE", mal); if (err) goto fail3; err = request_irq(mal->txeob_irq, mal_txeob, 0, "MAL TX EOB", mal);
Quoted 8 lines
if (err) goto fail4; err = request_irq(mal->rxde_irq, hdlr_rxde, irqflags, "MAL RX DE", mal); if (err) goto fail5; err = request_irq(mal->rxeob_irq, mal_rxeob, 0, "MAL RX EOB", mal); if (err) goto fail6;
I like it. Much cleaner. I'll fix that up too.
josh
Re: [PATCH 3/3] ibm_newemac: MAL support for PowerPC 405EZ
Quoted 8 lines
Quoted 6 lines
drivers/net/ibm_newemac/mal.c static int __devinit mal_probe(struct of_device *ofdev, · line 572
Quoted 3 lines
drivers/net/ibm_newemac/mal.c +2
-0+if (of_device_is_compatible (ofdev->node,"ibm,mcmal-405ez" )) + mal->features |= (MAL_FTR_CLEAR_ICINTSTAT |MAL_FTR_COMMON_ERR_INT );The above like is >80 characters wide.
But I'm not sure that anyone cares.I don't. If Ben complains I'll change it.
I wouldn't do a tatrum over it but if you're going to respin the patch you may as well put the second constant on the next line.
Cheers,
Ben.