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: Wed, 23 Jan 2019 14:15:02 +0100 [thread overview]
Message-ID: <20190123131502.GA26413@lunn.ch> (raw)
In-Reply-To: <1bac2c2c-2c60-5043-3b74-0b20138a72c1@aquantia.com>
On Wed, Jan 23, 2019 at 09:49:25AM +0000, Igor Russkikh wrote:
>
> >
> > 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.
>
> Hi Andrew, agreed, but driver have more incompatible places with constructs like
>
> AQ_HW_WAIT_FOR(orig_stats_val !=
> (aq_hw_read_reg(self, HW_ATL_FW2X_MPI_STATE2_ADDR) &
> BIT(CAPS_HI_STATISTICS)),
> 1U, 10000U);
You can define a little helper:
static u32 aq_hw_read_mpi_state2_addr(struct aq_hw_s *self)
{
return aq_hw_read_reg(self, HW_ATL_FW2X_MPI_STATE2_ADDR);
}
Then
readx_poll_timeout(u32 aq_hw_read_mpi_state2_addr, self,
stats_val, orig_stats_val != stats_val & BIT(CAPS_HI_STATISTICS));
Given you have the comment:
/* Wait FW to report back */
You think the current code is not very readable. So you could actually
have:
static int sq_fw2_update_stats_fw_wait(aq_hw_s *self, u32 orig_stats_val)
{
u32 stats_val;
return readx_poll_timeout(u32 aq_hw_read_mpi_state2_addr, self,
stats_val,
orig_stats_val != stats_val & BIT(CAPS_HI_STATISTICS),
1, 1000);
}
You see this sort of construct in quite a lot of drivers.
> Found duplicating readl_poll_timeout declaration here:
> https://elixir.bootlin.com/linux/latest/source/drivers/phy/qualcomm/phy-qcom-ufs-i.h#L27
> Not sure what's the reason, but may worth cleaning it up.
Thanks.
Andrew
next prev parent reply other threads:[~2019-01-23 13:15 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
2019-01-23 9:49 ` Igor Russkikh
2019-01-23 13:15 ` Andrew Lunn [this message]
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=20190123131502.GA26413@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.