Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1425574 > unrolled thread

[PATCH v3 net-next v3 10/14] net: dsa: mv88e6xxx: add SMI init helper

Started byVivien Didelot <vivien.didelot@savoirfairelinux.com>
First post2016-06-18 02:20 +0200
Last post2016-06-18 22:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v3 net-next v3 10/14] net: dsa: mv88e6xxx: add SMI init helper Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-06-18 02:20 +0200
    Re: [PATCH v3 net-next v3 10/14] net: dsa: mv88e6xxx: add SMI init  helper Andrew Lunn <andrew@lunn.ch> - 2016-06-18 22:30 +0200

#1425574 — [PATCH v3 net-next v3 10/14] net: dsa: mv88e6xxx: add SMI init helper

FromVivien Didelot <vivien.didelot@savoirfairelinux.com>
Date2016-06-18 02:20 +0200
Subject[PATCH v3 net-next v3 10/14] net: dsa: mv88e6xxx: add SMI init helper
Message-ID<rLc9s-57u-25@gated-at.bofh.it>
Add an helper function to isolate SMI specific assignations and checks.

This function will later help choosing the different SMI accesses based
of the compatible info.

Since the chip structure is already allocated in the legacy probe, use
the mv88e6xxx_reg_read access routine instead of __mv88e6xxx_reg_read.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 drivers/net/dsa/mv88e6xxx.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 113092a..4e24ac5 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -3616,6 +3616,19 @@ static struct mv88e6xxx_priv_state *mv88e6xxx_alloc_chip(struct device *dev)
 	return ps;
 }
 
+static int mv88e6xxx_smi_init(struct mv88e6xxx_priv_state *ps,
+			      struct mii_bus *bus, int sw_addr)
+{
+	/* ADDR[0] pin is unavailable externally and considered zero */
+	if (sw_addr & 0x1)
+		return -EINVAL;
+
+	ps->bus = bus;
+	ps->sw_addr = sw_addr;
+
+	return 0;
+}
+
 static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
 				       struct device *host_dev, int sw_addr,
 				       void **priv)
@@ -3635,7 +3648,11 @@ static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
 	if (!ps)
 		return NULL;
 
-	id = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), PORT_SWITCH_ID);
+	err = mv88e6xxx_smi_init(ps, bus, sw_addr);
+	if (err)
+		goto free;
+
+	id = mv88e6xxx_reg_read(ps, REG_PORT(0), PORT_SWITCH_ID);
 	if (id < 0)
 		goto free;
 
@@ -3648,8 +3665,6 @@ static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
 
 	name = info->name;
 
-	ps->bus = bus;
-	ps->sw_addr = sw_addr;
 	ps->info = info;
 
 	err = mv88e6xxx_mdio_register(ps, NULL);
@@ -3741,8 +3756,9 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev)
 	if (!ps)
 		return -ENOMEM;
 
-	ps->bus = mdiodev->bus;
-	ps->sw_addr = mdiodev->addr;
+	err = mv88e6xxx_smi_init(ps, mdiodev->bus, mdiodev->addr);
+	if (err)
+		return err;
 
 	id = mv88e6xxx_reg_read(ps, REG_PORT(0), PORT_SWITCH_ID);
 	if (id < 0)
-- 
2.8.3

[toc] | [next] | [standalone]


#1425835 — Re: [PATCH v3 net-next v3 10/14] net: dsa: mv88e6xxx: add SMI init helper

FromAndrew Lunn <andrew@lunn.ch>
Date2016-06-18 22:30 +0200
SubjectRe: [PATCH v3 net-next v3 10/14] net: dsa: mv88e6xxx: add SMI init helper
Message-ID<rLv2p-uj-1@gated-at.bofh.it>
In reply to#1425574
On Fri, Jun 17, 2016 at 08:07:32PM -0400, Vivien Didelot wrote:
> Add an helper function to isolate SMI specific assignations and checks.

I don't think you meant assignations. Assignments?

Otherwise

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web