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


Groups > linux.kernel > #1704260 > unrolled thread

[PATCH net-next 1/3] net: dsa: assign switch device in legacy code

Started byVivien Didelot <vivien.didelot@savoirfairelinux.com>
First post2017-08-05 00:30 +0200
Last post2017-08-05 22:20 +0200
Articles 3 — 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 net-next 1/3] net: dsa: assign switch device in legacy code Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-05 00:30 +0200
    Re: [PATCH net-next 1/3] net: dsa: assign switch device in legacy  code Andrew Lunn <andrew@lunn.ch> - 2017-08-05 03:00 +0200
      Re: [PATCH net-next 1/3] net: dsa: assign switch device in legacy code Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-05 22:20 +0200

#1704260 — [PATCH net-next 1/3] net: dsa: assign switch device in legacy code

FromVivien Didelot <vivien.didelot@savoirfairelinux.com>
Date2017-08-05 00:30 +0200
Subject[PATCH net-next 1/3] net: dsa: assign switch device in legacy code
Message-ID<uaTgu-4xE-15@gated-at.bofh.it>
Assign the parent device to the dev member of the newly allocated
dsa_switch structure in the legacy dsa_switch_setup function, so that
the underlying dsa_switch_setup_one and dsa_cpu_dsa_setups functions can
access it instead of requiring an additional struct device argument.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 net/dsa/legacy.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/net/dsa/legacy.c b/net/dsa/legacy.c
index 1d7a3282f2a7..c565787e1c78 100644
--- a/net/dsa/legacy.c
+++ b/net/dsa/legacy.c
@@ -78,7 +78,7 @@ dsa_switch_probe(struct device *parent, struct device *host_dev, int sw_addr,
 }
 
 /* basic switch operations **************************************************/
-static int dsa_cpu_dsa_setups(struct dsa_switch *ds, struct device *dev)
+static int dsa_cpu_dsa_setups(struct dsa_switch *ds)
 {
 	struct dsa_port *dport;
 	int ret, port;
@@ -88,15 +88,15 @@ static int dsa_cpu_dsa_setups(struct dsa_switch *ds, struct device *dev)
 			continue;
 
 		dport = &ds->ports[port];
-		ret = dsa_cpu_dsa_setup(ds, dev, dport, port);
+		ret = dsa_cpu_dsa_setup(ds, ds->dev, dport, port);
 		if (ret)
 			return ret;
 	}
 	return 0;
 }
 
-static int dsa_switch_setup_one(struct dsa_switch *ds, struct net_device *master,
-				struct device *parent)
+static int dsa_switch_setup_one(struct dsa_switch *ds,
+				struct net_device *master)
 {
 	const struct dsa_switch_ops *ops = ds->ops;
 	struct dsa_switch_tree *dst = ds->dst;
@@ -176,7 +176,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct net_device *master
 	}
 
 	if (!ds->slave_mii_bus && ops->phy_read) {
-		ds->slave_mii_bus = devm_mdiobus_alloc(parent);
+		ds->slave_mii_bus = devm_mdiobus_alloc(ds->dev);
 		if (!ds->slave_mii_bus)
 			return -ENOMEM;
 		dsa_slave_mii_bus_init(ds);
@@ -196,14 +196,14 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct net_device *master
 		if (!(ds->enabled_port_mask & (1 << i)))
 			continue;
 
-		ret = dsa_slave_create(ds, parent, i, cd->port_names[i]);
+		ret = dsa_slave_create(ds, ds->dev, i, cd->port_names[i]);
 		if (ret < 0)
 			netdev_err(master, "[%d]: can't create dsa slave device for port %d(%s): %d\n",
 				   index, i, cd->port_names[i], ret);
 	}
 
 	/* Perform configuration of the CPU and DSA ports */
-	ret = dsa_cpu_dsa_setups(ds, parent);
+	ret = dsa_cpu_dsa_setups(ds);
 	if (ret < 0)
 		netdev_err(master, "[%d] : can't configure CPU and DSA ports\n",
 			   index);
@@ -251,8 +251,9 @@ dsa_switch_setup(struct dsa_switch_tree *dst, struct net_device *master,
 	ds->cd = cd;
 	ds->ops = ops;
 	ds->priv = priv;
+	ds->dev = parent;
 
-	ret = dsa_switch_setup_one(ds, master, parent);
+	ret = dsa_switch_setup_one(ds, master);
 	if (ret)
 		return ERR_PTR(ret);
 
-- 
2.13.3

[toc] | [next] | [standalone]


#1704531 — Re: [PATCH net-next 1/3] net: dsa: assign switch device in legacy code

FromAndrew Lunn <andrew@lunn.ch>
Date2017-08-05 03:00 +0200
SubjectRe: [PATCH net-next 1/3] net: dsa: assign switch device in legacy code
Message-ID<uaVBD-5XD-7@gated-at.bofh.it>
In reply to#1704260
> @@ -251,8 +251,9 @@ dsa_switch_setup(struct dsa_switch_tree *dst, struct net_device *master,
>  	ds->cd = cd;
>  	ds->ops = ops;
>  	ds->priv = priv;
> +	ds->dev = parent;

Hi Vivien

Is this even needed? dsa_switch_alloc() does ds->dev = dev.

   Andrew

[toc] | [prev] | [next] | [standalone]


#1704701

FromVivien Didelot <vivien.didelot@savoirfairelinux.com>
Date2017-08-05 22:20 +0200
Message-ID<ubdId-1aY-7@gated-at.bofh.it>
In reply to#1704531
Hi Andrew,

Andrew Lunn <andrew@lunn.ch> writes:

>> @@ -251,8 +251,9 @@ dsa_switch_setup(struct dsa_switch_tree *dst, struct net_device *master,
>>  	ds->cd = cd;
>>  	ds->ops = ops;
>>  	ds->priv = priv;
>> +	ds->dev = parent;
>
> Is this even needed? dsa_switch_alloc() does ds->dev = dev.

You are correct! Respinning.


Thanks,

        Vivien

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web