qcacmn: Add APIs to split/join lists
Add following APIs. 1. Split a list into 2 lists 2. Join two lists Change-Id: I9eb5cdfeeef582ef0bebe108f08fac307494b59d CRs-Fixed: 3071041
Bu işleme şunda yer alıyor:

işlemeyi yapan:
Madan Koyyalamudi

ebeveyn
0a6cc5a1a0
işleme
915648336f
@@ -188,4 +188,31 @@ bool qdf_list_has_node(qdf_list_t *list, qdf_list_node_t *node);
|
||||
*/
|
||||
bool qdf_list_node_in_any_list(const qdf_list_node_t *node);
|
||||
|
||||
/**
|
||||
* qdf_list_join - Join two lists and reinitialize the emptied list
|
||||
* @list1: Pointer to list 1
|
||||
* @list2: Pointer to list 2
|
||||
*
|
||||
* This API joins list1 and list2 and writes the resultant list (list1 + list2)
|
||||
* to list1. list2 is re initialized to an empty list.
|
||||
*
|
||||
* Return: QDF_STATUS of operation
|
||||
*/
|
||||
QDF_STATUS qdf_list_join(qdf_list_t *list1, qdf_list_t *list2);
|
||||
|
||||
/**
|
||||
* qdf_list_split - Split a list into two chunks
|
||||
* @new: Pointer to the list to store one of the chunks after splitting.
|
||||
* This list will be overwritten by the API and hence it should be
|
||||
* an empty list to avoid data loss.
|
||||
* @list: Pointer to the list to be split
|
||||
* @node: Pointer to a node within the @list. If @node is not present in
|
||||
* the @list, behaviour is undefined.
|
||||
*
|
||||
* This API splits @list after @node. The initial portion of the @list
|
||||
* up to and including @node will be moved to @new. The remaining portion will
|
||||
* be assigned to @list.
|
||||
*/
|
||||
QDF_STATUS qdf_list_split(qdf_list_t *new, qdf_list_t *list,
|
||||
qdf_list_node_t *node);
|
||||
#endif /* __QDF_LIST_H */
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014-2018 The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2014-2018, 2021 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for
|
||||
* any purpose with or without fee is hereby granted, provided that the
|
||||
@@ -262,3 +262,33 @@ bool qdf_list_node_in_any_list(const qdf_list_node_t *node)
|
||||
return true;
|
||||
}
|
||||
|
||||
QDF_STATUS qdf_list_split(qdf_list_t *new, qdf_list_t *list,
|
||||
qdf_list_node_t *node)
|
||||
{
|
||||
qdf_list_node_t *cur_node;
|
||||
uint32_t new_list_count = 0;
|
||||
|
||||
list_cut_position(&new->anchor, &list->anchor, node);
|
||||
|
||||
list_for_each(cur_node, &new->anchor)
|
||||
new_list_count++;
|
||||
|
||||
new->count = new_list_count;
|
||||
list->count = list->count - new->count;
|
||||
|
||||
return QDF_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
qdf_export_symbol(qdf_list_split);
|
||||
|
||||
QDF_STATUS qdf_list_join(qdf_list_t *list1, qdf_list_t *list2)
|
||||
{
|
||||
list_splice_tail_init(&list2->anchor, &list1->anchor);
|
||||
|
||||
list1->count = list1->count + list2->count;
|
||||
list2->count = 0;
|
||||
|
||||
return QDF_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
qdf_export_symbol(qdf_list_join);
|
||||
|
Yeni konuda referans
Bir kullanıcı engelle