netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/6] net: dsa: Platform data for dsa2.c
@ 2016-06-28  0:52 Florian Fainelli
  2016-06-28  0:52 ` [PATCH net-next 1/6] net: dsa: Pass device pointer to dsa_register_switch Florian Fainelli
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Florian Fainelli @ 2016-06-28  0:52 UTC (permalink / raw)
  To: netdev; +Cc: davem, andrew, vivien.didelot, Florian Fainelli

Hi all,

This patch series adds support for platform data using the new code from
net/dsa/dsa2.c. The motivation behind this is that we have a bit of in tree
platforms (ar7, bcm47xx, x86, others) that could be benefiting from the new
dsa_register_switch() API model but do not support Device Tree, nor is there a
plan to bring Device Tree to these platforms (time vs. benefits).

The approach taken here is to introduced a new set of platform data structures:
- dsa2_platform_data: per-switch platform data information
- dsa2_port_data: per-port platform data information
- dsa2_port_link: per-port link topology

The platform data is mapped as closely as possible to the Device Tree binding.
Where needed the code is looking either specifically for DT
attributes/properties, or parses the platform data, unlike net/dsa/dsa.c we do
not try to make the DT code allocate and fit within the platform data, but that
could be an option if deemed necessary.

This was tested against a "loopback" driver which is available here, and which
was built as a module and into the kernel, modprobe & rmmod were succesful and
working:

https://github.com/ffainelli/linux/blob/27024f4c9b43cf879348baa5445763c690fbc618/drivers/net/dsa/dsa_loop.c

in two configurations:

- first configuration has 4 switches connected in a cascade [1]
- second configuration is the actual binding example [2]

[1]:
https://github.com/ffainelli/linux/commit/0aa1e98c027e8e41ed2f83825da82a3d8a1c3ae2
[2]:
https://github.com/ffainelli/linux/commit/27024f4c9b43cf879348baa5445763c690fbc618

Florian Fainelli (6):
  net: dsa: Pass device pointer to dsa_register_switch
  net: dsa: Make most functions take a dsa_port argument
  net: dsa: Suffix function manipulating device_node with _dn
  net: dsa: Move ports assignment closer to error checking
  net: dsa: Export dev_to_net_device()
  net: dsa: Add support for platform data

 drivers/net/dsa/b53/b53_common.c  |   2 +-
 drivers/net/dsa/mv88e6xxx/chip.c  |   7 +-
 include/linux/platform_data/dsa.h |  61 +++++++++++
 include/net/dsa.h                 |  10 +-
 net/dsa/Kconfig                   |   1 +
 net/dsa/dsa.c                     |  58 ++++++----
 net/dsa/dsa2.c                    | 216 ++++++++++++++++++++++++++++----------
 net/dsa/dsa_priv.h                |   4 +-
 8 files changed, 273 insertions(+), 86 deletions(-)
 create mode 100644 include/linux/platform_data/dsa.h

-- 
2.7.4

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH net-next 1/6] net: dsa: Pass device pointer to dsa_register_switch
  2016-06-28  0:52 [PATCH net-next 0/6] net: dsa: Platform data for dsa2.c Florian Fainelli
@ 2016-06-28  0:52 ` Florian Fainelli
  2016-06-28  0:52 ` [PATCH net-next 2/6] net: dsa: Make most functions take a dsa_port argument Florian Fainelli
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Florian Fainelli @ 2016-06-28  0:52 UTC (permalink / raw)
  To: netdev; +Cc: davem, andrew, vivien.didelot, Florian Fainelli

In preparation for allowing dsa_register_switch() to be supplied with
device/platform data, pass down a struct device pointer instead of a
struct device_node.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/b53/b53_common.c | 2 +-
 drivers/net/dsa/mv88e6xxx/chip.c | 7 +++----
 include/net/dsa.h                | 2 +-
 net/dsa/dsa2.c                   | 7 ++++---
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 444de66667b9..e5799a68cfc8 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1778,7 +1778,7 @@ int b53_switch_register(struct b53_device *dev)
 
 	pr_info("found switch: %s, rev %i\n", dev->name, dev->core_rev);
 
-	return dsa_register_switch(dev->ds, dev->ds->dev->of_node);
+	return dsa_register_switch(dev->ds, dev->ds->dev);
 }
 EXPORT_SYMBOL(b53_switch_register);
 
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 5cb06f7673af..11617c04cd33 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -3848,8 +3848,7 @@ static struct dsa_switch_driver mv88e6xxx_switch_driver = {
 	.port_fdb_dump          = mv88e6xxx_port_fdb_dump,
 };
 
-static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip,
-				     struct device_node *np)
+static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
 {
 	struct device *dev = chip->dev;
 	struct dsa_switch *ds;
@@ -3864,7 +3863,7 @@ static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip,
 
 	dev_set_drvdata(dev, ds);
 
-	return dsa_register_switch(ds, np);
+	return dsa_register_switch(ds, dev);
 }
 
 static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
@@ -3911,7 +3910,7 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev)
 	if (err)
 		return err;
 
-	err = mv88e6xxx_register_switch(chip, np);
+	err = mv88e6xxx_register_switch(chip);
 	if (err) {
 		mv88e6xxx_mdio_unregister(chip);
 		return err;
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 20b3087ad193..6de162c8283e 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -381,5 +381,5 @@ static inline bool dsa_uses_tagged_protocol(struct dsa_switch_tree *dst)
 }
 
 void dsa_unregister_switch(struct dsa_switch *ds);
-int dsa_register_switch(struct dsa_switch *ds, struct device_node *np);
+int dsa_register_switch(struct dsa_switch *ds, struct device *dev);
 #endif
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 83b95fc4cede..0940a0ec83e6 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -590,8 +590,9 @@ static struct device_node *dsa_get_ports(struct dsa_switch *ds,
 	return ports;
 }
 
-static int _dsa_register_switch(struct dsa_switch *ds, struct device_node *np)
+static int _dsa_register_switch(struct dsa_switch *ds, struct device *dev)
 {
+	struct device_node *np = dev->of_node;
 	struct device_node *ports = dsa_get_ports(ds, np);
 	struct dsa_switch_tree *dst;
 	u32 tree, index;
@@ -660,12 +661,12 @@ out:
 	return err;
 }
 
-int dsa_register_switch(struct dsa_switch *ds, struct device_node *np)
+int dsa_register_switch(struct dsa_switch *ds, struct device *dev)
 {
 	int err;
 
 	mutex_lock(&dsa2_mutex);
-	err = _dsa_register_switch(ds, np);
+	err = _dsa_register_switch(ds, dev);
 	mutex_unlock(&dsa2_mutex);
 
 	return err;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 2/6] net: dsa: Make most functions take a dsa_port argument
  2016-06-28  0:52 [PATCH net-next 0/6] net: dsa: Platform data for dsa2.c Florian Fainelli
  2016-06-28  0:52 ` [PATCH net-next 1/6] net: dsa: Pass device pointer to dsa_register_switch Florian Fainelli
