diff options
author | Alex Elder <elder@linaro.org> | 2022-09-02 16:02:13 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2022-09-05 12:47:01 +0100 |
commit | b2abe33d23cfaea6cd3f8335a1ee08c480512c6f (patch) | |
tree | f575eb1f75ac9e96e986ab188a729bc6d3df793e /drivers/net/ipa/gsi_private.h | |
parent | 599566c1c369205286b1a22e1b3c2e9dea0e3744 (diff) |
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_private.h')
-rw-r--r-- | drivers/net/ipa/gsi_private.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/net/ipa/gsi_private.h b/drivers/net/ipa/gsi_private.h index 0b2516fa21b5..51bbc7a40dc2 100644 --- a/drivers/net/ipa/gsi_private.h +++ b/drivers/net/ipa/gsi_private.h @@ -17,6 +17,20 @@ struct gsi_channel; #define GSI_RING_ELEMENT_SIZE 16 /* bytes; must be a power of 2 */ /** + * list_last_entry_or_null - get the last element from a list + * @ptr: the list head to take the element from. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_head within the struct. + * + * Note that if the list is empty, it returns NULL. + */ +#define list_last_entry_or_null(ptr, type, member) ({ \ + struct list_head *head__ = (ptr); \ + struct list_head *pos__ = READ_ONCE(head__->prev); \ + pos__ != head__ ? list_entry(pos__, type, member) : NULL; \ +}) + +/** * gsi_trans_move_complete() - Mark a GSI transaction completed * @trans: Transaction to commit */ |