From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752886AbdJ3SjG (ORCPT ); Mon, 30 Oct 2017 14:39:06 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:52505 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752681AbdJ3SjF (ORCPT ); Mon, 30 Oct 2017 14:39:05 -0400 X-Google-Smtp-Source: ABhQp+RN+NV8x9Yg7LmqcEu7XLwG5gwca/VSIR1EXnm7F2jF7tLXWGIGbI9GJbJtDUQvAg0hHd5dPA== Subject: Re: [PATCH net-next 3/7] net: dsa: get port type at parse time To: Vivien Didelot , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com, "David S. Miller" , Andrew Lunn References: <20171027195519.5931-1-vivien.didelot@savoirfairelinux.com> <20171027195519.5931-4-vivien.didelot@savoirfairelinux.com> From: Florian Fainelli Message-ID: Date: Mon, 30 Oct 2017 11:39:01 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20171027195519.5931-4-vivien.didelot@savoirfairelinux.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Florian Fainelli 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