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=-2.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, USER_AGENT_MUTT 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 5D690C282C3 for ; Tue, 22 Jan 2019 13:34:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 20FAF20870 for ; Tue, 22 Jan 2019 13:34:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="Gztuq/W8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728550AbfAVNe2 (ORCPT ); Tue, 22 Jan 2019 08:34:28 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:51570 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728523AbfAVNe1 (ORCPT ); Tue, 22 Jan 2019 08:34:27 -0500 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; bh=1QAlkNdBLrVny7JfoXVkIRGWaEu42D8v/JFPTG5jGFs=; b=Gztuq/W8EJrTdawLgiPawWkgWfJgfo7RquDBFazZ3qwf6gy4poUkLzTgTgNKWGh6f+ydbvX/wdfzJTbaYx+iNbf8IQxbi1JUtT/GY424DSCmoPaaYLaL03yv2LcOQ6nSvcqSvJNruOi943Li7W2ftoe1MlfkzcAPdLtks7flcn8=; Received: from andrew by vps0.lunn.ch with local (Exim 4.84_2) (envelope-from ) id 1glwC8-0001OI-Bn; Tue, 22 Jan 2019 14:34:24 +0100 Date: Tue, 22 Jan 2019 14:34:24 +0100 From: Andrew Lunn To: Igor Russkikh Cc: "David S . Miller" , "netdev@vger.kernel.org" , Nikita Danilov Subject: Re: [PATCH net 5/5] net: aquantia: added err var into AQ_HW_WAIT_FOR construct Message-ID: <20190122133424.GB3634@lunn.ch> References: <8bae843a7f567eb7187cf7b84372d96e4914b3e7.1547878835.git.igor.russkikh@aquantia.com> <20190121171323.GK8620@lunn.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Tue, Jan 22, 2019 at 12:44:07PM +0000, Igor Russkikh wrote: > > >> -#define AQ_HW_WAIT_FOR(_B_, _US_, _N_) \ > >> +#define AQ_HW_WAIT_FOR(_B_, _US_, _N_, _err_) \ > >> do { \ > >> unsigned int AQ_HW_WAIT_FOR_i; \ > >> for (AQ_HW_WAIT_FOR_i = _N_; (!(_B_)) && (AQ_HW_WAIT_FOR_i);\ > >> @@ -31,7 +31,7 @@ do { \ > >> udelay(_US_); \ > >> } \ > >> if (!AQ_HW_WAIT_FOR_i) {\ > >> - err = -ETIME; \ > >> + *(_err_) = -ETIME; \ > >> } \ > >> } while (0) > > > > Hi Igor > > > > How about throwing this horrible macro away and using one of the > > readx_poll_timeout() variants. > > Hi Andrew, > > Thanks I was not aware of that macro. > > The original macro actually differs a bit in a sense that it does not require > a 'value' local variable to be used. Also aq driver used a number of wrapper > functions to hide the actual readl and mmio access. > > Thus its hard to adopt readx_poll_timeout() in its current form. > > WAIT_FOR is normally used like > > AQ_HW_WAIT_FOR(hw_atl_itr_res_irq_get(self) == 0, 1000U, 10U, &err); Hi Igor err = readx_poll_timeout(hw_atl_itr_res_irq_get, self, alt_itr_res, alt_itr_res == 0, 10, 1000); The advantage of using readx_poll_timeout is that it is used by lots of other drivers and works. It is much better to use core infrastructure, then build your own. Andrew