Commit af509dfc authored by Luca Ceresoli's avatar Luca Ceresoli
Browse files

drm/omap: dss: sdi: convert to devm_drm_bridge_alloc() API



This is the new API for allocating DRM bridges.

Switching from a non-devm to a devm allocation allows removing the kfree()
in the remove function and in the probe error management code, and as a
consequence to simplify the code flow by removing now unnecessary gotos.

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


Signed-off-by: default avatarLuca Ceresoli <luca.ceresoli@bootlin.com>
parent eb01c3cc
Loading
Loading
Loading
Loading
+8 −17
Original line number Diff line number Diff line
@@ -284,7 +284,6 @@ static const struct drm_bridge_funcs sdi_bridge_funcs = {

static void sdi_bridge_init(struct sdi_device *sdi)
{
	sdi->bridge.funcs = &sdi_bridge_funcs;
	sdi->bridge.of_node = sdi->pdev->dev.of_node;
	sdi->bridge.type = DRM_MODE_CONNECTOR_LVDS;

@@ -344,21 +343,19 @@ int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
	u32 datapairs;
	int r;

	sdi = kzalloc(sizeof(*sdi), GFP_KERNEL);
	if (!sdi)
		return -ENOMEM;
	sdi = devm_drm_bridge_alloc(&pdev->dev, struct sdi_device, bridge, &sdi_bridge_funcs);
	if (IS_ERR(sdi))
		return PTR_ERR(sdi);

	ep = of_graph_get_next_port_endpoint(port, NULL);
	if (!ep) {
		r = 0;
		goto err_free;
	}
	if (!ep)
		return 0;

	r = of_property_read_u32(ep, "datapairs", &datapairs);
	of_node_put(ep);
	if (r) {
		DSSERR("failed to parse datapairs\n");
		goto err_free;
		return r;
	}

	sdi->datapairs = datapairs;
@@ -372,19 +369,14 @@ int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
		r = PTR_ERR(sdi->vdds_sdi_reg);
		if (r != -EPROBE_DEFER)
			DSSERR("can't get VDDS_SDI regulator\n");
		goto err_free;
		return r;
	}

	r = sdi_init_output(sdi);
	if (r)
		goto err_free;
		return r;

	return 0;

err_free:
	kfree(sdi);

	return r;
}

void sdi_uninit_port(struct device_node *port)
@@ -395,5 +387,4 @@ void sdi_uninit_port(struct device_node *port)
		return;

	sdi_uninit_output(sdi);
	kfree(sdi);
}