Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1534322pxj; Sat, 12 Jun 2021 11:25:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyBTHnNfNVhGJRd7buMDC9MyVR9aoyEOVme6qxlnYAJAAytc42ULxwsux+Fsl0TWJYpTIh X-Received: by 2002:a17:906:f6d7:: with SMTP id jo23mr8836152ejb.302.1623522312636; Sat, 12 Jun 2021 11:25:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623522312; cv=none; d=google.com; s=arc-20160816; b=U8eVy0z90cVsLG/dC93tQDRsqAuS+SFyts6Vi4kybqkssUnOXDgWZki2jjd94thzLj dgEnoxDjUxKhMtN7uj2wdNIkBD/0wWcYjvnNAB1/gQaX9lhfi+Npxyt3r15bHP/g5ECK mWDztMs7VsXTeGNV/v5/GAXBcgn/fmGsxxtqZktUlTqOi2I0dXNwoUInTOO5txyYZ+rq prDUJrwnVI9SARBMaqORYGdP3twyvzE4fcpeWgP1SxOcfmW0oKXyjtFbQWmn/WVrk4YM ikXjdM/AbBjovC/b6237NXCwgVajHAVIZcpCUzKI6p8cFwoqs0jebBvWYUklvGN5b7ib BDog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wPWBaV8IYJCZ83hJS663zBYMFbq7zkgEdloZ6L+4ZGc=; b=F5GKXG6sEyjfTDzlbLqHytdmbTEb4l5ST4VpEvyb5Jv75cBvsRaycez3Jhh/0Xt1fq 3+c0pyBisF1luBFvQA+Ewo6H7M+GvES1nr3YBLXVzR4XT82AYGn++NZnZEWXmdxPibRZ gFa/UbyI3s4WN2bI23suOLcmjEbYRXuDeSE/DmB78Qum2yATZiWl4ScKMCMYayqmQL0o DBJJhWX+aT6StRw3Pe1N9wn+fSrzTv5kPxp8xDMOqIUmet6kZwY8/ApJ6yqnPvkwJmbm LSxFZlVnSUPLNcIoWIf5UWDWC5Ux19F0EobqFJGleCwqO4zh9iuagEnKZvW8+5Zbbvwa xMOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=LTbA36Hq; 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 n2si7686216edb.238.2021.06.12.11.24.49; Sat, 12 Jun 2021 11:25: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; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=LTbA36Hq; 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 S230403AbhFLSZ6 (ORCPT + 99 others); Sat, 12 Jun 2021 14:25:58 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:32842 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229753AbhFLSZ6 (ORCPT ); Sat, 12 Jun 2021 14:25:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=wPWBaV8IYJCZ83hJS663zBYMFbq7zkgEdloZ6L+4ZGc=; b=LTbA36Hqp87F1Tio/7Seq0kgBO DIHVmeBJlhJeFl5XASy7rzmBmaiw89KGbwNzQlZUMGGTgCMQdXe6z3KLr7QIPwO0gQHmk/sSd9qWk udz1yFCcg2FWPsBRQj2SSRbsR5QZWUZl0Md24CtiUaSRSz3833hTtLq2SN/bidVuzz4M=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1ls8IT-0091Qp-F0; Sat, 12 Jun 2021 20:23:53 +0200 Date: Sat, 12 Jun 2021 20:23:53 +0200 From: Andrew Lunn To: Oleksij Rempel 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: References: <20210611071527.9333-1-o.rempel@pengutronix.de> <20210611071527.9333-10-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210611071527.9333-10-o.rempel@pengutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +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? Andrew