mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 07:03:03 +02:00
drm/bridge: imx8qxp-pixel-combiner: convert to devm_drm_bridge_alloc() API
This is the new API for allocating DRM bridges. This driver embeds an array of channels in the main struct, and each channel embeds a drm_bridge. This prevents dynamic, refcount-based deallocation of the bridges. To make the new, dynamic bridge allocation possible: * change the array of channels into an array of channel pointers * allocate each channel using devm_drm_bridge_alloc() * adapt the code wherever using the channels * remove the is_available flag, now "ch != NULL" is equivalent Reviewed-by: Liu Ying <victor.liu@nxp.com> Link: https://lore.kernel.org/r/20250509-drm-bridge-convert-to-alloc-api-v3-18-b8bc1f16d7aa@bootlin.com Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
This commit is contained in:
parent
a3f7d26dfc
commit
9976459352
|
|
@ -63,12 +63,11 @@ struct imx8qxp_pc_channel {
|
||||||
struct drm_bridge *next_bridge;
|
struct drm_bridge *next_bridge;
|
||||||
struct imx8qxp_pc *pc;
|
struct imx8qxp_pc *pc;
|
||||||
unsigned int stream_id;
|
unsigned int stream_id;
|
||||||
bool is_available;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct imx8qxp_pc {
|
struct imx8qxp_pc {
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct imx8qxp_pc_channel ch[2];
|
struct imx8qxp_pc_channel *ch[2];
|
||||||
struct clk *clk_apb;
|
struct clk *clk_apb;
|
||||||
void __iomem *base;
|
void __iomem *base;
|
||||||
};
|
};
|
||||||
|
|
@ -307,7 +306,14 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
|
||||||
goto free_child;
|
goto free_child;
|
||||||
}
|
}
|
||||||
|
|
||||||
ch = &pc->ch[i];
|
ch = devm_drm_bridge_alloc(dev, struct imx8qxp_pc_channel, bridge,
|
||||||
|
&imx8qxp_pc_bridge_funcs);
|
||||||
|
if (IS_ERR(ch)) {
|
||||||
|
ret = PTR_ERR(ch);
|
||||||
|
goto free_child;
|
||||||
|
}
|
||||||
|
|
||||||
|
pc->ch[i] = ch;
|
||||||
ch->pc = pc;
|
ch->pc = pc;
|
||||||
ch->stream_id = i;
|
ch->stream_id = i;
|
||||||
|
|
||||||
|
|
@ -333,9 +339,7 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
|
||||||
of_node_put(remote);
|
of_node_put(remote);
|
||||||
|
|
||||||
ch->bridge.driver_private = ch;
|
ch->bridge.driver_private = ch;
|
||||||
ch->bridge.funcs = &imx8qxp_pc_bridge_funcs;
|
|
||||||
ch->bridge.of_node = child;
|
ch->bridge.of_node = child;
|
||||||
ch->is_available = true;
|
|
||||||
|
|
||||||
drm_bridge_add(&ch->bridge);
|
drm_bridge_add(&ch->bridge);
|
||||||
}
|
}
|
||||||
|
|
@ -345,8 +349,8 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
|
||||||
free_child:
|
free_child:
|
||||||
of_node_put(child);
|
of_node_put(child);
|
||||||
|
|
||||||
if (i == 1 && pc->ch[0].next_bridge)
|
if (i == 1 && pc->ch[0]->next_bridge)
|
||||||
drm_bridge_remove(&pc->ch[0].bridge);
|
drm_bridge_remove(&pc->ch[0]->bridge);
|
||||||
|
|
||||||
pm_runtime_disable(dev);
|
pm_runtime_disable(dev);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -359,13 +363,10 @@ static void imx8qxp_pc_bridge_remove(struct platform_device *pdev)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
ch = &pc->ch[i];
|
ch = pc->ch[i];
|
||||||
|
|
||||||
if (!ch->is_available)
|
if (ch)
|
||||||
continue;
|
drm_bridge_remove(&ch->bridge);
|
||||||
|
|
||||||
drm_bridge_remove(&ch->bridge);
|
|
||||||
ch->is_available = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pm_runtime_disable(&pdev->dev);
|
pm_runtime_disable(&pdev->dev);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user