@ 2016-06-28  0:52 ` Florian Fainelli
  2016-06-28  0:52 ` [PATCH net-next 3/6] net: dsa: Suffix function manipulating device_node with _dn Florian Fainelli
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Florian Fainelli @ 2016-06-28  0:52 UTC (permalink / raw)
  To: netdev; +Cc: davem, andrew, vivien.didelot, Florian Fainelli

In preparation for allowing platform data, and therefore no valid
device_node pointer, make most DSA functions takes a pointer to a
dsa_port structure whenever possible. While at it, introduce a
dsa_port_is_valid() helper function which checks whether port->dn is
NULL or not at the moment.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 net/dsa/dsa.c      | 14 +++++++------
 net/dsa/dsa2.c     | 61 +++++++++++++++++++++++++++++-------------------------
 net/dsa/dsa_priv.h |  4 ++--
 3 files changed, 43 insertions(+), 36 deletions(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 766d2a525ada..d117580a78b6 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -208,8 +208,9 @@ __ATTRIBUTE_GROUPS(dsa_hwmon);
 
 /* basic switch operations **************************************************/
 int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct device *dev,
-		      struct device_node *port_dn, int port)
+		      struct dsa_port *dport, int port)
 {
+	struct device_node *port_dn = dport->dn;
 	struct phy_device *phydev;
 	int ret, mode;
 
@@ -237,15 +238,15 @@ int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct device *dev,
 
 static int dsa_cpu_dsa_setups(struct dsa_switch *ds, struct device *dev)
 {
-	struct device_node *port_dn;
+	struct dsa_port *dport;
 	int ret, port;
 
 	for (port = 0; port < DSA_MAX_PORTS; port++) {
 		if (!(dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)))
 			continue;
 
-		port_dn = ds->ports[port].dn;
-		ret = dsa_cpu_dsa_setup(ds, dev, port_dn, port);
+		dport = &ds->ports[port];
+		ret = dsa_cpu_dsa_setup(ds, dev, dport, port);
 		if (ret)
 			return ret;
 	}
@@ -494,8 +495,9 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
 	return ds;
 }
 
