最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c - Does devm_drm_dev_alloc() treat the drm_device as a managed resource of the parent device? - Stack Overflow

programmeradmin6浏览0评论

When using a devm_* function, I'm aware that it allocates and manages memory for the resource of a device. I imagine devm_drm_dev_alloc() does the same, but it initializes a drm_device which is also a device (this is where my confusion stems from). So is the drm device treated as a resource for the parent device created by users?

When using a devm_* function, I'm aware that it allocates and manages memory for the resource of a device. I imagine devm_drm_dev_alloc() does the same, but it initializes a drm_device which is also a device (this is where my confusion stems from). So is the drm device treated as a resource for the parent device created by users?

Share Improve this question asked Mar 19 at 0:36 Victor TermeVictor Terme 491 silver badge7 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3

Looking at calls here: devm_drm_dev_alloc calls devm_drm_dev_init(dev, driver, parent) after successful allocation, which in turn calls drm_dev_init(dev, driver, parent) , which in turn calls get_device(parent) to get a handle on the parent to store in the newly allocated device, which calls kobj_get(&dev->kobj) (dev here is the parent device) which does increment the reference counter on the parent.

So the initialized device will contain a reference to the parent device, and the reference counter on the parent device is incremented accordingly for this new handle.

发布评论

评论列表(0)

  1. 暂无评论