Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
devres.c File Reference
#include <linux/device.h>
#include <linux/module.h>
#include <linux/slab.h>
#include "base.h"

Go to the source code of this file.

Data Structures

struct  devres_node
 
struct  devres
 
struct  devres_group
 

Macros

#define set_node_dbginfo(node, n, s)   do {} while (0)
 
#define devres_log(dev, node, op)   do {} while (0)
 

Functions

voiddevres_alloc (dr_release_t release, size_t size, gfp_t gfp)
 
 EXPORT_SYMBOL_GPL (devres_alloc)
 
void devres_for_each_res (struct device *dev, dr_release_t release, dr_match_t match, void *match_data, void(*fn)(struct device *, void *, void *), void *data)
 
 EXPORT_SYMBOL_GPL (devres_for_each_res)
 
void devres_free (void *res)
 
 EXPORT_SYMBOL_GPL (devres_free)
 
void devres_add (struct device *dev, void *res)
 
 EXPORT_SYMBOL_GPL (devres_add)
 
voiddevres_find (struct device *dev, dr_release_t release, dr_match_t match, void *match_data)
 
 EXPORT_SYMBOL_GPL (devres_find)
 
voiddevres_get (struct device *dev, void *new_res, dr_match_t match, void *match_data)
 
 EXPORT_SYMBOL_GPL (devres_get)
 
voiddevres_remove (struct device *dev, dr_release_t release, dr_match_t match, void *match_data)
 
 EXPORT_SYMBOL_GPL (devres_remove)
 
int devres_destroy (struct device *dev, dr_release_t release, dr_match_t match, void *match_data)
 
 EXPORT_SYMBOL_GPL (devres_destroy)
 
int devres_release (struct device *dev, dr_release_t release, dr_match_t match, void *match_data)
 
 EXPORT_SYMBOL_GPL (devres_release)
 
int devres_release_all (struct device *dev)
 
voiddevres_open_group (struct device *dev, void *id, gfp_t gfp)
 
 EXPORT_SYMBOL_GPL (devres_open_group)
 
void devres_close_group (struct device *dev, void *id)
 
 EXPORT_SYMBOL_GPL (devres_close_group)
 
void devres_remove_group (struct device *dev, void *id)
 
 EXPORT_SYMBOL_GPL (devres_remove_group)
 
int devres_release_group (struct device *dev, void *id)
 
 EXPORT_SYMBOL_GPL (devres_release_group)
 
voiddevm_kzalloc (struct device *dev, size_t size, gfp_t gfp)
 
 EXPORT_SYMBOL_GPL (devm_kzalloc)
 
void devm_kfree (struct device *dev, void *p)
 
 EXPORT_SYMBOL_GPL (devm_kfree)
 

Macro Definition Documentation

#define devres_log (   dev,
  node,
  op 
)    do {} while (0)

Definition at line 58 of file devres.c.

#define set_node_dbginfo (   node,
  n,
  s 
)    do {} while (0)

Definition at line 57 of file devres.c.

Function Documentation

void devm_kfree ( struct device dev,
void p 
)

devm_kfree - Resource-managed kfree : Device this memory belongs to : Memory to free

Free memory allocated with devm_kzalloc().

Definition at line 721 of file devres.c.

void* devm_kzalloc ( struct device dev,
size_t  size,
gfp_t  gfp 
)

devm_kzalloc - Resource-managed kzalloc : Device to allocate memory for : Allocation size : Allocation gfp flags

Managed kzalloc. Memory allocated with this function is automatically freed on driver detach. Like all other devres resources, guaranteed alignment is unsigned long long.

RETURNS: Pointer to allocated memory on success, NULL on failure.

Definition at line 699 of file devres.c.

void devres_add ( struct device dev,
void res 
)

devres_add - Register device resource : Device to add resource to : Resource to register

Register devres to . should have been allocated using devres_alloc(). On driver detach, the associated release function will be invoked and devres will be freed automatically.

Definition at line 214 of file devres.c.

void* devres_alloc ( dr_release_t  release,
size_t  size,
gfp_t  gfp 
)

devres_alloc - Allocate device resource data : Release function devres will be associated with : Allocation size : Allocation flags

Allocate devres of bytes. The allocated area is zeroed, then associated with . The returned pointer can be passed to other devres_*() functions.

RETURNS: Pointer to allocated devres on success, NULL on failure.

Definition at line 134 of file devres.c.

void devres_close_group ( struct device dev,
void id 
)

devres_close_group - Close a devres group : Device to close devres group for : ID of target group, can be NULL

Close the group identified by . If is NULL, the latest open group is selected.

Definition at line 588 of file devres.c.

int devres_destroy ( struct device dev,
dr_release_t  release,
dr_match_t  match,
void match_data 
)

devres_destroy - Find a device resource and destroy it : Device to find resource from : Look for resources associated with this release function : Match function (optional) : Data for the match function

