diff options
Diffstat (limited to 'include/linux/device.h')
-rw-r--r-- | include/linux/device.h | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index 94638efa0bf8..5e44cff5bced 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/atomic.h> | 26 | #include <linux/atomic.h> |
27 | #include <linux/ratelimit.h> | 27 | #include <linux/ratelimit.h> |
28 | #include <linux/uidgid.h> | 28 | #include <linux/uidgid.h> |
29 | #include <linux/gfp.h> | ||
29 | #include <asm/device.h> | 30 | #include <asm/device.h> |
30 | 31 | ||
31 | struct device; | 32 | struct device; |
@@ -606,8 +607,24 @@ extern void devres_close_group(struct device *dev, void *id); | |||
606 | extern void devres_remove_group(struct device *dev, void *id); | 607 | extern void devres_remove_group(struct device *dev, void *id); |
607 | extern int devres_release_group(struct device *dev, void *id); | 608 | extern int devres_release_group(struct device *dev, void *id); |
608 | 609 | ||
609 | /* managed kzalloc/kfree for device drivers, no kmalloc, always use kzalloc */ | 610 | /* managed devm_k.alloc/kfree for device drivers */ |
610 | extern void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp); | 611 | extern void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp); |
612 | static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp) | ||
613 | { | ||
614 | return devm_kmalloc(dev, size, gfp | __GFP_ZERO); | ||
615 | } | ||
616 | static inline void *devm_kmalloc_array(struct device *dev, | ||
617 | size_t n, size_t size, gfp_t flags) | ||
618 | { | ||
619 | if (size != 0 && n > SIZE_MAX / size) | ||
620 | return NULL; | ||
621 | return devm_kmalloc(dev, n * size, flags); | ||
622 | } | ||
623 | static inline void *devm_kcalloc(struct device *dev, | ||
624 | size_t n, size_t size, gfp_t flags) | ||
625 | { | ||
626 | return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO); | ||
627 | } | ||
611 | extern void devm_kfree(struct device *dev, void *p); | 628 | extern void devm_kfree(struct device *dev, void *p); |
612 | 629 | ||
613 | void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res); | 630 | void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res); |