From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752691AbbDDQmY (ORCPT ); Sat, 4 Apr 2015 12:42:24 -0400 Received: from vps0.lunn.ch ([178.209.37.122]:37233 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752368AbbDDQmW (ORCPT ); Sat, 4 Apr 2015 12:42:22 -0400 Date: Sat, 4 Apr 2015 18:38:14 +0200 From: Andrew Lunn To: Pavel Nakonechny Cc: netdev@vger.kernel.org, "David S. Miller" , Grant Likely , Rob Herring , Florian Fainelli , Fabian Frederick , Alexander Duyck , Joe Perches , linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: dsa: fix filling rtable from OF description Message-ID: <20150404163814.GA19428@lunn.ch> References: <1941340.ZSOIoOXLWB@pavel.skitlab.int> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1941340.ZSOIoOXLWB@pavel.skitlab.int> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Pavel There is the code after applying your patch: static int dsa_of_setup_routing_table(struct dsa_platform_data *pd, struct dsa_chip_data *cd, int chip_index, int port_index, struct device_node *link) { const __be32 *reg; int link_sw_addr; struct device_node *parent_sw; int len; parent_sw = of_get_parent(link); if (!parent_sw) return -EINVAL; link is the phandle to the port in other switch. parent_sw is then the switch property. reg = of_get_property(parent_sw, "reg", &len); if (!reg || (len != sizeof(*reg) * 2)) return -EINVAL; So now you get the reg property. This is documented as: - reg : Describes the switch address on the MII bus link_sw_addr = be32_to_cpup(reg + 1); if (link_sw_addr >= pd->nr_chips) return -EINVAL; This is now not making much sense. Looking up the MII bus address seems wrong. You want the chip number, not its address. Andrew /* First time routing table allocation */ if (!cd->rtable) { cd->rtable = kmalloc_array(pd->nr_chips, sizeof(s8), GFP_KERNEL); if (!cd->rtable) return -ENOMEM; /* default to no valid uplink/downlink */ memset(cd->rtable, -1, pd->nr_chips * sizeof(s8)); } cd->rtable[link_sw_addr] = port_index; return 0; }