Find the latest devres of associated with and for which returns 1. If is NULL, it's considered to match all. If found, the resource is removed atomically and freed.

Note that the release function for the resource will not be called, only the devres-allocated data will be freed. The caller becomes responsible for freeing any other data.

RETURNS: 0 if devres is found and freed, -ENOENT if not found.

Definition at line 361 of file devres.c.

void* devres_find ( struct device dev,
dr_release_t  release,
dr_match_t  match,
void match_data 
)

devres_find - Find device resource : Device to lookup resource from : Look for resources associated with this release function : Match function (optional) : Data for the match function

Find the latest devres of which is associated with and for which returns 1. If is NULL, it's considered to match all.

RETURNS: Pointer to found devres, NULL if not found.

Definition at line 257 of file devres.c.

void devres_for_each_res ( struct device dev,
dr_release_t  release,
dr_match_t  match,
void match_data,
void(*)(struct device *, void *, void *)  fn,
void data 
)

Definition at line 161 of file devres.c.

void devres_free ( void res)

devres_free - Free device resource data : Pointer to devres data to free

Free devres created with devres_alloc().

Definition at line 194 of file devres.c.

void* devres_get ( struct device dev,
void new_res,
dr_match_t  match,
void match_data 
)

devres_get - Find devres, if non-existent, add one atomically : Device to lookup or add devres for : Pointer to new initialized devres to add if not found : Match function (optional) : Data for the match function

Find the latest devres of which has the same release function as and for which return 1. If found, is freed; otherwise, is added atomically.

RETURNS: Pointer to found or added devres.

Definition at line 287 of file devres.c.

void* devres_open_group ( struct device dev,
void id,
gfp_t  gfp 
)

devres_open_group - Open a new devres group : Device to open devres group for : Separator ID : Allocation flags

Open a new devres group for with . For , using a pointer to an object which won't be used for another group is recommended. If is NULL, address-wise unique ID is created.

RETURNS: ID of the new group, NULL on failure.

Definition at line 531 of file devres.c.

int devres_release ( struct device dev,
dr_release_t  release,
dr_match_t  match,
void match_data 
)

devres_release - Find a device resource and destroy it, calling release : Device to find resource from : Look for resources associated with this release function : Match function (optional) : Data for the match function

Find the latest devres of associated with and for which returns 1. If is NULL, it's considered to match all. If found, the resource is removed atomically, the release function called and the resource freed.

RETURNS: 0 if devres is found and freed, -ENOENT if not found.

Definition at line 391 of file devres.c.

int devres_release_all ( struct device dev)

devres_release_all - Release all managed resources : Device to release resources for

Release all resources associated with . This function is called on driver detach.

Definition at line 506 of file devres.c.

int devres_release_group ( struct device dev,
void id 
)

devres_release_group - Release resources in a devres group : Device to release group for : ID of target group, can be NULL

Release all resources in the group identified by . If is NULL, the latest open group is selected. The selected group and groups properly nested inside the selected group are removed.

RETURNS: The number of released non-group resources.

Definition at line 647 of file devres.c.

void* devres_remove ( struct device dev,
dr_release_t  release,
dr_match_t  match,
void match_data 
)

devres_remove - Find a device resource and remove it : Device to find resource from : Look for resources associated with this release function : Match function (optional) : Data for the match function

Find the latest devres of associated with and for which returns 1. If is NULL, it's considered to match all. If found, the resource is removed atomically and returned.

RETURNS: Pointer to removed devres on success, NULL if not found.

Definition at line 323 of file devres.c.

void devres_remove_group ( struct device dev,
void id 
)

devres_remove_group - Remove a devres group : Device to remove group for : ID of target group, can be NULL

Remove the group identified by . If is NULL, the latest open group is selected. Note that removing a group doesn't affect any other resources.

Definition at line 614 of file devres.c.

EXPORT_SYMBOL_GPL ( devres_alloc  )
EXPORT_SYMBOL_GPL ( devres_for_each_res  )
EXPORT_SYMBOL_GPL ( devres_free  )
EXPORT_SYMBOL_GPL ( devres_add  )
EXPORT_SYMBOL_GPL ( devres_find  )
EXPORT_SYMBOL_GPL ( devres_get  )
EXPORT_SYMBOL_GPL ( devres_remove  )
EXPORT_SYMBOL_GPL ( devres_destroy  )
EXPORT_SYMBOL_GPL ( devres_release  )
EXPORT_SYMBOL_GPL ( devres_open_group  )
EXPORT_SYMBOL_GPL ( devres_close_group  )
EXPORT_SYMBOL_GPL ( devres_remove_group  )
EXPORT_SYMBOL_GPL ( devres_release_group  )
EXPORT_SYMBOL_GPL ( devm_kzalloc  )
EXPORT_SYMBOL_GPL ( devm_kfree  )