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=-6.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS 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 2CA3EC4332E for ; Thu, 19 Mar 2020 17:10:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F1AD52072D for ; Thu, 19 Mar 2020 17:10:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="rMIndAv4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728289AbgCSRKb (ORCPT ); Thu, 19 Mar 2020 13:10:31 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:45678 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727235AbgCSRKb (ORCPT ); Thu, 19 Mar 2020 13:10:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=97QUluO/9z2nRz1LUzTzwjEEpdtKGGADgdrtcJm2fOA=; b=rMIndAv4X0iMvZD54MRmU04cL9 wigGi4hw8VKxK79UiAvPzUG36qw6+8iJqWdy2A4J1EHH/w4iRt2r1IjxGpuXKZdzkVqyLQn1c4PAF FjjmDNkrmn83p2tyiVYaTzWNLYOOPKKOiXvttuCjz4ApHuebPULjbbmMM8A5rUvgbYn4=; Received: from andrew by vps0.lunn.ch with local (Exim 4.93) (envelope-from ) id 1jEygV-000893-QN; Thu, 19 Mar 2020 18:10:19 +0100 Date: Thu, 19 Mar 2020 18:10:19 +0100 From: Andrew Lunn To: Heiner Kallweit Cc: Dejin Zheng , f.fainelli@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, tglx@linutronix.de, broonie@kernel.org, corbet@lwn.net, mchehab+samsung@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next 3/7] net: phy: introduce phy_read_mmd_poll_timeout macro Message-ID: <20200319171019.GJ27807@lunn.ch> References: <20200319163910.14733-1-zhengdejin5@gmail.com> <20200319163910.14733-4-zhengdejin5@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, Mar 19, 2020 at 05:56:39PM +0100, Heiner Kallweit wrote: > On 19.03.2020 17:39, Dejin Zheng wrote: > > it is sometimes necessary to poll a phy register by phy_read_mmd() > > function until its value satisfies some condition. introduce > > phy_read_mmd_poll_timeout() macros that do this. > > > > Signed-off-by: Dejin Zheng > > --- > > include/linux/phy.h | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/include/linux/phy.h b/include/linux/phy.h > > index 36d9dea04016..a30e9008647f 100644 > > --- a/include/linux/phy.h > > +++ b/include/linux/phy.h > > @@ -24,6 +24,7 @@ > > #include > > #include > > #include > > +#include > > > > #include > > > > @@ -784,6 +785,9 @@ static inline int __phy_modify_changed(struct phy_device *phydev, u32 regnum, > > */ > > int phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum); > > > > +#define phy_read_mmd_poll_timeout(val, cond, sleep_us, timeout_us, args...) \ > > + read_poll_timeout(phy_read_mmd, val, cond, sleep_us, timeout_us, args) > > + > > /** > > * __phy_read_mmd - Convenience function for reading a register > > * from an MMD on a given PHY. > > > I'm not fully convinced. Usage of the new macro with its lots of > parameters makes the code quite hard to read. Therefore I'm also > not a big fan of readx_poll_timeout. One issue is that people often implement polling wrong. They don't take into account where extra delays can happen, and return -ETIMEOUT when in fact the operation was successful. readx_poll_timeout gives us a core which is known to be good. What i don't like here is phy_read_mmd_poll_timeout() takes args... We know it should be passed a phydev, and device address and a reg. I would prefer these to be explicit parameters. We can then get the compiler to check the correct number of parameters are passed. Andrew