From: Andrew Lunn <andrew@lunn.ch>
To: Igor Russkikh <Igor.Russkikh@aquantia.com>
Cc: "David S . Miller" <davem@davemloft.net>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Nikita Danilov <Nikita.Danilov@aquantia.com>
Subject: Re: [PATCH net 5/5] net: aquantia: added err var into AQ_HW_WAIT_FOR construct
Date: Tue, 22 Jan 2019 14:34:24 +0100 [thread overview]
Message-ID: <20190122133424.GB3634@lunn.ch> (raw)
In-Reply-To: <e305ce76-215e-8350-4f6c-4e938924e754@aquantia.com>
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
next prev parent reply other threads:[~2019-01-22 13:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-21 14:53 [PATCH net 0/5] net: aquantia: minor bug fixes after static analysis Igor Russkikh
2019-01-21 14:53 ` [PATCH net 1/5] net: aquantia: fixed memcpy size Igor Russkikh
2019-01-21 14:53 ` [PATCH net 2/5] net: aquantia: added newline at end of file Igor Russkikh
2019-01-21 14:53 ` [PATCH net 3/5] net: aquantia: fixed buffer overflow Igor Russkikh
2019-01-21 14:53 ` [PATCH net 4/5] net: aquantia: fixed instack structure overflow Igor Russkikh
2019-01-21 17:10 ` Andrew Lunn
2019-01-21 14:53 ` [PATCH net 5/5] net: aquantia: added err var into AQ_HW_WAIT_FOR construct Igor Russkikh
2019-01-21 17:13 ` Andrew Lunn
2019-01-22 12:44 ` Igor Russkikh
2019-01-22 13:34 ` Andrew Lunn [this message]
2019-01-23 9:49 ` Igor Russkikh
2019-01-23 13:15 ` Andrew Lunn
2019-01-24 14:28 ` Igor Russkikh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190122133424.GB3634@lunn.ch \
--to=andrew@lunn.ch \
--cc=Igor.Russkikh@aquantia.com \
--cc=Nikita.Danilov@aquantia.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).