Commit 3d3f2279 authored by Luca Ceresoli's avatar Luca Ceresoli
Browse files

drm/sti: dvo: convert to devm_drm_bridge_alloc() API



This is the new API for allocating DRM bridges.

This driver allocates the DRM bridge separately from the main driver
private struct, which prevents using the new devm_drm_bridge_alloc()
API. Simplify the code by replacing the struct drm_bridge pointer with an
embedded struct drm_bridge inside the private struct, to make use of the
new API with the same code flow.

Acked-by: default avatarMaxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/20250509-drm-bridge-convert-to-alloc-api-v3-16-b8bc1f16d7aa@bootlin.com


Signed-off-by: default avatarLuca Ceresoli <luca.ceresoli@bootlin.com>
parent ee81a4a2
Loading
Loading
Loading
Loading
+11 −18
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ struct sti_dvo {
	struct dvo_config *config;
	bool enabled;
	struct drm_encoder *encoder;
	struct drm_bridge *bridge;
	struct drm_bridge bridge;
};

struct sti_dvo_connector {
@@ -439,7 +439,6 @@ static int sti_dvo_bind(struct device *dev, struct device *master, void *data)
	struct drm_encoder *encoder;
	struct sti_dvo_connector *connector;
	struct drm_connector *drm_connector;
	struct drm_bridge *bridge;
	int err;

	/* Set the drm device handle */
@@ -455,20 +454,14 @@ static int sti_dvo_bind(struct device *dev, struct device *master, void *data)

	connector->dvo = dvo;

	bridge = devm_kzalloc(dev, sizeof(*bridge), GFP_KERNEL);
	if (!bridge)
		return -ENOMEM;

	bridge->driver_private = dvo;
	bridge->funcs = &sti_dvo_bridge_funcs;
	bridge->of_node = dvo->dev.of_node;
	drm_bridge_add(bridge);
	dvo->bridge.driver_private = dvo;
	dvo->bridge.of_node = dvo->dev.of_node;
	drm_bridge_add(&dvo->bridge);

	err = drm_bridge_attach(encoder, bridge, NULL, 0);
	err = drm_bridge_attach(encoder, &dvo->bridge, NULL, 0);
	if (err)
		return err;

	dvo->bridge = bridge;
	connector->encoder = encoder;
	dvo->encoder = encoder;

@@ -490,7 +483,7 @@ static int sti_dvo_bind(struct device *dev, struct device *master, void *data)
	return 0;

err_sysfs:
	drm_bridge_remove(bridge);
	drm_bridge_remove(&dvo->bridge);
	return -EINVAL;
}

@@ -499,7 +492,7 @@ static void sti_dvo_unbind(struct device *dev,
{
	struct sti_dvo *dvo = dev_get_drvdata(dev);

	drm_bridge_remove(dvo->bridge);
	drm_bridge_remove(&dvo->bridge);
}

static const struct component_ops sti_dvo_ops = {
@@ -515,10 +508,10 @@ static int sti_dvo_probe(struct platform_device *pdev)

	DRM_INFO("%s\n", __func__);

	dvo = devm_kzalloc(dev, sizeof(*dvo), GFP_KERNEL);
	if (!dvo) {
		DRM_ERROR("Failed to allocate memory for DVO\n");
		return -ENOMEM;
	dvo = devm_drm_bridge_alloc(dev, struct sti_dvo, bridge, &sti_dvo_bridge_funcs);
	if (IS_ERR(dvo)) {
		DRM_ERROR("Failed to allocate DVO\n");
		return PTR_ERR(dvo);
	}

	dvo->dev = pdev->dev;