mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-23 05:56:14 -04:00
drm/bridge: add devm_drm_bridge_alloc()
Add a macro to allocate and initialize a DRM bridge embedded within a private driver struct. Compared to current practice, which is based on [devm_]kzalloc() allocation followed by open-coded initialization of fields, this allows to have a common and explicit API to allocate and initialize DRM bridges. Besides being useful to consolidate bridge driver code, this is a fundamental step in preparation for adding dynamic lifetime to bridges based on refcount. Reviewed-by: Maxime Ripard <mripard@kernel.org> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250326-drm-bridge-refcount-v9-1-5e0661fe1f84@bootlin.com Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
This commit is contained in:
committed by
Louis Chauvet
parent
81feddc126
commit
0cc6aadd7f
@@ -199,6 +199,28 @@
|
||||
static DEFINE_MUTEX(bridge_lock);
|
||||
static LIST_HEAD(bridge_list);
|
||||
|
||||
void *__devm_drm_bridge_alloc(struct device *dev, size_t size, size_t offset,
|
||||
const struct drm_bridge_funcs *funcs)
|
||||
{
|
||||
void *container;
|
||||
struct drm_bridge *bridge;
|
||||
|
||||
if (!funcs) {
|
||||
dev_warn(dev, "Missing funcs pointer\n");
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
container = devm_kzalloc(dev, size, GFP_KERNEL);
|
||||
if (!container)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
bridge = container + offset;
|
||||
bridge->funcs = funcs;
|
||||
|
||||
return container;
|
||||
}
|
||||
EXPORT_SYMBOL(__devm_drm_bridge_alloc);
|
||||
|
||||
/**
|
||||
* drm_bridge_add - add the given bridge to the global bridge list
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user