drm/omap: dss: Move src and dst check and set to connection handlers

The encoders duplicate the same omap_dss_device src and dst fields set
and checks in their connect and disconnect handlers. Move the code to
the connect and disconnect wrappers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
This commit is contained in:
Laurent Pinchart 2018-02-28 17:30:30 +02:00 committed by Tomi Valkeinen
parent 73fc0ac4a6
commit fb5571717c
12 changed files with 25 additions and 74 deletions

View File

@ -51,9 +51,6 @@ static int opa362_connect(struct omap_dss_device *dssdev,
return r; return r;
} }
dst->src = dssdev;
dssdev->dst = dst;
ddata->in = in; ddata->in = in;
return 0; return 0;
} }
@ -64,13 +61,6 @@ static void opa362_disconnect(struct omap_dss_device *dssdev,
struct panel_drv_data *ddata = to_panel_data(dssdev); struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *in = ddata->in; struct omap_dss_device *in = ddata->in;
WARN_ON(dst != dssdev->dst);
if (dst != dssdev->dst)
return;
dst->src = NULL;
dssdev->dst = NULL;
omapdss_device_disconnect(in, &ddata->dssdev); omapdss_device_disconnect(in, &ddata->dssdev);
omap_dss_put_device(in); omap_dss_put_device(in);

View File

@ -47,9 +47,6 @@ static int tfp410_connect(struct omap_dss_device *dssdev,
return r; return r;
} }
dst->src = dssdev;
dssdev->dst = dst;
ddata->in = in; ddata->in = in;
return 0; return 0;
} }
@ -60,13 +57,6 @@ static void tfp410_disconnect(struct omap_dss_device *dssdev,
struct panel_drv_data *ddata = to_panel_data(dssdev); struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *in = ddata->in; struct omap_dss_device *in = ddata->in;
WARN_ON(dst != dssdev->dst);
if (dst != dssdev->dst)
return;
dst->src = NULL;
dssdev->dst = NULL;
omapdss_device_disconnect(in, &ddata->dssdev); omapdss_device_disconnect(in, &ddata->dssdev);
omap_dss_put_device(in); omap_dss_put_device(in);

View File

@ -55,9 +55,6 @@ static int tpd_connect(struct omap_dss_device *dssdev,
return r; return r;
} }
dst->src = dssdev;
dssdev->dst = dst;
gpiod_set_value_cansleep(ddata->ct_cp_hpd_gpio, 1); gpiod_set_value_cansleep(ddata->ct_cp_hpd_gpio, 1);
gpiod_set_value_cansleep(ddata->ls_oe_gpio, 1); gpiod_set_value_cansleep(ddata->ls_oe_gpio, 1);
@ -74,17 +71,9 @@ static void tpd_disconnect(struct omap_dss_device *dssdev,
struct panel_drv_data *ddata = to_panel_data(dssdev); struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *in = ddata->in; struct omap_dss_device *in = ddata->in;
WARN_ON(dst != dssdev->dst);
if (dst != dssdev->dst)
return;
gpiod_set_value_cansleep(ddata->ct_cp_hpd_gpio, 0); gpiod_set_value_cansleep(ddata->ct_cp_hpd_gpio, 0);
gpiod_set_value_cansleep(ddata->ls_oe_gpio, 0); gpiod_set_value_cansleep(ddata->ls_oe_gpio, 0);
dst->src = NULL;
dssdev->dst = NULL;
omapdss_device_disconnect(in, &ddata->dssdev); omapdss_device_disconnect(in, &ddata->dssdev);
omap_dss_put_device(in); omap_dss_put_device(in);

View File

@ -105,15 +105,27 @@ struct omap_dss_device *omapdss_find_device_by_port(struct device_node *src,
int omapdss_device_connect(struct omap_dss_device *src, int omapdss_device_connect(struct omap_dss_device *src,
struct omap_dss_device *dst) struct omap_dss_device *dst)
{ {
int ret;
dev_dbg(src->dev, "connect\n"); dev_dbg(src->dev, "connect\n");
if (omapdss_device_is_connected(src)) if (omapdss_device_is_connected(src))
return -EBUSY; return -EBUSY;
if (src->driver) if (src->driver)
return src->driver->connect(src); ret = src->driver->connect(src);
else else
return src->ops->connect(src, dst); ret = src->ops->connect(src, dst);
if (ret < 0)
return ret;
if (dst) {
dst->src = src;
src->dst = dst;
}
return 0;
} }
EXPORT_SYMBOL_GPL(omapdss_device_connect); EXPORT_SYMBOL_GPL(omapdss_device_connect);
@ -127,6 +139,14 @@ void omapdss_device_disconnect(struct omap_dss_device *src,
return; return;
} }
if (dst) {
if (WARN_ON(dst != src->dst))
return;
dst->src = NULL;
src->dst = NULL;
}
if (src->driver) if (src->driver)
src->driver->disconnect(src); src->driver->disconnect(src);
else else

View File

@ -671,11 +671,6 @@ static void dpi_disconnect(struct omap_dss_device *dssdev,
{ {
struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
WARN_ON(dst != dssdev->dst);
if (dst != dssdev->dst)
return;
omapdss_output_unset_device(dssdev); omapdss_output_unset_device(dssdev);
dss_mgr_disconnect(&dpi->output, dssdev); dss_mgr_disconnect(&dpi->output, dssdev);

View File

@ -4990,11 +4990,6 @@ static void dsi_disconnect(struct omap_dss_device *dssdev,
{ {
struct dsi_data *dsi = to_dsi_data(dssdev); struct dsi_data *dsi = to_dsi_data(dssdev);
WARN_ON(dst != dssdev->dst);
if (dst != dssdev->dst)
return;
omapdss_output_unset_device(dssdev); omapdss_output_unset_device(dssdev);
dss_mgr_disconnect(&dsi->output, dssdev); dss_mgr_disconnect(&dsi->output, dssdev);

View File

@ -478,11 +478,6 @@ static void hdmi_disconnect(struct omap_dss_device *dssdev,
{ {
struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev); struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
WARN_ON(dst != dssdev->dst);
if (dst != dssdev->dst)
return;
omapdss_output_unset_device(dssdev); omapdss_output_unset_device(dssdev);
dss_mgr_disconnect(&hdmi->output, dssdev); dss_mgr_disconnect(&hdmi->output, dssdev);

View File

@ -481,11 +481,6 @@ static void hdmi_disconnect(struct omap_dss_device *dssdev,
{ {
struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev); struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
WARN_ON(dst != dssdev->dst);
if (dst != dssdev->dst)
return;
omapdss_output_unset_device(dssdev); omapdss_output_unset_device(dssdev);
dss_mgr_disconnect(&hdmi->output, dssdev); dss_mgr_disconnect(&hdmi->output, dssdev);

View File

@ -391,6 +391,9 @@ struct omap_dss_device {
struct module *owner; struct module *owner;
struct omap_dss_device *src;
struct omap_dss_device *dst;
struct list_head list; struct list_head list;
struct list_head panel_list; struct list_head panel_list;
@ -409,8 +412,6 @@ struct omap_dss_device {
enum omap_display_caps caps; enum omap_display_caps caps;
struct omap_dss_device *src;
enum omap_dss_display_state state; enum omap_dss_display_state state;
/* OMAP DSS output specific fields */ /* OMAP DSS output specific fields */
@ -426,9 +427,6 @@ struct omap_dss_device {
/* the port number in the DT node */ /* the port number in the DT node */
int port_num; int port_num;
/* dynamic fields */
struct omap_dss_device *dst;
}; };
struct omap_dss_driver { struct omap_dss_driver {

View File

@ -47,9 +47,6 @@ int omapdss_output_set_device(struct omap_dss_device *out,
goto err; goto err;
} }
out->dst = dssdev;
dssdev->src = out;
mutex_unlock(&output_lock); mutex_unlock(&output_lock);
return 0; return 0;
@ -81,9 +78,6 @@ int omapdss_output_unset_device(struct omap_dss_device *out)
goto err; goto err;
} }
out->dst->src = NULL;
out->dst = NULL;
mutex_unlock(&output_lock); mutex_unlock(&output_lock);
return 0; return 0;

View File

@ -301,11 +301,6 @@ static void sdi_disconnect(struct omap_dss_device *dssdev,
{ {
struct sdi_device *sdi = dssdev_to_sdi(dssdev); struct sdi_device *sdi = dssdev_to_sdi(dssdev);
WARN_ON(dst != dssdev->dst);
if (dst != dssdev->dst)
return;
omapdss_output_unset_device(dssdev); omapdss_output_unset_device(dssdev);
dss_mgr_disconnect(&sdi->output, dssdev); dss_mgr_disconnect(&sdi->output, dssdev);

View File

@ -740,11 +740,6 @@ static void venc_disconnect(struct omap_dss_device *dssdev,
{ {
struct venc_device *venc = dssdev_to_venc(dssdev); struct venc_device *venc = dssdev_to_venc(dssdev);
WARN_ON(dst != dssdev->dst);
if (dst != dssdev->dst)
return;
omapdss_output_unset_device(dssdev); omapdss_output_unset_device(dssdev);
dss_mgr_disconnect(&venc->output, dssdev); dss_mgr_disconnect(&venc->output, dssdev);