drm/bridge: Add devm_drm_bridge_add()
This adds a devm managed version of drm_bridge_add(). Like other "devm" function listed in drm_bridge.h, this function takes an explicit "dev" to use for the lifetime management. A few notes: * In general we have a "struct device" for bridges that makes a good candidate for where the lifetime matches exactly what we want. * The "bridge->dev->dev" device appears to be the encoder device. That's not the right device to use for lifetime management. Suggested-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Signed-off-by: Douglas Anderson <dianders@chromium.org> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Link: https://patchwork.freedesktop.org/patch/msgid/20220510122726.v3.3.Iba4b9bf6c7a1ee5ea2835ad7bd5eaf84d7688520@changeid
This commit is contained in:
parent
3800b17109
commit
50e156bd8a
|
@ -170,6 +170,29 @@ void drm_bridge_add(struct drm_bridge *bridge)
|
|||
}
|
||||
EXPORT_SYMBOL(drm_bridge_add);
|
||||
|
||||
static void drm_bridge_remove_void(void *bridge)
|
||||
{
|
||||
drm_bridge_remove(bridge);
|
||||
}
|
||||
|
||||
/**
|
||||
* devm_drm_bridge_add - devm managed version of drm_bridge_add()
|
||||
*
|
||||
* @dev: device to tie the bridge lifetime to
|
||||
* @bridge: bridge control structure
|
||||
*
|
||||
* This is the managed version of drm_bridge_add() which automatically
|
||||
* calls drm_bridge_remove() when @dev is unbound.
|
||||
*
|
||||
* Return: 0 if no error or negative error code.
|
||||
*/
|
||||
int devm_drm_bridge_add(struct device *dev, struct drm_bridge *bridge)
|
||||
{
|
||||
drm_bridge_add(bridge);
|
||||
return devm_add_action_or_reset(dev, drm_bridge_remove_void, bridge);
|
||||
}
|
||||
EXPORT_SYMBOL(devm_drm_bridge_add);
|
||||
|
||||
/**
|
||||
* drm_bridge_remove - remove the given bridge from the global bridge list
|
||||
*
|
||||
|
|
|
@ -796,6 +796,7 @@ drm_priv_to_bridge(struct drm_private_obj *priv)
|
|||
}
|
||||
|
||||
void drm_bridge_add(struct drm_bridge *bridge);
|
||||
int devm_drm_bridge_add(struct device *dev, struct drm_bridge *bridge);
|
||||
void drm_bridge_remove(struct drm_bridge *bridge);
|
||||
int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
|
||||
struct drm_bridge *previous,
|
||||
|
|
Loading…
Reference in New Issue