aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/net/ipa/gsi.c
diff options
context:
space:
mode:
authorAlex Elder <elder@linaro.org>2022-09-02 16:02:13 -0500
committerDavid S. Miller <davem@davemloft.net>2022-09-05 12:47:01 +0100
commitb2abe33d23cfaea6cd3f8335a1ee08c480512c6f (patch)
treef575eb1f75ac9e96e986ab188a729bc6d3df793e /drivers/net/ipa/gsi.c
parentr8169: use devm_clk_get_optional_enabled() to simplify the code (diff)
downloadwireguard-linux-b2abe33d23cfaea6cd3f8335a1ee08c480512c6f.tar.xz
wireguard-linux-b2abe33d23cfaea6cd3f8335a1ee08c480512c6f.zip
net: ipa: rework last transaction determination
When quiescing a channel, we find the "last" transaction, which is the latest one to have been allocated. (New transaction allocation will have been prevented by the time this is called.) Currently we do this by looking for the first non-empty transaction list in each state, then return the last entry from that last. Instead, determine the last entry in each list (if any) and return that entry if found. Temporarily (locally) introduce list_last_entry_or_null() as a helper for this, mirroring list_first_entry_or_null(). This macro definition will be removed by an upcoming patch. Remove the temporary warnings added by the previous commit. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ipa/gsi.c')
-rw-r--r--drivers/net/ipa/gsi.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c
index 9e307eebd33f..0ea98fa5dee5 100644
--- a/drivers/net/ipa/gsi.c
+++ b/drivers/net/ipa/gsi.c
@@ -710,7 +710,6 @@ static void gsi_evt_ring_program(struct gsi *gsi, u32 evt_ring_id)
static struct gsi_trans *gsi_channel_trans_last(struct gsi_channel *channel)
{
struct gsi_trans_info *trans_info = &channel->trans_info;
- const struct list_head *list;
struct gsi_trans *trans;
spin_lock_bh(&trans_info->spinlock);
@@ -719,29 +718,30 @@ static struct gsi_trans *gsi_channel_trans_last(struct gsi_channel *channel)
* before we disabled transmits, so check for that.
*/
if (channel->toward_ipa) {
- list = &trans_info->alloc;
- if (!list_empty(list))
+ trans = list_last_entry_or_null(&trans_info->alloc,
+ struct gsi_trans, links);
+ if (trans)
goto done;
- list = &trans_info->committed;
- if (!list_empty(list))
+ trans = list_last_entry_or_null(&trans_info->committed,
+ struct gsi_trans, links);
+ if (trans)
goto done;
- list = &trans_info->pending;
- if (!list_empty(list))
+ trans = list_last_entry_or_null(&trans_info->pending,
+ struct gsi_trans, links);
+ if (trans)
goto done;
}
/* Otherwise (TX or RX) we want to wait for anything that
* has completed, or has been polled but not released yet.
*/
- list = &trans_info->complete;
- if (!list_empty(list))
+ trans = list_last_entry_or_null(&trans_info->complete,
+ struct gsi_trans, links);
+ if (trans)
goto done;
- list = &trans_info->polled;
- if (list_empty(list))
- list = NULL;
+ trans = list_last_entry_or_null(&trans_info->polled,
+ struct gsi_trans, links);
done:
- trans = list ? list_last_entry(list, struct gsi_trans, links) : NULL;
-
/* Caller will wait for this, so take a reference */
if (trans)
refcount_inc(&trans->refcount);