Commit 4a878c03 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Archit Taneja

drm: bridge: Detach bridge from encoder at encoder cleanup time

Most drivers that use bridges forgot to detach them at cleanup time.
Instead of fixing them one by one, detach the bridge in the core
drm_encoder_cleanup() function.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarArchit Taneja <architt@codeaurora.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1481709550-29226-5-git-send-email-laurent.pinchart+renesas@ideasonboard.com
parent 3bb80f24
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include <drm/drm_bridge.h> #include <drm/drm_bridge.h>
#include <drm/drm_encoder.h> #include <drm/drm_encoder.h>
#include "drm_crtc_internal.h"
/** /**
* DOC: overview * DOC: overview
* *
...@@ -145,16 +147,6 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, ...@@ -145,16 +147,6 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
} }
EXPORT_SYMBOL(drm_bridge_attach); EXPORT_SYMBOL(drm_bridge_attach);
/**
* drm_bridge_detach - deassociate given bridge from its DRM device
*
* @bridge: bridge control structure
*
* Called by a kms driver to unlink the given bridge from its DRM device.
*
* Note that tearing down links between the bridge and our encoder/bridge
* objects needs to be handled by the kms driver itself.
*/
void drm_bridge_detach(struct drm_bridge *bridge) void drm_bridge_detach(struct drm_bridge *bridge)
{ {
if (WARN_ON(!bridge)) if (WARN_ON(!bridge))
...@@ -168,7 +160,6 @@ void drm_bridge_detach(struct drm_bridge *bridge) ...@@ -168,7 +160,6 @@ void drm_bridge_detach(struct drm_bridge *bridge)
bridge->dev = NULL; bridge->dev = NULL;
} }
EXPORT_SYMBOL(drm_bridge_detach);
/** /**
* DOC: bridge callbacks * DOC: bridge callbacks
......
...@@ -186,6 +186,9 @@ void drm_plane_unregister_all(struct drm_device *dev); ...@@ -186,6 +186,9 @@ void drm_plane_unregister_all(struct drm_device *dev);
int drm_plane_check_pixel_format(const struct drm_plane *plane, int drm_plane_check_pixel_format(const struct drm_plane *plane,
u32 format); u32 format);
/* drm_bridge.c */
void drm_bridge_detach(struct drm_bridge *bridge);
/* IOCTL */ /* IOCTL */
int drm_mode_getplane_res(struct drm_device *dev, void *data, int drm_mode_getplane_res(struct drm_device *dev, void *data,
struct drm_file *file_priv); struct drm_file *file_priv);
......
...@@ -159,6 +159,9 @@ void drm_encoder_cleanup(struct drm_encoder *encoder) ...@@ -159,6 +159,9 @@ void drm_encoder_cleanup(struct drm_encoder *encoder)
* the indices on the drm_encoder after us in the encoder_list. * the indices on the drm_encoder after us in the encoder_list.
*/ */
if (encoder->bridge)
drm_bridge_detach(encoder->bridge);
drm_mode_object_unregister(dev, &encoder->base); drm_mode_object_unregister(dev, &encoder->base);
kfree(encoder->name); kfree(encoder->name);
list_del(&encoder->head); list_del(&encoder->head);
......
...@@ -186,23 +186,6 @@ int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe *pipe, ...@@ -186,23 +186,6 @@ int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe *pipe,
} }
EXPORT_SYMBOL(drm_simple_display_pipe_attach_bridge); EXPORT_SYMBOL(drm_simple_display_pipe_attach_bridge);
/**
* drm_simple_display_pipe_detach_bridge - Detach the bridge from the display pipe
* @pipe: simple display pipe object
*
* Detaches the drm bridge previously attached with
* drm_simple_display_pipe_attach_bridge()
*/
void drm_simple_display_pipe_detach_bridge(struct drm_simple_display_pipe *pipe)
{
if (WARN_ON(!pipe->encoder.bridge))
return;
drm_bridge_detach(pipe->encoder.bridge);
pipe->encoder.bridge = NULL;
}
EXPORT_SYMBOL(drm_simple_display_pipe_detach_bridge);
/** /**
* drm_simple_display_pipe_init - Initialize a simple display pipeline * drm_simple_display_pipe_init - Initialize a simple display pipeline
* @dev: DRM device * @dev: DRM device
......
...@@ -736,8 +736,6 @@ static void imx_ldb_unbind(struct device *dev, struct device *master, ...@@ -736,8 +736,6 @@ static void imx_ldb_unbind(struct device *dev, struct device *master,
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
struct imx_ldb_channel *channel = &imx_ldb->channel[i]; struct imx_ldb_channel *channel = &imx_ldb->channel[i];
if (channel->bridge)
drm_bridge_detach(channel->bridge);
if (channel->panel) if (channel->panel)
drm_panel_detach(channel->panel); drm_panel_detach(channel->panel);
......
...@@ -284,8 +284,6 @@ static void imx_pd_unbind(struct device *dev, struct device *master, ...@@ -284,8 +284,6 @@ static void imx_pd_unbind(struct device *dev, struct device *master,
{ {
struct imx_parallel_display *imxpd = dev_get_drvdata(dev); struct imx_parallel_display *imxpd = dev_get_drvdata(dev);
if (imxpd->bridge)
drm_bridge_detach(imxpd->bridge);
if (imxpd->panel) if (imxpd->panel)
drm_panel_detach(imxpd->panel); drm_panel_detach(imxpd->panel);
......
...@@ -203,7 +203,6 @@ void drm_bridge_remove(struct drm_bridge *bridge); ...@@ -203,7 +203,6 @@ void drm_bridge_remove(struct drm_bridge *bridge);
struct drm_bridge *of_drm_find_bridge(struct device_node *np); struct drm_bridge *of_drm_find_bridge(struct device_node *np);
int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
struct drm_bridge *previous); struct drm_bridge *previous);
void drm_bridge_detach(struct drm_bridge *bridge);
bool drm_bridge_mode_fixup(struct drm_bridge *bridge, bool drm_bridge_mode_fixup(struct drm_bridge *bridge,
const struct drm_display_mode *mode, const struct drm_display_mode *mode,
......
...@@ -114,8 +114,6 @@ struct drm_simple_display_pipe { ...@@ -114,8 +114,6 @@ struct drm_simple_display_pipe {
int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe *pipe, int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe *pipe,
struct drm_bridge *bridge); struct drm_bridge *bridge);
void drm_simple_display_pipe_detach_bridge(struct drm_simple_display_pipe *pipe);
int drm_simple_display_pipe_init(struct drm_device *dev, int drm_simple_display_pipe_init(struct drm_device *dev,
struct drm_simple_display_pipe *pipe, struct drm_simple_display_pipe *pipe,
const struct drm_simple_display_pipe_funcs *funcs, const struct drm_simple_display_pipe_funcs *funcs,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment