From patchwork Thu Sep 24 08:37:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helmut Grohne X-Patchwork-Id: 260267 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.4 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EDF8C4346E for ; Thu, 24 Sep 2020 08:43:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1628D23600 for ; Thu, 24 Sep 2020 08:43:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=intenta.de header.i=@intenta.de header.b="YrhZ1z3d" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727330AbgIXInE (ORCPT ); Thu, 24 Sep 2020 04:43:04 -0400 Received: from mail.intenta.de ([178.249.25.132]:37150 "EHLO mail.intenta.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726811AbgIXInC (ORCPT ); Thu, 24 Sep 2020 04:43:02 -0400 X-Greylist: delayed 309 seconds by postgrey-1.27 at vger.kernel.org; Thu, 24 Sep 2020 04:43:01 EDT DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=intenta.de; s=dkim1; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:CC:To:From:Date; bh=BXTF18riOp+4eJobrYt1HthX37h7jdYvM9cOfc+Lyds=; b=YrhZ1z3dxs5xJfgHRQ4e2i+IEk0e/IPsG3FaTC42q8lQzRI+pk8w8qwDUgxTc7XGMlugGTdf5uUQpx4jgPwxKuBKQIv3++1ZPUPinigheobtxDj9vHm0J18VcXQCnDxoBL0eh93T2QBozV22ENmoNXarKnvrkSAZOXSZtECC2Zia78EoGw2mIyDh+8t6oR5gjTIxRP42TI1U3geUBuJ0CHY/a8HQEBcOqclvHZyJm93fVGF84H7MZ4+FdWIEpKz3meAdpvko/zznaeIB2S3/tORMzpTbiilbYr3He1G8HJltg0TDo3MM1mnQ9c4JLjZzo7EosiQR80xPb2KN7+k9Cg==; Date: Thu, 24 Sep 2020 10:37:47 +0200 From: Helmut Grohne To: David Miller CC: , , , , , , , , , , , Subject: [PATCH] net: dsa: microchip: really look for phy-mode in port nodes Message-ID: <20200924083746.GA9410@laureti-dev> References: <20200910.123257.1333858679864684014.davem@davemloft.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200910.123257.1333858679864684014.davem@davemloft.net> User-Agent: Mutt/1.10.1 (2018-07-13) X-ClientProxiedBy: ICSMA002.intenta.de (10.10.16.48) To ICSMA002.intenta.de (10.10.16.48) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The previous implementation failed to account for the "ports" node. The actual port nodes are not child nodes of the switch node, but a "ports" node sits in between. Fixes: edecfa98f602 ("net: dsa: microchip: look for phy-mode in port nodes") Signed-off-by: Helmut Grohne --- drivers/net/dsa/microchip/ksz_common.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) I am very sorry that I need to send a fixup. It turned out that my testing methodology was flawed. When I reintegrated Linus' master branch, I noticed that it didn't work. It turned out that our hardware now correctly implements hardware reset. As a consequence, the correct setting of the phy-mode now became essential to operating the device. I'm also looking forward to see "net: dsa: microchip: Improve phy mode message" (from net-next) being merged. That would have helped me spot this earlier. Helmut diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 8e755b50c9c1..c796d42730ba 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -387,8 +387,8 @@ EXPORT_SYMBOL(ksz_switch_alloc); int ksz_switch_register(struct ksz_device *dev, const struct ksz_dev_ops *ops) { + struct device_node *port, *ports; phy_interface_t interface; - struct device_node *port; unsigned int port_num; int ret; @@ -429,13 +429,17 @@ int ksz_switch_register(struct ksz_device *dev, ret = of_get_phy_mode(dev->dev->of_node, &interface); if (ret == 0) dev->compat_interface = interface; - for_each_available_child_of_node(dev->dev->of_node, port) { - if (of_property_read_u32(port, "reg", &port_num)) - continue; - if (port_num >= dev->port_cnt) - return -EINVAL; - of_get_phy_mode(port, &dev->ports[port_num].interface); - } + ports = of_get_child_by_name(dev->dev->of_node, "ports"); + if (ports) + for_each_available_child_of_node(ports, port) { + if (of_property_read_u32(port, "reg", + &port_num)) + continue; + if (port_num >= dev->port_cnt) + return -EINVAL; + of_get_phy_mode(port, + &dev->ports[port_num].interface); + } dev->synclko_125 = of_property_read_bool(dev->dev->of_node, "microchip,synclko-125"); }