diff options
| author | Philipp Zabel <p.zabel@pengutronix.de> | 2013-04-29 19:17:10 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 21:28:13 -0400 |
| commit | 9375db07adeaeea5f5ea7ca0463a8b371d71ddbb (patch) | |
| tree | 8825d1985a7bd6acd9e13de4594c574c81dd11fe /include | |
| parent | 3119b487e03650b51589a86aac33098b7cc2a09e (diff) | |
genalloc: add devres support, allow to find a managed pool by device
This patch adds three exported functions to lib/genalloc.c:
devm_gen_pool_create, dev_get_gen_pool, and of_get_named_gen_pool.
devm_gen_pool_create is a managed version of gen_pool_create that keeps
track of the pool via devres and allows the management code to
automatically destroy it after device removal.
dev_get_gen_pool retrieves the gen_pool for a given device, if it was
created with devm_gen_pool_create, using devres_find.
of_get_named_gen_pool retrieves the gen_pool for a given device node and
property name, where the property must contain a phandle pointing to a
platform device node. The corresponding platform device is then fed into
dev_get_gen_pool and the resulting gen_pool is returned.
[akpm@linux-foundation.org: make the of_get_named_gen_pool() stub static, fixing a zillion link errors]
[akpm@linux-foundation.org: squish "struct device declared inside parameter list" warning]
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Tested-by: Michal Simek <monstr@monstr.eu>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Matt Porter <mporter@ti.com>
Cc: Dong Aisheng <dong.aisheng@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Javier Martin <javier.martin@vista-silicon.com>
Cc: Huang Shijie <shijie8@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/genalloc.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/linux/genalloc.h b/include/linux/genalloc.h index dd7c569aacad..661d374aeb2d 100644 --- a/include/linux/genalloc.h +++ b/include/linux/genalloc.h | |||
| @@ -29,6 +29,10 @@ | |||
| 29 | 29 | ||
| 30 | #ifndef __GENALLOC_H__ | 30 | #ifndef __GENALLOC_H__ |
| 31 | #define __GENALLOC_H__ | 31 | #define __GENALLOC_H__ |
| 32 | |||
| 33 | struct device; | ||
| 34 | struct device_node; | ||
| 35 | |||
| 32 | /** | 36 | /** |
| 33 | * Allocation callback function type definition | 37 | * Allocation callback function type definition |
| 34 | * @map: Pointer to bitmap | 38 | * @map: Pointer to bitmap |
| @@ -105,4 +109,18 @@ extern unsigned long gen_pool_first_fit(unsigned long *map, unsigned long size, | |||
| 105 | extern unsigned long gen_pool_best_fit(unsigned long *map, unsigned long size, | 109 | extern unsigned long gen_pool_best_fit(unsigned long *map, unsigned long size, |
| 106 | unsigned long start, unsigned int nr, void *data); | 110 | unsigned long start, unsigned int nr, void *data); |
| 107 | 111 | ||
| 112 | extern struct gen_pool *devm_gen_pool_create(struct device *dev, | ||
| 113 | int min_alloc_order, int nid); | ||
| 114 | extern struct gen_pool *dev_get_gen_pool(struct device *dev); | ||
| 115 | |||
| 116 | #ifdef CONFIG_OF | ||
| 117 | extern struct gen_pool *of_get_named_gen_pool(struct device_node *np, | ||
| 118 | const char *propname, int index); | ||
| 119 | #else | ||
| 120 | static inline struct gen_pool *of_get_named_gen_pool(struct device_node *np, | ||
| 121 | const char *propname, int index) | ||
| 122 | { | ||
| 123 | return NULL; | ||
| 124 | } | ||
| 125 | #endif | ||
| 108 | #endif /* __GENALLOC_H__ */ | 126 | #endif /* __GENALLOC_H__ */ |
