Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
klist.h File Reference
#include <linux/spinlock.h>
#include <linux/kref.h>
#include <linux/list.h>

Go to the source code of this file.

Data Structures

struct  klist
 
struct  klist_node
 
struct  klist_iter
 

Macros

#define KLIST_INIT(_name, _get, _put)
 
#define DEFINE_KLIST(_name, _get, _put)   struct klist _name = KLIST_INIT(_name, _get, _put)
 

Functions

struct klist __attribute__ ((aligned(sizeof(void *))))
 
void klist_init (struct klist *k, void(*get)(struct klist_node *), void(*put)(struct klist_node *))
 
void klist_add_tail (struct klist_node *n, struct klist *k)
 
void klist_add_head (struct klist_node *n, struct klist *k)
 
void klist_add_after (struct klist_node *n, struct klist_node *pos)
 
void klist_add_before (struct klist_node *n, struct klist_node *pos)
 
void klist_del (struct klist_node *n)
 
void klist_remove (struct klist_node *n)
 
int klist_node_attached (struct klist_node *n)
 
void klist_iter_init (struct klist *k, struct klist_iter *i)
 
void klist_iter_init_node (struct klist *k, struct klist_iter *i, struct klist_node *n)
 
void klist_iter_exit (struct klist_iter *i)
 
struct klist_nodeklist_next (struct klist_iter *i)
 

Variables

spinlock_t k_lock
 
struct list_head k_list
 
void(* get )(struct klist_node *)
 
void(* put )(struct klist_node *)
 
struct klist_node __attribute__
 

Macro Definition Documentation

#define DEFINE_KLIST (   _name,
  _get,
  _put 
)    struct klist _name = KLIST_INIT(_name, _get, _put)

Definition at line 33 of file klist.h.

#define KLIST_INIT (   _name,
  _get,
  _put 
)
Value:
{ .k_lock = __SPIN_LOCK_UNLOCKED(_name.k_lock), \
.k_list = LIST_HEAD_INIT(_name.k_list), \
.get = _get, \
.put = _put, }

Definition at line 27 of file klist.h.

Function Documentation

void klist_add_after ( struct klist_node n,
struct klist_node pos 
)

klist_add_after - Init a klist_node and add it after an existing node
: node we're adding. : node to put
after

Definition at line 147 of file klist.c.

void klist_add_before ( struct klist_node n,
struct klist_node pos 
)

klist_add_before - Init a klist_node and add it before an existing node
: node we're adding. : node to put
after

Definition at line 163 of file klist.c.

void klist_add_head ( struct klist_node n,
struct klist k 
)

klist_add_head - Initialize a klist_node and add it to front.
: node we're adding. : klist it's going on.

Definition at line 123 of file klist.c.

void klist_add_tail ( struct klist_node n,
struct klist k 
)

klist_add_tail - Initialize a klist_node and add it to back.
: node we're adding. : klist it's going on.

Definition at line 135 of file klist.c.

void klist_del ( struct klist_node n)

klist_del - Decrement the reference count of node and try to remove.
: node we're deleting.

Definition at line 229 of file klist.c.

void klist_init ( struct klist k,
void(*)(struct klist_node *)  get,
void(*)(struct klist_node *)  put 
)

klist_init - Initialize a klist structure. : The klist we're initializing. : The get function for the embedding object (NULL if none) : The put function for the embedding object (NULL if none)

Initialises the klist structure. If the klist_node structures are going to be embedded in refcounted objects (necessary for safe deletion) then the get/put arguments are used to initialise functions that take and release references on the embedding objects.

Definition at line 85 of file klist.c.

void klist_iter_exit ( struct klist_iter i)

klist_iter_exit - Finish a list iteration. : Iterator structure.

Must be called when done iterating over list, as it decrements the refcount of the current node. Necessary in case iteration exited before the end of the list was reached, and always good form.

Definition at line 312 of file klist.c.

void klist_iter_init ( struct klist k,
struct klist_iter i 
)

klist_iter_init - Iniitalize a klist_iter structure. : klist we're iterating. : klist_iter structure we're filling.

Similar to klist_iter_init_node(), but start with the list head.

Definition at line 298 of file klist.c.

void klist_iter_init_node ( struct klist k,
struct klist_iter i,
struct klist_node n 
)

klist_iter_init_node - Initialize a klist_iter structure. : klist we're iterating. : klist_iter we're filling.
: node to start with.

Similar to klist_iter_init(), but starts the action off with
, instead of with the list head.

Definition at line 281 of file klist.c.

struct klist_node* klist_next ( struct klist_iter i)
read

klist_next - Ante up next node in list. : Iterator structure.

First grab list lock. Decrement the reference count of the previous node, if there was one. Grab the next node, increment its reference count, drop the lock, and return that next node.

Definition at line 334 of file klist.c.

int klist_node_attached ( struct klist_node n)

klist_node_attached - Say whether a node is bound to a list or not.
: Node that we're testing.

Definition at line 266 of file klist.c.

void klist_remove ( struct klist_node n)

klist_remove - Decrement the refcount of node and wait for it to go away.
: node we're removing.

Definition at line 239 of file klist.c.

Variable Documentation

static int get
inline

Definition at line 28 of file klist.h.

struct list_head k_list

Definition at line 27 of file klist.h.

spinlock_t k_lock

Definition at line 26 of file klist.h.

void(* put)(struct klist_node *)

Definition at line 29 of file klist.h.