Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2434222pxj; Sun, 13 Jun 2021 20:58:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUXqGSx/CtDYd/DHsruuPq8H6Oa5y/tR6LL/c8vy6vkpu6fNrhTrbw+VNuQGoWJ0WpK9ky X-Received: by 2002:aa7:d7cf:: with SMTP id e15mr15122974eds.114.1623643092243; Sun, 13 Jun 2021 20:58:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623643092; cv=none; d=google.com; s=arc-20160816; b=MwF/UGTbmqGP82QbqTECuHKrz5RmOt6weEUJNQP27QGzS3gXZRNzk4nTUu2qE4FtrZ RIArB+n8h3JTl5+FCMxCwGo4U4iaEHTJDOoq4sLDsefjdZSNPu3CuBtxO3wzuiLSbv88 S/xas0KGg/5eQ0GfSycnW+GdTUP/fg3f0kDNV2OjqOR0yWLWGbLErwaDtnJzLaDDBfKc EFocqMLIWFv7sCSZnepzXSUe+FE6mJ9KPQRv5qu8Dz7aKMhkDWz4+xDsQ8dq6lxwpDbq vVpI2RuG/RbKQBsdt9ScJ3QVt92IWXeTMsB+xHufjUuHqTrtovWRh1PtIYyXwdooGLHO dlvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=oXTf9mFu5/tlpBzZNrGoOv4lZKYPoxeZWOz6IBQvDUY=; b=dz6tZukPvZdTI127Hc9Z6ThLbBkJrEctHkdgmat/okfa5f14BE7v+vc3J7WC9kiw0O SJntjnDtalZVNXR4HmQbO4EAWdR74ax90qeJOimOma3L2vV9bq5shx4KV/u66nCe9a/9 7vpRsbxr8fy7xBLu34ub4zX/sbisxq2nMS7UZBGMI6ub08doWXcac+eSPF4lk3zg444R 8h6UUMuK/71N4uo/7IYZstzso8CaXR1meetFnso8JBeyneYKk3xqfIgfK0Y225YEH3nI oz2t22xBCHtvS/78rUq8TCLVmVV9WqpKSNLrvlytuADuvVxZQlHpKcJL7QJ/zt91ydni XlQA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e3si10327305ejm.412.2021.06.13.20.57.37; Sun, 13 Jun 2021 20:58:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232319AbhFNDx7 (ORCPT + 99 others); Sun, 13 Jun 2021 23:53:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232251AbhFNDx7 (ORCPT ); Sun, 13 Jun 2021 23:53:59 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FC59C061766 for ; Sun, 13 Jun 2021 20:51:57 -0700 (PDT) Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lsddd-0006mA-89; Mon, 14 Jun 2021 05:51:49 +0200 Received: from ore by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1lsddc-0006qM-6G; Mon, 14 Jun 2021 05:51:48 +0200 Date: Mon, 14 Jun 2021 05:51:48 +0200 From: Oleksij Rempel To: Andrew Lunn Cc: Woojung Huh , UNGLinuxDriver@microchip.com, Florian Fainelli , Vivien Didelot , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , kernel@pengutronix.de, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Russell King , Michael Grzeschik Subject: Re: [PATCH net-next v4 9/9] net: phy: micrel: ksz886x/ksz8081: add cabletest support Message-ID: <20210614035148.w742cyk52m3w56zh@pengutronix.de> References: <20210611071527.9333-1-o.rempel@pengutronix.de> <20210611071527.9333-10-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 05:51:09 up 193 days, 17:57, 48 users, load average: 0.09, 0.06, 0.01 User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jun 12, 2021 at 08:23:53PM +0200, Andrew Lunn wrote: > > +static int ksz886x_cable_test_get_status(struct phy_device *phydev, > > + bool *finished) > > +{ > > + unsigned long pair_mask = 0x3; > > + int retries = 20; > > + int pair, ret; > > + > > + *finished = false; > > + > > + /* Try harder if link partner is active */ > > + while (pair_mask && retries--) { > > + for_each_set_bit(pair, &pair_mask, 4) { > > + ret = ksz886x_cable_test_one_pair(phydev, pair); > > + if (ret == -EAGAIN) > > + continue; > > + if (ret < 0) > > + return ret; > > + clear_bit(pair, &pair_mask); > > + } > > + /* If link partner is in autonegotiation mode it will send 2ms > > + * of FLPs with at least 6ms of silence. > > + * Add 2ms sleep to have better chances to hit this silence. > > + */ > > + if (pair_mask) > > + msleep(2); > > + } > > + > > + *finished = true; > > + > > + return 0; > > If ksz886x_cable_test_one_pair() returns -EAGAIN 20x and it gives up, > you end up returning 0. Maybe it would be better to return ret? Good point. Fixed. Regards, Oleksij -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |