From mboxrd@z Thu Jan 1 00:00:00 1970 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=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable 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 B6258C4338F for ; Mon, 16 Aug 2021 18:09:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 99CBD60F22 for ; Mon, 16 Aug 2021 18:09:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232207AbhHPSJt (ORCPT ); Mon, 16 Aug 2021 14:09:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230008AbhHPSJp (ORCPT ); Mon, 16 Aug 2021 14:09:45 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4301EC0613CF for ; Mon, 16 Aug 2021 11:09:13 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id v2so17371480edq.10 for ; Mon, 16 Aug 2021 11:09:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mind.be; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=O3ErUZ22t3/2NnJvS4t3GxIKREc/lpK4t3GrCBcKr0s=; b=MqIR+wT3TQ7AperC/QwCBgWjfTLvLSef5OV3AlZZPKb99x1zp9VkDperrxeByexvZo 6btdJ3JlSZoWgdIJZtALiWD/7fEXImETrT+PY1kmGFHHGIUUBzmrWfJj7JbwjWQkwhy/ tw1ufFGwyjPpT3FZNhYPIP/bpOJTFHrV5HjvtrH9CII5KLn37RhUYIHH3hh5AmSBE6Tm F8yakd5pZDW8Q9UA7HGQtOWOG9bU8Db8/Pfmg4tUFoPhEghY+QeG92EOSzMPd6hCWA1M KmYRWIK3TH0S8Qb2Kv2dv+hHupAPnw/bCJrSGrbsCHOjV2xfd7iBRdJwU+BxWiytldxr m9BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=O3ErUZ22t3/2NnJvS4t3GxIKREc/lpK4t3GrCBcKr0s=; b=kdS0lk6BZra68YvjeYw1lxWNBtGL9x/Vxg50i+yg+sDJ8oEixLX65lQBsjemDi21HB /WCMh+KecMXc4/zda5ISDYs/8lgGBZtQ3cj0v6v297Q2oJ24DAH5ufCwcGt2g9X89FDj TXS9Pjht5xqI+MdZKTS79x7ZZAr434wpN7+9Gq4GZ/Wwb6CUPK5y3rzGTbFwTYgyaOlH MODYQ8kwFkgMTjZ3u7cgEsoBa8Z86fjesSdhf3DiMXnC/Tlgt4DPA8X/o/18lGLH+yLu I4ATR16/6rmAuK8pFAhQ6XzpEaa0FRpTeo3lQ46fB0EqIB7blMY+W9/iArrbFLT8Ec+D BVaA== X-Gm-Message-State: AOAM530GJF2sVyWgu2XhGHSZ6skZ8Jun5FJUEuoiaHXJutCjCgb1BNwp ofAuDLmlC8ix6Jd5sHiGgjaD8Q== X-Google-Smtp-Source: ABdhPJxr/NOJQwEcR8v0SouCivf0RaGELa2786Pp80kXXkfyso/2qhYytT5Bic1pg8IR4u20WhzRTQ== X-Received: by 2002:aa7:cad9:: with SMTP id l25mr22395060edt.351.1629137351869; Mon, 16 Aug 2021 11:09:11 -0700 (PDT) Received: from cephalopod (168.7-181-91.adsl-dyn.isp.belgacom.be. [91.181.7.168]) by smtp.gmail.com with ESMTPSA id fl2sm3916189ejc.114.2021.08.16.11.09.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Aug 2021 11:09:11 -0700 (PDT) Date: Mon, 16 Aug 2021 20:09:09 +0200 From: Ben Hutchings To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, "David S. Miller" , Sasha Levin , Woojung Huh , Microchip Linux Driver Support , Michael Grzeschik , Marek Vasut Subject: [PATCH 5.10 1/5] net: dsa: microchip: Fix probing KSZ87xx switch with DT node for host port Message-ID: <20210816180909.GE18930@cephalopod> References: <20210816174905.GD18930@cephalopod> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210816174905.GD18930@cephalopod> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ksz8795 and ksz9477 drivers differ in the way they count ports. For ksz8795, ksz_device::port_cnt does not include the host port whereas for ksz9477 it does. This inconsistency was fixed in Linux 5.11 by a series of changes, but remains in 5.10-stable. When probing, the common code treats a port device node with an address >= dev->port_cnt as a fatal error. As a minimal fix, change it to compare again dev->mib_port_cnt. This is the length of the dev->ports array that the port number will be used to index, and always includes the host port. Cc: Woojung Huh Cc: Microchip Linux Driver Support Cc: Michael Grzeschik Cc: Marek Vasut Signed-off-by: Ben Hutchings --- drivers/net/dsa/microchip/ksz_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index d4a64dbde315..88fa0779e0bc 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -432,7 +432,7 @@ int ksz_switch_register(struct ksz_device *dev, if (of_property_read_u32(port, "reg", &port_num)) continue; - if (port_num >= dev->port_cnt) + if (port_num >= dev->mib_port_cnt) return -EINVAL; of_get_phy_mode(port, &dev->ports[port_num].interface); -- 2.20.1