Re: [PATCH net-next 3/7] net: dsa: get port type at parse time

From: Florian Fainelli
Date: Mon Oct 30 2017 - 14:39:12 EST


On 10/27/2017 12:55 PM, Vivien Didelot wrote:
> Assign a port's type at parsed time instead of waiting for the tree to
> be completed.
>
> Because this is now done earlier, we can use the port's type in
> dsa_port_is_* helpers instead of digging again in topology description.
>
> Signed-off-by: Vivien Didelot <vivien.didelot@xxxxxxxxxxxxxxxxxxxx>

Reviewed-by: Florian Fainelli <f.fainelli@xxxxxxxxx>

One nit below:


> static int dsa_port_parse_of(struct dsa_port *dp, struct device_node *dn)
> {
> + struct device_node *ethernet = of_parse_phandle(dn, "ethernet", 0);
> + struct device_node *link = of_parse_phandle(dn, "link", 0);
> +
> + if (ethernet) {
> + dp->type = DSA_PORT_TYPE_CPU;
> + } else if (link) {
> + dp->type = DSA_PORT_TYPE_DSA;
> + } else {
> + dp->type = DSA_PORT_TYPE_USER;
> + }
> +

The curly braces are probably not necessary since all of these are
single line statements.

> dp->dn = dn;
>
> return 0;
> @@ -630,6 +629,14 @@ static int dsa_parse_ports_of(struct device_node *dn, struct dsa_switch *ds)
> static int dsa_port_parse(struct dsa_port *dp, const char *name,
> struct device *dev)
> {
> + if (!strcmp(name, "cpu")) {
> + dp->type = DSA_PORT_TYPE_CPU;
> + } else if (!strcmp(name, "dsa")) {
> + dp->type = DSA_PORT_TYPE_DSA;
> + } else {
> + dp->type = DSA_PORT_TYPE_USER;
> + }

Likewise.
--
Florian