-void dsa_cpu_dsa_destroy(struct device_node *port_dn)
+void dsa_cpu_dsa_destroy(struct dsa_port *port)
 {
+	struct device_node *port_dn = port->dn;
 	struct phy_device *phydev;
 
 	if (of_phy_is_fixed_link(port_dn)) {
@@ -531,7 +533,7 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
 	for (port = 0; port < DSA_MAX_PORTS; port++) {
 		if (!(dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)))
 			continue;
-		dsa_cpu_dsa_destroy(ds->ports[port].dn);
+		dsa_cpu_dsa_destroy(&ds->ports[port]);
 
 		/* Clearing a bit which is not set does no harm */
 		ds->cpu_port_mask |= ~(1 << port);
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 0940a0ec83e6..3a782ceef716 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -77,11 +77,16 @@ static void dsa_dst_del_ds(struct dsa_switch_tree *dst,
 	kref_put(&dst->refcount, dsa_free_dst);
 }
 
-static bool dsa_port_is_dsa(struct device_node *port)
+static bool dsa_port_is_valid(struct dsa_port *port)
+{
+	return !!port->dn;
+}
+
+static bool dsa_port_is_dsa(struct dsa_port *port)
 {
 	const char *name;
 
-	name = of_get_property(port, "label", NULL);
+	name = of_get_property(port->dn, "label", NULL);
 	if (!name)
 		return false;
 
@@ -91,11 +96,11 @@ static bool dsa_port_is_dsa(struct device_node *port)
 	return false;
 }
 
-static bool dsa_port_is_cpu(struct device_node *port)
+static bool dsa_port_is_cpu(struct dsa_port *port)
 {
 	const char *name;
 
-	name = of_get_property(port, "label", NULL);
+	name = of_get_property(port->dn, "label", NULL);
 	if (!name)
 		return false;
 
@@ -136,7 +141,7 @@ static struct dsa_switch *dsa_dst_find_port(struct dsa_switch_tree *dst,
 
 static int dsa_port_complete(struct dsa_switch_tree *dst,
 			     struct dsa_switch *src_ds,
-			     struct device_node *port,
+			     struct dsa_port *port,
 			     u32 src_port)
 {
 	struct device_node *link;
@@ -144,7 +149,7 @@ static int dsa_port_complete(struct dsa_switch_tree *dst,
 	struct dsa_switch *dst_ds;
 
 	for (index = 0;; index++) {
-		link = of_parse_phandle(port, "link", index);
+		link = of_parse_phandle(port->dn, "link", index);
 		if (!link)
 			break;
 
@@ -167,13 +172,13 @@ static int dsa_port_complete(struct dsa_switch_tree *dst,
  */
 static int dsa_ds_complete(struct dsa_switch_tree *dst, struct dsa_switch *ds)
 {
-	struct device_node *port;
+	struct dsa_port *port;
 	u32 index;
 	int err;
 
 	for (index = 0; index < DSA_MAX_PORTS; index++) {
-		port = ds->ports[index].dn;
-		if (!port)
+		port = &ds->ports[index];
+		if (!dsa_port_is_valid(port))
 			continue;
 
 		if (!dsa_port_is_dsa(port))
@@ -213,7 +218,7 @@ static int dsa_dst_complete(struct dsa_switch_tree *dst)
 	return 0;
 }
 
-static int dsa_dsa_port_apply(struct device_node *port, u32 index,
+static int dsa_dsa_port_apply(struct dsa_port *port, u32 index,
 			      struct dsa_switch *ds)
 {
 	int err;
@@ -228,13 +233,13 @@ static int dsa_dsa_port_apply(struct device_node *port, u32 index,
 	return 0;
 }
 
-static void dsa_dsa_port_unapply(struct device_node *port, u32 index,
+static void dsa_dsa_port_unapply(struct dsa_port *port, u32 index,
 				 struct dsa_switch *ds)
 {
 	dsa_cpu_dsa_destroy(port);
 }
 
-static int dsa_cpu_port_apply(struct device_node *port, u32 index,
+static int dsa_cpu_port_apply(struct dsa_port *port, u32 index,
 			      struct dsa_switch *ds)
 {
 	int err;
@@ -251,7 +256,7 @@ static int dsa_cpu_port_apply(struct device_node *port, u32 index,
 	return 0;
 }
 
-static void dsa_cpu_port_unapply(struct device_node *port, u32 index,
+static void dsa_cpu_port_unapply(struct dsa_port *port, u32 index,
 				 struct dsa_switch *ds)
 {
 	dsa_cpu_dsa_destroy(port);
@@ -259,13 +264,13 @@ static void dsa_cpu_port_unapply(struct device_node *port, u32 index,
 
 }
 
-static int dsa_user_port_apply(struct device_node *port, u32 index,
+static int dsa_user_port_apply(struct dsa_port *port, u32 index,
 			       struct dsa_switch *ds)
 {
 	const char *name;
 	int err;
 
-	name = of_get_property(port, "label", NULL);
+	name = of_get_property(port->dn, "label", NULL);
 
 	err = dsa_slave_create(ds, ds->dev, index, name);
 	if (err) {
@@ -277,7 +282,7 @@ static int dsa_user_port_apply(struct device_node *port, u32 index,
 	return 0;
 }
 
-static void dsa_user_port_unapply(struct device_node *port, u32 index,
+static void dsa_user_port_unapply(struct dsa_port *port, u32 index,
 				  struct dsa_switch *ds)
 {
 	if (ds->ports[index].netdev) {
@@ -289,7 +294,7 @@ static void dsa_user_port_unapply(struct device_node *port, u32 index,
 
 static int dsa_ds_apply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
 {
-	struct device_node *port;
+	struct dsa_port *port;
 	u32 index;
 	int err;
 
@@ -325,8 +330,8 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
 	}
 
 	for (index = 0; index < DSA_MAX_PORTS; index++) {
-		port = ds->ports[index].dn;
-		if (!port)
+		port = &ds->ports[index];
+		if (!dsa_port_is_valid(port))
 			continue;
 
 		if (dsa_port_is_dsa(port)) {
@@ -353,12 +358,12 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
 
 static void dsa_ds_unapply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
 {
-	struct device_node *port;
+	struct dsa_port *port;
 	u32 index;
 
 	for (index = 0; index < DSA_MAX_PORTS; index++) {
-		port = ds->ports[index].dn;
-		if (!port)
+		port = &ds->ports[index];
+		if (!dsa_port_is_valid(port))
 			continue;
 
 		if (dsa_port_is_dsa(port)) {
@@ -439,14 +444,14 @@ static void dsa_dst_unapply(struct dsa_switch_tree *dst)
 	dst->applied = false;
 }
 
-static int dsa_cpu_parse(struct device_node *port, u32 index,
+static int dsa_cpu_parse(struct dsa_port *port, u32 index,
 			 struct dsa_switch_tree *dst,
 			 struct dsa_switch *ds)
 {
 	struct net_device *ethernet_dev;
 	struct device_node *ethernet;
 
-	ethernet = of_parse_phandle(port, "ethernet", 0);
+	ethernet = of_parse_phandle(port->dn, "ethernet", 0);
 	if (!ethernet)
 		return -EINVAL;
 
@@ -478,13 +483,13 @@ static int dsa_cpu_parse(struct device_node *port, u32 index,
 
 static int dsa_ds_parse(struct dsa_switch_tree *dst, struct dsa_switch *ds)
 {
-	struct device_node *port;
+	struct dsa_port *port;
 	u32 index;
 	int err;
 
 	for (index = 0; index < DSA_MAX_PORTS; index++) {
-		port = ds->ports[index].dn;
-		if (!port)
+		port = &ds->ports[index];
+		if (!dsa_port_is_valid(port))
 			continue;
 
 		if (dsa_port_is_cpu(port)) {
@@ -545,7 +550,7 @@ static int dsa_parse_ports_dn(struct device_node *ports, struct dsa_switch *ds)
 		 * to have access to a correct value, just like what
 		 * net/dsa/dsa.c::dsa_switch_setup_one does.
 		 */
-		if (!dsa_port_is_cpu(port))
+		if (!dsa_port_is_cpu(&ds->ports[reg]))
 			ds->enabled_port_mask |= 1 << reg;
 	}
 
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 00077a9c97f4..3dbc9ce10ab0 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -51,8 +51,8 @@ struct dsa_slave_priv {
 /* dsa.c */
 extern char dsa_driver_version[];
 int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct device *dev,
-		      struct device_node *port_dn, int port);
-void dsa_cpu_dsa_destroy(struct device_node *port_dn);
+		      struct dsa_port *dport, int port);
+void dsa_cpu_dsa_destroy(struct dsa_port *dport);
 const struct dsa_device_ops *dsa_resolve_tag_protocol(int tag_protocol);
 int dsa_cpu_port_ethtool_setup(struct dsa_switch *ds);
 void dsa_cpu_port_ethtool_restore(struct dsa_switch *ds);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 3/6] net: dsa: Suffix function manipulating device_node with _dn
  2016-06-28  0:52 [PATCH net-next 0/6] net: dsa: Platform data for dsa2.c Florian Fainelli
  2016-06-28  0:52 ` [PATCH net-next 1/6] net: dsa: Pass device pointer to dsa_register_switch Florian Fainelli
  2016-06-28  0:52 ` [PATCH net-next 2/6] net: dsa: Make most functions take a dsa_port argument Florian Fainelli
@ 2016-06-28  0:52 ` Florian Fainelli
  2016-06-28  0:52 ` [PATCH net-next 4/6] net: dsa: Move ports assignment closer to error checking Florian Fainelli
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Florian Fainelli @ 2016-06-28  0:52 UTC (permalink / raw)
  To: netdev; +Cc: davem, andrew, vivien.didelot, Florian Fainelli

Make it clear that these functions take a device_node structure pointer

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 net/dsa/dsa2.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 3a782ceef716..bdde5d217326 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -110,8 +110,8 @@ static bool dsa_port_is_cpu(struct dsa_port *port)
 	return false;
 }
 
-static bool dsa_ds_find_port(struct dsa_switch *ds,
-			     struct device_node *port)
+static bool dsa_ds_find_port_dn(struct dsa_switch *ds,
+				struct device_node *port)
 {
 	u32 index;
 
@@ -121,8 +121,8 @@ static bool dsa_ds_find_port(struct dsa_switch *ds,
 	return false;
 }
 
-static struct dsa_switch *dsa_dst_find_port(struct dsa_switch_tree *dst,
-					    struct device_node *port)
+static struct dsa_switch *dsa_dst_find_port_dn(struct dsa_switch_tree *dst,
+					       struct device_node *port)
 {
 	struct dsa_switch *ds;
 	u32 index;
@@ -132,7 +132,7 @@ static struct dsa_switch *dsa_dst_find_port(struct dsa_switch_tree *dst,
 		if (!ds)
 			continue;
 
-		if (dsa_ds_find_port(ds, port))
+		if (dsa_ds_find_port_dn(ds, port))
 			return ds;
 	}
 
@@ -153,7 +153,7 @@ static int dsa_port_complete(struct dsa_switch_tree *dst,
 		if (!link)
 			break;
 
-		dst_ds = dsa_dst_find_port(dst, link);
+		dst_ds = dsa_dst_find_port_dn(dst, link);
 		of_node_put(link);
 
 		if (!dst_ds)
@@ -557,7 +557,7 @@ static int dsa_parse_ports_dn(struct device_node *ports, struct dsa_switch *ds)
 	return 0;
 }
 
-static int dsa_parse_member(struct device_node *np, u32 *tree, u32 *index)
+static int dsa_parse_member_dn(struct device_node *np, u32 *tree, u32 *index)
 {
 	int err;
 
@@ -603,7 +603,7 @@ static int _dsa_register_switch(struct dsa_switch *ds, struct device *dev)
 	u32 tree, index;
 	int err;
 
-	err = dsa_parse_member(np, &tree, &index);
+	err = dsa_parse_member_dn(np, &tree, &index);
 	if (err)
 		return err;
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 4/6] net: dsa: Move ports assignment closer to error checking
  2016-06-28  0:52 [PATCH net-next 0/6] net: dsa: Platform data for dsa2.c Florian Fainelli
                   ` (2 preceding siblings ...)
  2016-06-28  0:52 ` [PATCH net-next 3/6] net: dsa: Suffix function manipulating device_node with _dn Florian Fainelli
@ 2016-06-28  0:52 ` Florian Fainelli
  2016-06-28  0:52 ` [PATCH net-next 5/6] net: dsa: Export dev_to_net_device() Florian Fainelli
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Florian Fainelli @ 2016-06-28  0:52 UTC (permalink / raw)
  To: netdev; +Cc: davem, andrew, vivien.didelot, Florian Fainelli

Move the assignment of ports in _dsa_register_switch() closer to where
it is checked, no functional change. Re-order declarations to be
preserve the inverted christmas tree style.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 net/dsa/dsa2.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index bdde5d217326..a565bd919aa3 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -598,8 +598,8 @@ static struct device_node *dsa_get_ports(struct dsa_switch *ds,
 static int _dsa_register_switch(struct dsa_switch *ds, struct device *dev)
 {
 	struct device_node *np = dev->of_node;
-	struct device_node *ports = dsa_get_ports(ds, np);
 	struct dsa_switch_tree *dst;
+	struct device_node *ports;
 	u32 tree, index;
 	int err;
 
@@ -607,6 +607,7 @@ static int _dsa_register_switch(struct dsa_switch *ds, struct device *dev)
 	if (err)
 		return err;
 
+	ports = dsa_get_ports(ds, np);
 	if (IS_ERR(ports))
 		return PTR_ERR(ports);
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 5/6] net: dsa: Export dev_to_net_device()
  2016-06-28  0:52 [PATCH net-next 0/6] net: dsa: Platform data for dsa2.c Florian Fainelli
                   ` (3 preceding siblings ...)
  2016-06-28  0:52 ` [PATCH net-next 4/6] net: dsa: Move ports assignment closer to error checking Florian Fainelli
@ 2016-06-28  0:52 ` Florian Fainelli
  2016-06-28  0:52 ` [PATCH net-next 6/6] net: dsa: Add support for platform data Florian Fainelli
  2016-06-28  1:05 ` [PATCH net-next 0/6] net: dsa: Platform data for dsa2.c Andrew Lunn
  6 siblings, 0 replies; 13+ messages in thread
From: Florian Fainelli @ 2016-06-28  0:52 UTC (permalink / raw)
  To: netdev; +Cc: davem, andrew, vivien.didelot, Florian Fainelli

We are going to need this in net/dsa/dsa2.c as well, so make it
avaialable.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 include/net/dsa.h | 1 +
 net/dsa/dsa.c     | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 6de162c8283e..48dce1fd100a 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -369,6 +369,7 @@ struct dsa_switch_driver {
 void register_switch_driver(struct dsa_switch_driver *type);
 void unregister_switch_driver(struct dsa_switch_driver *type);
 struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev);
+struct net_device *dev_to_net_device(struct device *dev);
 
 static inline void *ds_to_priv(struct dsa_switch *ds)
 {
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index d117580a78b6..9b5ff9814b5e 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -626,7 +626,7 @@ struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(dsa_host_dev_to_mii_bus);
 
-static struct net_device *dev_to_net_device(struct device *dev)
+struct net_device *dev_to_net_device(struct device *dev)
 {
 	struct device *d;
 
@@ -643,6 +643,7 @@ static struct net_device *dev_to_net_device(struct device *dev)
 
 	return NULL;
 }
+EXPORT_SYMBOL_GPL(dev_to_net_device);
 
 #ifdef CONFIG_OF
 static int dsa_of_setup_routing_table(struct dsa_platform_data *pd,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 6/6] net: dsa: Add support for platform data
  2016-06-28  0:52 [PATCH net-next 0/6] net: dsa: Platform data for dsa2.c Florian Fainelli
                   ` (4 preceding siblings ...)
  2016-06-28  0:52 ` [PATCH net-next 5/6] net: dsa: Export dev_to_net_device() Florian Fainelli
@ 2016-06-28  0:52 ` Florian Fainelli
  2016-06-28  1:05 ` [PATCH net-next 0/6] net: dsa: Platform data for dsa2.c Andrew Lunn
  6 siblings, 0 replies; 13+ messages in thread
From: Florian Fainelli @ 2016-06-28  0:52 UTC (permalink / raw)
  To: netdev; +Cc: davem, andrew, vivien.didelot, Florian Fainelli

Allow drivers to use the new DSA API with platform data. Most of the
code in net/dsa/dsa2.c does not rely so much on device_nodes and can get
the same information from platform_data instead.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 include/linux/platform_data/dsa.h |  61 ++++++++++++++++
 include/net/dsa.h                 |   7 ++
 net/dsa/Kconfig                   |   1 +
 net/dsa/dsa.c                     |  43 +++++++----
 net/dsa/dsa2.c                    | 147 +++++++++++++++++++++++++++++++-------
 5 files changed, 218 insertions(+), 41 deletions(-)
 create mode 100644 include/linux/platform_data/dsa.h

diff --git a/include/linux/platform_data/dsa.h b/include/linux/platform_data/dsa.h
new file mode 100644
index 000000000000..72a91903a88f
--- /dev/null
+++ b/include/linux/platform_data/dsa.h
@@ -0,0 +1,61 @@
+#ifndef __DSA_PDATA_H
+#define __DSA_PDATA_H
+
+#include <linux/kernel.h>
+#include <net/dsa.h>
+#include <linux/phy.h>
+#include <linux/phy_fixed.h>
+
+struct dsa2_port_link {
+	bool		valid;
+	u32		index;
+	unsigned int	port;
+};
+
+struct dsa2_port_data {
+	/*
+	 * Name of the ports, can be unique or a template (e.g: port%d)
+	 */
+	const char *name;
+
+	/*
+	 * PHY interface
+	 */
+	phy_interface_t phy_iface;
+
+	/*
+	 * Fixed PHY status information, if needed by the port (e.g: CPU port)
+	 */
+	struct fixed_phy_status	fixed_phy_status;
+	int link_gpio;
+
+	/*
+	 * Links to other switches in the tree
+	 */
+	struct dsa2_port_link	links[DSA_MAX_SWITCHES];
+};
+
+struct dsa2_platform_data {
+	/*
+	 * Reference to a Linux network interface that connects
+	 * to this switch chip.
+	 */
+	struct device	*netdev;
+
+	/*
+	 * Tree number
+	 */
+	u32 tree;
+
+	/*
+	 * Switch chip index within the tree
+	 */
+	u32 index;
+
+	/*
+	 * Ports layout and description
+	 */
+	struct dsa2_port_data ports[DSA_MAX_PORTS];
+};
+
+#endif /* __DSA_PDATA_H */
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 48dce1fd100a..5e686640fd8e 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -83,6 +83,7 @@ struct dsa_platform_data {
 };
 
 struct packet_type;
+struct dsa2_platform_data;
 
 struct dsa_switch_tree {
 	struct list_head	list;
@@ -101,6 +102,7 @@ struct dsa_switch_tree {
 	 * this dsa switch tree instance.
 	 */
 	struct dsa_platform_data	*pd;
+	struct dsa2_platform_data	*pd2;
 
 	/*
 	 * Reference to network device to use, and which tagging
@@ -136,9 +138,14 @@ struct dsa_switch_tree {
 	const struct dsa_device_ops *tag_ops;
 };
 
+struct dsa2_port_data;
+
 struct dsa_port {
+	const char		*name;
 	struct net_device	*netdev;
+	struct phy_device	*phydev;
 	struct device_node	*dn;
+	struct dsa2_port_data	*data;
 };
 
 struct dsa_switch {
diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig
index ff7736f7ff42..a152bafedce5 100644
--- a/net/dsa/Kconfig
+++ b/net/dsa/Kconfig
@@ -8,6 +8,7 @@ config NET_DSA
 	tristate "Distributed Switch Architecture"
 	depends on HAVE_NET_DSA && NET_SWITCHDEV
 	select PHYLIB
+	select FIXED_PHY
 	---help---
 	  Say Y if you want to enable support for the hardware switches supported
 	  by the Distributed Switch Architecture.
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 9b5ff9814b5e..6a84067a5b18 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -25,6 +25,7 @@
 #include <linux/sysfs.h>
 #include <linux/phy_fixed.h>
 #include <linux/gpio/consumer.h>
+#include <linux/platform_data/dsa.h>
 #include "dsa_priv.h"
 
 char dsa_driver_version[] = "0.1";
@@ -211,10 +212,14 @@ int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct device *dev,
 		      struct dsa_port *dport, int port)
 {
 	struct device_node *port_dn = dport->dn;
+	struct dsa2_port_data *pdata = dport->data;
 	struct phy_device *phydev;
 	int ret, mode;
 
-	if (of_phy_is_fixed_link(port_dn)) {
+	if (!port_dn && !pdata)
+		return 0;
+
+	if (port_dn && of_phy_is_fixed_link(port_dn)) {
 		ret = of_phy_register_fixed_link(port_dn);
 		if (ret) {
 			dev_err(dev, "failed to register fixed PHY\n");
@@ -225,13 +230,25 @@ int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct device *dev,
 		mode = of_get_phy_mode(port_dn);
 		if (mode < 0)
 			mode = PHY_INTERFACE_MODE_NA;
-		phydev->interface = mode;
+	} else if (pdata->fixed_phy_status.speed != 0) {
+		phydev = fixed_phy_register(PHY_POLL, &pdata->fixed_phy_status,
+					    pdata->link_gpio,
+					    NULL);
+		if (IS_ERR(phydev)) {
+			dev_err(dev, "failed to register fixed PHY\n");
+			return PTR_ERR(phydev);
+		}
+		mode = pdata->phy_iface;
+	} else
+		return 0;
 
-		genphy_config_init(phydev);
-		genphy_read_status(phydev);
-		if (ds->drv->adjust_link)
-			ds->drv->adjust_link(ds, port, phydev);
-	}
+	dport->phydev = phydev;
+	phydev->interface = mode;
+
+	genphy_config_init(phydev);
+	genphy_read_status(phydev);
+	if (ds->drv->adjust_link)
+		ds->drv->adjust_link(ds, port, phydev);
 
 	return 0;
 }
@@ -497,15 +514,11 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
 
 void dsa_cpu_dsa_destroy(struct dsa_port *port)
 {
-	struct device_node *port_dn = port->dn;
-	struct phy_device *phydev;
+	struct phy_device *phydev = port->phydev;
 
-	if (of_phy_is_fixed_link(port_dn)) {
-		phydev = of_phy_find_device(port_dn);
-		if (phydev) {
-			phy_device_free(phydev);
-			fixed_phy_unregister(phydev);
-		}
+	if (phydev) {
+		phy_device_free(phydev);
+		fixed_phy_unregister(phydev);
 	}
 }
 
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index a565bd919aa3..2d3c0e2b1e0e 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -18,6 +18,7 @@
 #include <net/dsa.h>
 #include <linux/of.h>
 #include <linux/of_net.h>
+#include <linux/platform_data/dsa.h>
 #include "dsa_priv.h"
 
 static LIST_HEAD(dsa_switch_trees);
@@ -79,14 +80,15 @@ static void dsa_dst_del_ds(struct dsa_switch_tree *dst,
 
 static bool dsa_port_is_valid(struct dsa_port *port)
 {
-	return !!port->dn;
+	return !!(port->dn || port->name);
 }
 
 static bool dsa_port_is_dsa(struct dsa_port *port)
 {
-	const char *name;
+	const char *name = port->name;
 
-	name = of_get_property(port->dn, "label", NULL);
+	if (port->dn)
+		name = of_get_property(port->dn, "label", NULL);
 	if (!name)
 		return false;
 
@@ -98,9 +100,10 @@ static bool dsa_port_is_dsa(struct dsa_port *port)
 
 static bool dsa_port_is_cpu(struct dsa_port *port)
 {
-	const char *name;
+	const char *name = port->name;
 
-	name = of_get_property(port->dn, "label", NULL);
+	if (port->dn)
+		name = of_get_property(port->dn, "label", NULL);
 	if (!name)
 		return false;
 
@@ -139,22 +142,54 @@ static struct dsa_switch *dsa_dst_find_port_dn(struct dsa_switch_tree *dst,
 	return NULL;
 }
 
+static struct dsa_switch *dsa_dst_find_port(struct dsa_switch_tree *dst,
+					    struct dsa2_port_link *link)
+{
+	struct dsa_switch *ds;
+	unsigned int port;
+	u32 index;
+
+	for (index = 0; index < DSA_MAX_SWITCHES; index++) {
+		ds = dst->ds[index];
+		if (!ds)
+			continue;
+
+		if (link->index != index)
+			continue;
+
+		for (port = 0; port < DSA_MAX_PORTS; port++)
+			if (link->port == port)
+				return ds;
+	}
+
+	return NULL;
+}
+
 static int dsa_port_complete(struct dsa_switch_tree *dst,
 			     struct dsa_switch *src_ds,
 			     struct dsa_port *port,
 			     u32 src_port)
 {
 	struct device_node *link;
+	struct dsa2_port_link *plink;
 	int index;
 	struct dsa_switch *dst_ds;
 
 	for (index = 0;; index++) {
-		link = of_parse_phandle(port->dn, "link", index);
-		if (!link)
-			break;
-
-		dst_ds = dsa_dst_find_port_dn(dst, link);
-		of_node_put(link);
+		if (port->dn) {
+			link = of_parse_phandle(port->dn, "link", index);
+			if (!link)
+				break;
+
+			dst_ds = dsa_dst_find_port_dn(dst, link);
+			of_node_put(link);
+		} else {
+			plink = &port->data->links[index];
+			if (!plink->valid)
+				break;
+
+			dst_ds = dsa_dst_find_port(dst, &port->data->links[index]);
+		}
 
 		if (!dst_ds)
 			return 1;
@@ -267,10 +302,11 @@ static void dsa_cpu_port_unapply(struct dsa_port *port, u32 index,
 static int dsa_user_port_apply(struct dsa_port *port, u32 index,
 			       struct dsa_switch *ds)
 {
-	const char *name;
+	const char *name = port->name;
 	int err;
 
-	name = of_get_property(port->dn, "label", NULL);
+	if (port->dn)
+		name = of_get_property(port->dn, "label", NULL);
 
 	err = dsa_slave_create(ds, ds->dev, index, name);
 	if (err) {
@@ -451,11 +487,14 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
 	struct net_device *ethernet_dev;
 	struct device_node *ethernet;
 
-	ethernet = of_parse_phandle(port->dn, "ethernet", 0);
-	if (!ethernet)
-		return -EINVAL;
+	if (port->dn) {
+		ethernet = of_parse_phandle(port->dn, "ethernet", 0);
+		if (!ethernet)
+			return -EINVAL;
+		ethernet_dev = of_find_net_device_by_node(ethernet);
+	} else
+		ethernet_dev = dev_to_net_device(dst->pd2->netdev);
 
-	ethernet_dev = of_find_net_device_by_node(ethernet);
 	if (!ethernet_dev)
 		return -EPROBE_DEFER;
 
@@ -557,6 +596,37 @@ static int dsa_parse_ports_dn(struct device_node *ports, struct dsa_switch *ds)
 	return 0;
 }
 
+static int dsa_parse_ports(struct dsa2_platform_data *pdata, struct dsa_switch *ds)
+{
+	struct dsa2_port_data *port;
+	bool valid_name_found = false;
+	unsigned int i;
+
+	for (i = 0; i < DSA_MAX_PORTS; i++) {
+		port = &pdata->ports[i];
+
+		if (!port->name)
+			continue;
+
+		ds->ports[i].name = port->name;
+		ds->ports[i].data = port;
+
+		/* Initialize enabled_port_mask now for drv->setup()
+		 * to have access to a correct value, just like what
+		 * net/dsa/dsa.c::dsa_switch_setup_one does.
+		 */
+		if (!dsa_port_is_cpu(&ds->ports[i]))
+			ds->enabled_port_mask |= 1 << i;
+
+		valid_name_found= true;
+	}
+
+	if (!valid_name_found && i == DSA_MAX_PORTS)
+		return -EINVAL;
+
+	return 0;
+}
+
 static int dsa_parse_member_dn(struct device_node *np, u32 *tree, u32 *index)
 {
 	int err;
@@ -581,6 +651,19 @@ static int dsa_parse_member_dn(struct device_node *np, u32 *tree, u32 *index)
 	return 0;
 }
 
+static int dsa_parse_member(struct dsa2_platform_data *pd, u32 *tree, u32 *index)
+{
+	*tree = *index = 0;
+
+	if (pd->index >= DSA_MAX_SWITCHES)
+		return -EINVAL;
+
+	*tree = pd->tree;
+	*index = pd->index;
+
+	return 0;
+}
+
 static struct device_node *dsa_get_ports(struct dsa_switch *ds,
 					 struct device_node *np)
 {
@@ -597,23 +680,34 @@ static struct device_node *dsa_get_ports(struct dsa_switch *ds,
 
 static int _dsa_register_switch(struct dsa_switch *ds, struct device *dev)
 {
+	struct dsa2_platform_data *pdata = dev->platform_data;
 	struct device_node *np = dev->of_node;
 	struct dsa_switch_tree *dst;
 	struct device_node *ports;
 	u32 tree, index;
 	int err;
 
-	err = dsa_parse_member_dn(np, &tree, &index);
-	if (err)
-		return err;
+	if (np) {
+		err = dsa_parse_member_dn(np, &tree, &index);
+		if (err)
+			return err;
 
-	ports = dsa_get_ports(ds, np);
-	if (IS_ERR(ports))
-		return PTR_ERR(ports);
+		ports = dsa_get_ports(ds, np);
+		if (IS_ERR(ports))
+			return PTR_ERR(ports);
 
-	err = dsa_parse_ports_dn(ports, ds);
-	if (err)
-		return err;
+		err = dsa_parse_ports_dn(ports, ds);
+		if (err)
+			return err;
+	} else {
+		err = dsa_parse_member(pdata, &tree, &index);
+		if (err)
+			return err;
+
+		err = dsa_parse_ports(pdata, ds);
+		if (err)
+			return err;
+	}
 
 	dst = dsa_get_dst(tree);
 	if (!dst) {
@@ -628,6 +722,7 @@ static int _dsa_register_switch(struct dsa_switch *ds, struct device *dev)
 	}
 
 	ds->dst = dst;
+	dst->pd2 = pdata;
 	ds->index = index;
 	dsa_dst_add_ds(dst, ds, index);
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next 0/6] net: dsa: Platform data for dsa2.c
  2016-06-28  0:52 [PATCH net-next 0/6] net: dsa: Platform data for dsa2.c Florian Fainelli
                   ` (5 preceding siblings ...)
  2016-06-28  0:52 ` [PATCH net-next 6/6] net: dsa: Add support for platform data Florian Fainelli
@ 2016-06-28  1:05 ` Andrew Lunn
  2016-06-28  1:19   ` Florian Fainelli
  6 siblings, 1 reply; 13+ messages in thread
From: Andrew Lunn @ 2016-06-28  1:05 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: netdev, davem, vivien.didelot

On Mon, Jun 27, 2016 at 05:52:37PM -0700, Florian Fainelli wrote:
> Hi all,
> 
> This patch series adds support for platform data using the new code from
> net/dsa/dsa2.c. The motivation behind this is that we have a bit of in tree
> platforms (ar7, bcm47xx, x86, others) that could be benefiting from the new
> dsa_register_switch() API model but do not support Device Tree, nor is there a
> plan to bring Device Tree to these platforms (time vs. benefits).

Hi Florian

Please could you convert an in tree device to actually use this.

       Thanks
	Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next 0/6] net: dsa: Platform data for dsa2.c
  2016-06-28  1:05 ` [PATCH net-next 0/6] net: dsa: Platform data for dsa2.c Andrew Lunn
@ 2016-06-28  1:19   ` Florian Fainelli
  2016-06-28 14:17     ` Andrew Lunn
  2016-06-29 10:12     ` David Miller
  0 siblings, 2 replies; 13+ messages in thread
From: Florian Fainelli @ 2016-06-28  1:19 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: netdev, David Miller, Vivien Didelot

2016-06-27 18:05 GMT-07:00 Andrew Lunn <andrew@lunn.ch>:
> On Mon, Jun 27, 2016 at 05:52:37PM -0700, Florian Fainelli wrote:
>> Hi all,
>>
>> This patch series adds support for platform data using the new code from
>> net/dsa/dsa2.c. The motivation behind this is that we have a bit of in tree
>> platforms (ar7, bcm47xx, x86, others) that could be benefiting from the new
>> dsa_register_switch() API model but do not support Device Tree, nor is there a
>> plan to bring Device Tree to these platforms (time vs. benefits).
>
> Hi Florian
>
> Please could you convert an in tree device to actually use this.

Sure, I don't think there are going to be in tree users who need the
dsa2_port_link information most of what we have is typically single
chip, and so in that case, we can even re-use the existing
dsa_platform_data.
-- 
Florian

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next 0/6] net: dsa: Platform data for dsa2.c
  2016-06-28  1:19   ` Florian Fainelli
@ 2016-06-28 14:17     ` Andrew Lunn
  2016-06-29 10:12     ` David Miller
  1 sibling, 0 replies; 13+ messages in thread
From: Andrew Lunn @ 2016-06-28 14:17 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: netdev, David Miller, Vivien Didelot

On Mon, Jun 27, 2016 at 06:19:28PM -0700, Florian Fainelli wrote:
> 2016-06-27 18:05 GMT-07:00 Andrew Lunn <andrew@lunn.ch>:
> > On Mon, Jun 27, 2016 at 05:52:37PM -0700, Florian Fainelli wrote:
> >> Hi all,
> >>
> >> This patch series adds support for platform data using the new code from
> >> net/dsa/dsa2.c. The motivation behind this is that we have a bit of in tree
> >> platforms (ar7, bcm47xx, x86, others) that could be benefiting from the new
> >> dsa_register_switch() API model but do not support Device Tree, nor is there a
> >> plan to bring Device Tree to these platforms (time vs. benefits).
> >
> > Hi Florian
> >
> > Please could you convert an in tree device to actually use this.
> 
> Sure, I don't think there are going to be in tree users who need the
> dsa2_port_link information most of what we have is typically single
> chip, and so in that case, we can even re-use the existing
> dsa_platform_data.

O.K.

Less is better. When going through the old code for the earlier
re-structuring proposals, the code is not simple at times. I would
prefer not adding more complexity to dsa2 than really is needed.

       Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next 0/6] net: dsa: Platform data for dsa2.c
  2016-06-28  1:19   ` Florian Fainelli
  2016-06-28 14:17     ` Andrew Lunn
@ 2016-06-29 10:12     ` David Miller
  2016-07-04 21:40       ` Florian Fainelli
  1 sibling, 1 reply; 13+ messages in thread
From: David Miller @ 2016-06-29 10:12 UTC (permalink / raw)
  To: f.fainelli; +Cc: andrew, netdev, vivien.didelot

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Mon, 27 Jun 2016 18:19:28 -0700

> 2016-06-27 18:05 GMT-07:00 Andrew Lunn <andrew@lunn.ch>:
>> On Mon, Jun 27, 2016 at 05:52:37PM -0700, Florian Fainelli wrote:
>>> Hi all,
>>>
>>> This patch series adds support for platform data using the new code from
>>> net/dsa/dsa2.c. The motivation behind this is that we have a bit of in tree
>>> platforms (ar7, bcm47xx, x86, others) that could be benefiting from the new
>>> dsa_register_switch() API model but do not support Device Tree, nor is there a
>>> plan to bring Device Tree to these platforms (time vs. benefits).
>>
>> Hi Florian
>>
>> Please could you convert an in tree device to actually use this.
> 
> Sure, I don't think there are going to be in tree users who need the
> dsa2_port_link information most of what we have is typically single
> chip, and so in that case, we can even re-use the existing
> dsa_platform_data.

I assume therefore that this series will be resubmitted with an
accompanying example in-tree conversion.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next 0/6] net: dsa: Platform data for dsa2.c
  2016-06-29 10:12     ` David Miller
@ 2016-07-04 21:40       ` Florian Fainelli
  2016-07-04 22:06         ` David Miller
  0 siblings, 1 reply; 13+ messages in thread
From: Florian Fainelli @ 2016-07-04 21:40 UTC (permalink / raw)
  To: David Miller; +Cc: andrew, netdev, vivien.didelot

Le 29/06/2016 03:12, David Miller a écrit :
> From: Florian Fainelli <f.fainelli@gmail.com>
> Date: Mon, 27 Jun 2016 18:19:28 -0700
> 
>> 2016-06-27 18:05 GMT-07:00 Andrew Lunn <andrew@lunn.ch>:
>>> On Mon, Jun 27, 2016 at 05:52:37PM -0700, Florian Fainelli wrote:
>>>> Hi all,
>>>>
>>>> This patch series adds support for platform data using the new code from
>>>> net/dsa/dsa2.c. The motivation behind this is that we have a bit of in tree
>>>> platforms (ar7, bcm47xx, x86, others) that could be benefiting from the new
>>>> dsa_register_switch() API model but do not support Device Tree, nor is there a
>>>> plan to bring Device Tree to these platforms (time vs. benefits).
>>>
>>> Hi Florian
>>>
>>> Please could you convert an in tree device to actually use this.
>>
>> Sure, I don't think there are going to be in tree users who need the
>> dsa2_port_link information most of what we have is typically single
>> chip, and so in that case, we can even re-use the existing
>> dsa_platform_data.
> 
> I assume therefore that this series will be resubmitted with an
> accompanying example in-tree conversion.
> 

That is correct, although patches 1-4 could be applied immediately as
they are mostly preparatory steps to patches 5-6, I don't mind resending
this at a later time though (probably for the next net-next merge window
I assume).
-- 
Florian

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next 0/6] net: dsa: Platform data for dsa2.c
  2016-07-04 21:40       ` Florian Fainelli
@ 2016-07-04 22:06         ` David Miller
  0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2016-07-04 22:06 UTC (permalink / raw)
  To: f.fainelli; +Cc: andrew, netdev, vivien.didelot

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Mon, 4 Jul 2016 14:40:28 -0700

> That is correct, although patches 1-4 could be applied immediately as
> they are mostly preparatory steps to patches 5-6, I don't mind resending
> this at a later time though (probably for the next net-next merge window
> I assume).

Depends upon how quickly you do the work and resubmit.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-07-04 22:06 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-28  0:52 [PATCH net-next 0/6] net: dsa: Platform data for dsa2.c Florian Fainelli
2016-06-28  0:52 ` [PATCH net-next 1/6] net: dsa: Pass device pointer to dsa_register_switch Florian Fainelli
2016-06-28  0:52 ` [PATCH net-next 2/6] net: dsa: Make most functions take a dsa_port argument Florian Fainelli
2016-06-28  0:52 ` [PATCH net-next 3/6] net: dsa: Suffix function manipulating device_node with _dn Florian Fainelli
2016-06-28  0:52 ` [PATCH net-next 4/6] net: dsa: Move ports assignment closer to error checking Florian Fainelli
2016-06-28  0:52 ` [PATCH net-next 5/6] net: dsa: Export dev_to_net_device() Florian Fainelli
2016-06-28  0:52 ` [PATCH net-next 6/6] net: dsa: Add support for platform data Florian Fainelli
2016-06-28  1:05 ` [PATCH net-next 0/6] net: dsa: Platform data for dsa2.c Andrew Lunn
2016-06-28  1:19   ` Florian Fainelli
2016-06-28 14:17     ` Andrew Lunn
2016-06-29 10:12     ` David Miller
2016-07-04 21:40       ` Florian Fainelli
2016-07-04 22:06         ` David Miller

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).