Subject: Re: [PATCH net-next 2/9] net: dsa: Add support for parsing the old binding

From: Florian Fainelli <[email-masked]>
Date: Sun, 5 Jun 2016 15:42:14 -0700

Le 04/06/2016 13:00, Andrew Lunn a écrit :
>> -static int dsa_cpu_parse(struct device_node *port, u32 index,
>> -			 struct dsa_switch_tree *dst,
>> -			 struct dsa_switch *ds)
>> +static int _dsa_cpu_parse(struct dsa_switch_tree *dst,
>> +			   struct dsa_switch *ds,
>> +			   struct net_device *ethernet_dev,
>> +			   u32 index)
>>  {
>> -	struct net_device *ethernet_dev;
>> -	struct device_node *ethernet;
>> -
>> -	ethernet = of_parse_phandle(port, "ethernet", 0);
>> -	if (!ethernet)
>> -		return -EINVAL;
>> -
>> -	ethernet_dev = of_find_net_device_by_node(ethernet);
>> -	if (!ethernet_dev)
>> -		return -EPROBE_DEFER;
>> -
> 
> Hi Florian
> 
> You have just removed all the actual DT parsing. So i would give this
> a different name, and avoid the _ prefix.
> 
>> +static int _dsa_register_switch_legacy(struct dsa_switch *ds, struct device_node *np)
>> +{
> 
> We might want to call this _dsa_register_switch_legacy_sf2, since the
> code only supports what is needed for your rather odd sf2 binding.

The SF2 binding just encapsulates the normal legacy DSA binding in its
simplified, one switch only configuration, that makes things much
easier, but not way off.

> It does not appear to work for the generic DSA binding.

It would if we also added support for parsing and filing in a routing
table, so yes, that is currently missing.

How about offering dsa_of_parse() (or another name) as a helper function
which fills up a dsa_switch / dsa_switch_tree structure to the best it
can, and then let a driver dealing with the old binding call into the
bottom parts of dsa_register_switch()? That could allow us to remove
some of the duplicated code from net/dsa/dsa.c by doing so

The other approach could be to have custom DT parsing in bcm_sf2.c and
also call the bottom parts of dsa_register_switch() once it has properly
initialized ds/dst.

How much support do we want to have for the old binding for in tree
platforms? Is the plan to migrate them all to the new binding?

-- 
Florian