1 // SPDX-License-Identifier: GPL-2.0 2 3 #ifndef _DRM_MANAGED_H_ 4 #define _DRM_MANAGED_H_ 5 6 #include <linux/gfp.h> 7 #include <linux/types.h> 8 9 struct drm_device; 10 11 typedef void (*drmres_release_t)(struct drm_device *dev, void *res); 12 13 #define drmm_add_action(dev, action, data) \ 14 __drmm_add_action(dev, action, data, #action) 15 16 int __must_check __drmm_add_action(struct drm_device *dev, 17 drmres_release_t action, 18 void *data, const char *name); 19 20 #define drmm_add_action_or_reset(dev, action, data) \ 21 __drmm_add_action_or_reset(dev, action, data, #action) 22 23 int __must_check __drmm_add_action_or_reset(struct drm_device *dev, 24 drmres_release_t action, 25 void *data, const char *name); 26 27 void drmm_add_final_kfree(struct drm_device *dev, void *container); 28 29 void *drmm_kmalloc(struct drm_device *dev, size_t size, gfp_t gfp) __malloc; 30 static inline void *drmm_kzalloc(struct drm_device *dev, size_t size, gfp_t gfp) 31 { 32 return drmm_kmalloc(dev, size, gfp | __GFP_ZERO); 33 } 34 char *drmm_kstrdup(struct drm_device *dev, const char *s, gfp_t gfp); 35 36 void drmm_kfree(struct drm_device *dev, void *data); 37 38 #endif 39