diff mbox

[v2,8/8] net/macb: unify peripheral version testing

Message ID 1427806926-18887-9-git-send-email-nicolas.ferre@atmel.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Nicolas Ferre March 31, 2015, 1:02 p.m. UTC
As we need to check peripheral version from the hardware during probe, I
introduce a little helper to unify these tests. It would prevent to
de-synchronize the test like previously observed.

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
---

Changes in v2: None

 drivers/net/ethernet/cadence/macb.c | 7 ++-----
 drivers/net/ethernet/cadence/macb.h | 5 +++++
 2 files changed, 7 insertions(+), 5 deletions(-)

Comments

Punnaiah Choudary Kalluri March 31, 2015, 2:58 p.m. UTC | #1
> -----Original Message-----
> From: Nicolas Ferre [mailto:nicolas.ferre@atmel.com]
> Sent: Tuesday, March 31, 2015 6:32 PM
> To: linux-arm-kernel@lists.infradead.org; netdev@vger.kernel.org; David S.
> Miller
> Cc: linux-kernel@vger.kernel.org; Boris BREZILLON; Cyrille Pitchen; Alexandre
> Belloni; Michal Simek; Punnaiah Choudary Kalluri; Nicolas Ferre
> Subject: [PATCH v2 8/8] net/macb: unify peripheral version testing
> 
> As we need to check peripheral version from the hardware during probe, I
> introduce a little helper to unify these tests. It would prevent to
> de-synchronize the test like previously observed.
> 
> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
    Reviewed-by: Punnaiah Choudary Kalluri <punnaia@xilinx.com>

> ---
> 
> Changes in v2: None
> 
>  drivers/net/ethernet/cadence/macb.c | 7 ++-----
>  drivers/net/ethernet/cadence/macb.h | 5 +++++
>  2 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cadence/macb.c
> b/drivers/net/ethernet/cadence/macb.c
> index 4412895cf4a8..448a32309dd0 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -2139,10 +2139,9 @@ static void macb_configure_caps(struct macb *bp,
> const struct macb_config *dt_co
>  	if (dt_conf)
>  		bp->caps = dt_conf->caps;
> 
> -	if (MACB_BFEXT(IDNUM, macb_readl(bp, MID)) >= 0x2)
> +	if (macb_is_gem_hw(bp->regs)) {
>  		bp->caps |= MACB_CAPS_MACB_IS_GEM;
> 
> -	if (macb_is_gem(bp)) {
>  		dcfg = gem_readl(bp, DCFG1);
>  		if (GEM_BFEXT(IRQCOR, dcfg) == 0)
>  			bp->caps |= MACB_CAPS_ISR_CLEAR_ON_WRITE;
> @@ -2159,7 +2158,6 @@ static void macb_probe_queues(void __iomem
> *mem,
>  			      unsigned int *num_queues)
>  {
>  	unsigned int hw_q;
> -	u32 mid;
> 
>  	*queue_mask = 0x1;
>  	*num_queues = 1;
> @@ -2170,8 +2168,7 @@ static void macb_probe_queues(void __iomem
> *mem,
>  	 * we are early in the probe process and don't have the
>  	 * MACB_CAPS_MACB_IS_GEM flag positioned
>  	 */
> -	mid = readl_relaxed(mem + MACB_MID);
> -	if (MACB_BFEXT(IDNUM, mid) < 0x2)
> +	if (!macb_is_gem_hw(mem))
>  		return;
> 
>  	/* bit 0 is never set but queue 0 always exists */
> diff --git a/drivers/net/ethernet/cadence/macb.h
> b/drivers/net/ethernet/cadence/macb.h
> index fd0a22157a88..eb7d76f7bf6a 100644
> --- a/drivers/net/ethernet/cadence/macb.h
> +++ b/drivers/net/ethernet/cadence/macb.h
> @@ -833,4 +833,9 @@ static inline bool macb_is_gem(struct macb *bp)
>  	return !!(bp->caps & MACB_CAPS_MACB_IS_GEM);
>  }
> 
> +static inline bool macb_is_gem_hw(void __iomem *addr)
> +{
> +	return !!(MACB_BFEXT(IDNUM, readl_relaxed(addr + MACB_MID))
> >= 0x2);
> +}
> +
>  #endif /* _MACB_H */
> --
> 2.1.3

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 4412895cf4a8..448a32309dd0 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -2139,10 +2139,9 @@  static void macb_configure_caps(struct macb *bp, const struct macb_config *dt_co
 	if (dt_conf)
 		bp->caps = dt_conf->caps;
 
-	if (MACB_BFEXT(IDNUM, macb_readl(bp, MID)) >= 0x2)
+	if (macb_is_gem_hw(bp->regs)) {
 		bp->caps |= MACB_CAPS_MACB_IS_GEM;
 
-	if (macb_is_gem(bp)) {
 		dcfg = gem_readl(bp, DCFG1);
 		if (GEM_BFEXT(IRQCOR, dcfg) == 0)
 			bp->caps |= MACB_CAPS_ISR_CLEAR_ON_WRITE;
@@ -2159,7 +2158,6 @@  static void macb_probe_queues(void __iomem *mem,
 			      unsigned int *num_queues)
 {
 	unsigned int hw_q;
-	u32 mid;
 
 	*queue_mask = 0x1;
 	*num_queues = 1;
@@ -2170,8 +2168,7 @@  static void macb_probe_queues(void __iomem *mem,
 	 * we are early in the probe process and don't have the
 	 * MACB_CAPS_MACB_IS_GEM flag positioned
 	 */
-	mid = readl_relaxed(mem + MACB_MID);
-	if (MACB_BFEXT(IDNUM, mid) < 0x2)
+	if (!macb_is_gem_hw(mem))
 		return;
 
 	/* bit 0 is never set but queue 0 always exists */
diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index fd0a22157a88..eb7d76f7bf6a 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -833,4 +833,9 @@  static inline bool macb_is_gem(struct macb *bp)
 	return !!(bp->caps & MACB_CAPS_MACB_IS_GEM);
 }
 
+static inline bool macb_is_gem_hw(void __iomem *addr)
+{
+	return !!(MACB_BFEXT(IDNUM, readl_relaxed(addr + MACB_MID)) >= 0x2);
+}
+
 #endif /* _MACB_H */