@@ -708,12 +708,13 @@ static int parse_flash_layout(struct stm32prog_data *data,
return 0;
}
-static int __init part_cmp(void *priv, struct list_head *a, struct list_head *b)
+static int __init part_cmp(void *priv, const struct list_head *a,
+ const struct list_head *b)
{
- struct stm32prog_part_t *parta, *partb;
+ const struct stm32prog_part_t *parta, *partb;
- parta = container_of(a, struct stm32prog_part_t, list);
- partb = container_of(b, struct stm32prog_part_t, list);
+ parta = container_of(a, const struct stm32prog_part_t, list);
+ partb = container_of(b, const struct stm32prog_part_t, list);
if (parta->part_id != partb->part_id)
return parta->part_id - partb->part_id;
@@ -114,18 +114,19 @@ static int switch_gc_head(struct ubifs_info *c)
* This function compares data nodes @a and @b. Returns %1 if @a has greater
* inode or block number, and %-1 otherwise.
*/
-static int data_nodes_cmp(void *priv, struct list_head *a, struct list_head *b)
+static int data_nodes_cmp(void *priv, const struct list_head *a,
+ const struct list_head *b)
{
ino_t inuma, inumb;
struct ubifs_info *c = priv;
- struct ubifs_scan_node *sa, *sb;
+ const struct ubifs_scan_node *sa, *sb;
cond_resched();
if (a == b)
return 0;
- sa = list_entry(a, struct ubifs_scan_node, list);
- sb = list_entry(b, struct ubifs_scan_node, list);
+ sa = list_entry(a, const struct ubifs_scan_node, list);
+ sb = list_entry(b, const struct ubifs_scan_node, list);
ubifs_assert(key_type(c, &sa->key) == UBIFS_DATA_KEY);
ubifs_assert(key_type(c, &sb->key) == UBIFS_DATA_KEY);
@@ -157,19 +158,19 @@ static int data_nodes_cmp(void *priv, struct list_head *a, struct list_head *b)
* first and sorted by length in descending order. Directory entry nodes go
* after inode nodes and are sorted in ascending hash valuer order.
*/
-static int nondata_nodes_cmp(void *priv, struct list_head *a,
- struct list_head *b)
+static int nondata_nodes_cmp(void *priv, const struct list_head *a,
+ const struct list_head *b)
{
ino_t inuma, inumb;
struct ubifs_info *c = priv;
- struct ubifs_scan_node *sa, *sb;
+ const struct ubifs_scan_node *sa, *sb;
cond_resched();
if (a == b)
return 0;
- sa = list_entry(a, struct ubifs_scan_node, list);
- sb = list_entry(b, struct ubifs_scan_node, list);
+ sa = list_entry(a, const struct ubifs_scan_node, list);
+ sb = list_entry(b, const struct ubifs_scan_node, list);
ubifs_assert(key_type(c, &sa->key) != UBIFS_DATA_KEY &&
key_type(c, &sb->key) != UBIFS_DATA_KEY);
@@ -268,10 +268,10 @@ static int apply_replay_entry(struct ubifs_info *c, struct replay_entry *r)
* entries @a and @b by comparing their sequence numer. Returns %1 if @a has
* greater sequence number and %-1 otherwise.
*/
-static int replay_entries_cmp(void *priv, struct list_head *a,
- struct list_head *b)
+static int replay_entries_cmp(void *priv, const struct list_head *a,
+ const struct list_head *b)
{
- struct replay_entry *ra, *rb;
+ const struct replay_entry *ra, *rb;
cond_resched();
if (a == b)
@@ -5,7 +5,9 @@
struct list_head;
-void list_sort(void *priv, struct list_head *head,
- int (*cmp)(void *priv, struct list_head *a,
- struct list_head *b));
+typedef int (*list_cmp_func_t)(void *priv, const struct list_head *a,
+ const struct list_head *b);
+
+void list_sort(void *priv, struct list_head *head, list_cmp_func_t cmp);
+
#endif
@@ -116,10 +116,11 @@ static u64 checksum(struct efi_pool_allocation *alloc)
* @b: second memory area
* Return: 1 if @a is before @b, -1 if @b is before @a, 0 if equal
*/
-static int efi_mem_cmp(void *priv, struct list_head *a, struct list_head *b)
+static int efi_mem_cmp(void *priv, const struct list_head *a,
+ const struct list_head *b)
{
- struct mem_node *mema = list_entry(a, struct mem_node, link);
- struct mem_node *memb = list_entry(b, struct mem_node, link);
+ const struct mem_node *mema = list_entry(a, struct mem_node, link);
+ const struct mem_node *memb = list_entry(b, struct mem_node, link);
if (mema->base == memb->base)
return 0;
@@ -21,8 +21,8 @@
* sentinel head node, "prev" links not maintained.
*/
static struct list_head *merge(void *priv,
- int (*cmp)(void *priv, struct list_head *a,
- struct list_head *b),
+ int (*cmp)(void *priv, const struct list_head *a,
+ const struct list_head *b),
struct list_head *a, struct list_head *b)
{
struct list_head head, *tail = &head;
@@ -50,8 +50,8 @@ static struct list_head *merge(void *priv,
* throughout.
*/
static void merge_and_restore_back_links(void *priv,
- int (*cmp)(void *priv, struct list_head *a,
- struct list_head *b),
+ int (*cmp)(void *priv, const struct list_head *a,
+ const struct list_head *b),
struct list_head *head,
struct list_head *a, struct list_head *b)
{
@@ -104,8 +104,8 @@ static void merge_and_restore_back_links(void *priv,
* ordering is to be preserved, @cmp must return 0.
*/
void list_sort(void *priv, struct list_head *head,
- int (*cmp)(void *priv, struct list_head *a,
- struct list_head *b))
+ int (*cmp)(void *priv, const struct list_head *a,
+ const struct list_head *b))
{
struct list_head *part[MAX_LIST_LENGTH_BITS+1]; /* sorted partial lists
-- last slot is a sentinel */