mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 05:50:53 +07:00
e311edbc45
Based on 1 normalized pattern(s): this file is rleased under the gpl v2 extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 1 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Alexios Zavras <alexios.zavras@intel.com> Reviewed-by: Enrico Weigelt <info@metux.net> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190602204654.725819457@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
68 lines
1.9 KiB
C
68 lines
1.9 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* klist.h - Some generic list helpers, extending struct list_head a bit.
|
|
*
|
|
* Implementations are found in lib/klist.c
|
|
*
|
|
* Copyright (C) 2005 Patrick Mochel
|
|
*/
|
|
|
|
#ifndef _LINUX_KLIST_H
|
|
#define _LINUX_KLIST_H
|
|
|
|
#include <linux/spinlock.h>
|
|
#include <linux/kref.h>
|
|
#include <linux/list.h>
|
|
|
|
struct klist_node;
|
|
struct klist {
|
|
spinlock_t k_lock;
|
|
struct list_head k_list;
|
|
void (*get)(struct klist_node *);
|
|
void (*put)(struct klist_node *);
|
|
} __attribute__ ((aligned (sizeof(void *))));
|
|
|
|
#define KLIST_INIT(_name, _get, _put) \
|
|
{ .k_lock = __SPIN_LOCK_UNLOCKED(_name.k_lock), \
|
|
.k_list = LIST_HEAD_INIT(_name.k_list), \
|
|
.get = _get, \
|
|
.put = _put, }
|
|
|
|
#define DEFINE_KLIST(_name, _get, _put) \
|
|
struct klist _name = KLIST_INIT(_name, _get, _put)
|
|
|
|
extern void klist_init(struct klist *k, void (*get)(struct klist_node *),
|
|
void (*put)(struct klist_node *));
|
|
|
|
struct klist_node {
|
|
void *n_klist; /* never access directly */
|
|
struct list_head n_node;
|
|
struct kref n_ref;
|
|
};
|
|
|
|
extern void klist_add_tail(struct klist_node *n, struct klist *k);
|
|
extern void klist_add_head(struct klist_node *n, struct klist *k);
|
|
extern void klist_add_behind(struct klist_node *n, struct klist_node *pos);
|
|
extern void klist_add_before(struct klist_node *n, struct klist_node *pos);
|
|
|
|
extern void klist_del(struct klist_node *n);
|
|
extern void klist_remove(struct klist_node *n);
|
|
|
|
extern int klist_node_attached(struct klist_node *n);
|
|
|
|
|
|
struct klist_iter {
|
|
struct klist *i_klist;
|
|
struct klist_node *i_cur;
|
|
};
|
|
|
|
|
|
extern void klist_iter_init(struct klist *k, struct klist_iter *i);
|
|
extern void klist_iter_init_node(struct klist *k, struct klist_iter *i,
|
|
struct klist_node *n);
|
|
extern void klist_iter_exit(struct klist_iter *i);
|
|
extern struct klist_node *klist_prev(struct klist_iter *i);
|
|
extern struct klist_node *klist_next(struct klist_iter *i);
|
|
|
|
#endif
|