Commit 3f3623dd authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Tomi Valkeinen

drm/omap: Remove enable checks from display .enable() and .remove()

The displays (connectors, panels and encoders) bail out from their
.enable() and .disable() handlers if the dss device is already enabled
or disabled. Those safety checks are not needed when the functions are
called through the omapdss_device_ops, as the .enable() and .disable()
handlers are called from the DRM atomic helpers that already guarantee
that no double enabling or disabling can occur.

However, the handlers are also called directly from the .remove()
handler. While this shouldn't be needed either as the modules can't be
removed as long as the device is in use, it's still a good practice to
disable the device explicitly. There is currently a safety check in
.remove() in some drivers but not all of them.

Remove the safety checks from the .enable() and .disable() handlers, and
add missing ones in the .remove() handler.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
Tested-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
parent b49a2139
...@@ -46,9 +46,6 @@ static void tvc_disable(struct omap_dss_device *dssdev) ...@@ -46,9 +46,6 @@ static void tvc_disable(struct omap_dss_device *dssdev)
{ {
struct omap_dss_device *src = dssdev->src; struct omap_dss_device *src = dssdev->src;
if (!omapdss_device_is_enabled(dssdev))
return;
src->ops->disable(src); src->ops->disable(src);
} }
...@@ -92,6 +89,7 @@ static int __exit tvc_remove(struct platform_device *pdev) ...@@ -92,6 +89,7 @@ static int __exit tvc_remove(struct platform_device *pdev)
omapdss_device_unregister(&ddata->dssdev); omapdss_device_unregister(&ddata->dssdev);
if (omapdss_device_is_enabled(dssdev))
tvc_disable(dssdev); tvc_disable(dssdev);
return 0; return 0;
......
...@@ -57,9 +57,6 @@ static void dvic_disable(struct omap_dss_device *dssdev) ...@@ -57,9 +57,6 @@ static void dvic_disable(struct omap_dss_device *dssdev)
{ {
struct omap_dss_device *src = dssdev->src; struct omap_dss_device *src = dssdev->src;
if (!omapdss_device_is_enabled(dssdev))
return;
src->ops->disable(src); src->ops->disable(src);
} }
...@@ -282,6 +279,7 @@ static int __exit dvic_remove(struct platform_device *pdev) ...@@ -282,6 +279,7 @@ static int __exit dvic_remove(struct platform_device *pdev)
omapdss_device_unregister(&ddata->dssdev); omapdss_device_unregister(&ddata->dssdev);
if (omapdss_device_is_enabled(dssdev))
dvic_disable(dssdev); dvic_disable(dssdev);
i2c_put_adapter(ddata->i2c_adapter); i2c_put_adapter(ddata->i2c_adapter);
......
...@@ -52,9 +52,6 @@ static void hdmic_disable(struct omap_dss_device *dssdev) ...@@ -52,9 +52,6 @@ static void hdmic_disable(struct omap_dss_device *dssdev)
{ {
struct omap_dss_device *src = dssdev->src; struct omap_dss_device *src = dssdev->src;
if (!omapdss_device_is_enabled(dssdev))
return;
src->ops->disable(src); src->ops->disable(src);
} }
...@@ -179,6 +176,7 @@ static int __exit hdmic_remove(struct platform_device *pdev) ...@@ -179,6 +176,7 @@ static int __exit hdmic_remove(struct platform_device *pdev)
omapdss_device_unregister(&ddata->dssdev); omapdss_device_unregister(&ddata->dssdev);
if (omapdss_device_is_enabled(dssdev))
hdmic_disable(dssdev); hdmic_disable(dssdev);
return 0; return 0;
......
...@@ -49,9 +49,6 @@ static int opa362_enable(struct omap_dss_device *dssdev) ...@@ -49,9 +49,6 @@ static int opa362_enable(struct omap_dss_device *dssdev)
dev_dbg(dssdev->dev, "enable\n"); dev_dbg(dssdev->dev, "enable\n");
if (omapdss_device_is_enabled(dssdev))
return 0;
r = src->ops->enable(src); r = src->ops->enable(src);
if (r) if (r)
return r; return r;
...@@ -71,9 +68,6 @@ static void opa362_disable(struct omap_dss_device *dssdev) ...@@ -71,9 +68,6 @@ static void opa362_disable(struct omap_dss_device *dssdev)
dev_dbg(dssdev->dev, "disable\n"); dev_dbg(dssdev->dev, "disable\n");
if (!omapdss_device_is_enabled(dssdev))
return;
if (ddata->enable_gpio) if (ddata->enable_gpio)
gpiod_set_value_cansleep(ddata->enable_gpio, 0); gpiod_set_value_cansleep(ddata->enable_gpio, 0);
......
...@@ -42,9 +42,6 @@ static int tfp410_enable(struct omap_dss_device *dssdev) ...@@ -42,9 +42,6 @@ static int tfp410_enable(struct omap_dss_device *dssdev)
struct omap_dss_device *src = dssdev->src; struct omap_dss_device *src = dssdev->src;
int r; int r;
if (omapdss_device_is_enabled(dssdev))
return 0;
r = src->ops->enable(src); r = src->ops->enable(src);
if (r) if (r)
return r; return r;
...@@ -62,9 +59,6 @@ static void tfp410_disable(struct omap_dss_device *dssdev) ...@@ -62,9 +59,6 @@ static void tfp410_disable(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 *src = dssdev->src; struct omap_dss_device *src = dssdev->src;
if (!omapdss_device_is_enabled(dssdev))
return;
if (ddata->pd_gpio) if (ddata->pd_gpio)
gpiod_set_value_cansleep(ddata->pd_gpio, 0); gpiod_set_value_cansleep(ddata->pd_gpio, 0);
......
...@@ -72,9 +72,6 @@ static void panel_dpi_disable(struct omap_dss_device *dssdev) ...@@ -72,9 +72,6 @@ static void panel_dpi_disable(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 *src = dssdev->src; struct omap_dss_device *src = dssdev->src;
if (!omapdss_device_is_enabled(dssdev))
return;
backlight_disable(ddata->backlight); backlight_disable(ddata->backlight);
gpiod_set_value_cansleep(ddata->enable_gpio, 0); gpiod_set_value_cansleep(ddata->enable_gpio, 0);
...@@ -182,6 +179,7 @@ static int __exit panel_dpi_remove(struct platform_device *pdev) ...@@ -182,6 +179,7 @@ static int __exit panel_dpi_remove(struct platform_device *pdev)
omapdss_device_unregister(dssdev); omapdss_device_unregister(dssdev);
if (omapdss_device_is_enabled(dssdev))
panel_dpi_disable(dssdev); panel_dpi_disable(dssdev);
return 0; return 0;
......
...@@ -829,11 +829,9 @@ static void dsicm_disable(struct omap_dss_device *dssdev) ...@@ -829,11 +829,9 @@ static void dsicm_disable(struct omap_dss_device *dssdev)
src->ops->dsi.bus_lock(src); src->ops->dsi.bus_lock(src);
if (omapdss_device_is_enabled(dssdev)) {
r = dsicm_wake_up(ddata); r = dsicm_wake_up(ddata);
if (!r) if (!r)
dsicm_power_off(ddata); dsicm_power_off(ddata);
}
src->ops->dsi.bus_unlock(src); src->ops->dsi.bus_unlock(src);
...@@ -1367,6 +1365,7 @@ static int __exit dsicm_remove(struct platform_device *pdev) ...@@ -1367,6 +1365,7 @@ static int __exit dsicm_remove(struct platform_device *pdev)
omapdss_device_unregister(dssdev); omapdss_device_unregister(dssdev);
if (omapdss_device_is_enabled(dssdev))
dsicm_disable(dssdev); dsicm_disable(dssdev);
omapdss_device_disconnect(dssdev->src, dssdev); omapdss_device_disconnect(dssdev->src, dssdev);
......
...@@ -144,9 +144,6 @@ static void lb035q02_disable(struct omap_dss_device *dssdev) ...@@ -144,9 +144,6 @@ static void lb035q02_disable(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 *src = dssdev->src; struct omap_dss_device *src = dssdev->src;
if (!omapdss_device_is_enabled(dssdev))
return;
if (ddata->enable_gpio) if (ddata->enable_gpio)
gpiod_set_value_cansleep(ddata->enable_gpio, 0); gpiod_set_value_cansleep(ddata->enable_gpio, 0);
...@@ -235,6 +232,7 @@ static int lb035q02_panel_spi_remove(struct spi_device *spi) ...@@ -235,6 +232,7 @@ static int lb035q02_panel_spi_remove(struct spi_device *spi)
omapdss_device_unregister(dssdev); omapdss_device_unregister(dssdev);
if (omapdss_device_is_enabled(dssdev))
lb035q02_disable(dssdev); lb035q02_disable(dssdev);
return 0; return 0;
......
...@@ -138,9 +138,6 @@ static void nec_8048_disable(struct omap_dss_device *dssdev) ...@@ -138,9 +138,6 @@ static void nec_8048_disable(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 *src = dssdev->src; struct omap_dss_device *src = dssdev->src;
if (!omapdss_device_is_enabled(dssdev))
return;
gpiod_set_value_cansleep(ddata->res_gpio, 0); gpiod_set_value_cansleep(ddata->res_gpio, 0);
src->ops->disable(src); src->ops->disable(src);
...@@ -226,6 +223,7 @@ static int nec_8048_remove(struct spi_device *spi) ...@@ -226,6 +223,7 @@ static int nec_8048_remove(struct spi_device *spi)
omapdss_device_unregister(dssdev); omapdss_device_unregister(dssdev);
if (omapdss_device_is_enabled(dssdev))
nec_8048_disable(dssdev); nec_8048_disable(dssdev);
return 0; return 0;
......
...@@ -97,9 +97,6 @@ static void sharp_ls_disable(struct omap_dss_device *dssdev) ...@@ -97,9 +97,6 @@ static void sharp_ls_disable(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 *src = dssdev->src; struct omap_dss_device *src = dssdev->src;
if (!omapdss_device_is_enabled(dssdev))
return;
if (ddata->ini_gpio) if (ddata->ini_gpio)
gpiod_set_value_cansleep(ddata->ini_gpio, 0); gpiod_set_value_cansleep(ddata->ini_gpio, 0);
...@@ -233,6 +230,7 @@ static int __exit sharp_ls_remove(struct platform_device *pdev) ...@@ -233,6 +230,7 @@ static int __exit sharp_ls_remove(struct platform_device *pdev)
omapdss_device_unregister(dssdev); omapdss_device_unregister(dssdev);
if (omapdss_device_is_enabled(dssdev))
sharp_ls_disable(dssdev); sharp_ls_disable(dssdev);
return 0; return 0;
......
...@@ -605,9 +605,6 @@ static void acx565akm_disable(struct omap_dss_device *dssdev) ...@@ -605,9 +605,6 @@ static void acx565akm_disable(struct omap_dss_device *dssdev)
{ {
struct panel_drv_data *ddata = to_panel_data(dssdev); struct panel_drv_data *ddata = to_panel_data(dssdev);
if (!omapdss_device_is_enabled(dssdev))
return;
mutex_lock(&ddata->mutex); mutex_lock(&ddata->mutex);
acx565akm_panel_power_off(dssdev); acx565akm_panel_power_off(dssdev);
mutex_unlock(&ddata->mutex); mutex_unlock(&ddata->mutex);
...@@ -750,6 +747,7 @@ static int acx565akm_remove(struct spi_device *spi) ...@@ -750,6 +747,7 @@ static int acx565akm_remove(struct spi_device *spi)
omapdss_device_unregister(dssdev); omapdss_device_unregister(dssdev);
if (omapdss_device_is_enabled(dssdev))
acx565akm_disable(dssdev); acx565akm_disable(dssdev);
return 0; return 0;
......
...@@ -270,9 +270,6 @@ static void td028ttec1_panel_disable(struct omap_dss_device *dssdev) ...@@ -270,9 +270,6 @@ static void td028ttec1_panel_disable(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 *src = dssdev->src; struct omap_dss_device *src = dssdev->src;
if (!omapdss_device_is_enabled(dssdev))
return;
dev_dbg(dssdev->dev, "td028ttec1_panel_disable()\n"); dev_dbg(dssdev->dev, "td028ttec1_panel_disable()\n");
jbt_ret_write_0(ddata, JBT_REG_DISPLAY_OFF); jbt_ret_write_0(ddata, JBT_REG_DISPLAY_OFF);
...@@ -357,6 +354,7 @@ static int td028ttec1_panel_remove(struct spi_device *spi) ...@@ -357,6 +354,7 @@ static int td028ttec1_panel_remove(struct spi_device *spi)
omapdss_device_unregister(dssdev); omapdss_device_unregister(dssdev);
if (omapdss_device_is_enabled(dssdev))
td028ttec1_panel_disable(dssdev); td028ttec1_panel_disable(dssdev);
return 0; return 0;
......
...@@ -350,9 +350,6 @@ static void tpo_td043_disable(struct omap_dss_device *dssdev) ...@@ -350,9 +350,6 @@ static void tpo_td043_disable(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 *src = dssdev->src; struct omap_dss_device *src = dssdev->src;
if (!omapdss_device_is_enabled(dssdev))
return;
src->ops->disable(src); src->ops->disable(src);
if (!ddata->spi_suspended) if (!ddata->spi_suspended)
...@@ -457,6 +454,7 @@ static int tpo_td043_remove(struct spi_device *spi) ...@@ -457,6 +454,7 @@ static int tpo_td043_remove(struct spi_device *spi)
omapdss_device_unregister(dssdev); omapdss_device_unregister(dssdev);
if (omapdss_device_is_enabled(dssdev))
tpo_td043_disable(dssdev); tpo_td043_disable(dssdev);
sysfs_remove_group(&spi->dev.kobj, &tpo_td043_attr_group); sysfs_remove_group(&spi->dev.kobj, &tpo_td043_attr_group);
......
...@@ -151,9 +151,6 @@ static void omap_encoder_disable(struct drm_encoder *encoder) ...@@ -151,9 +151,6 @@ static void omap_encoder_disable(struct drm_encoder *encoder)
dev_dbg(dev->dev, "disable(%s)\n", dssdev->name); dev_dbg(dev->dev, "disable(%s)\n", dssdev->name);
if (!omapdss_device_is_enabled(dssdev))
return;
dssdev->ops->disable(dssdev); dssdev->ops->disable(dssdev);
dssdev->state = OMAP_DSS_DISPLAY_DISABLED; dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
...@@ -168,9 +165,6 @@ static void omap_encoder_enable(struct drm_encoder *encoder) ...@@ -168,9 +165,6 @@ static void omap_encoder_enable(struct drm_encoder *encoder)
dev_dbg(dev->dev, "enable(%s)\n", dssdev->name); dev_dbg(dev->dev, "enable(%s)\n", dssdev->name);
if (omapdss_device_is_enabled(dssdev))
return;
r = dssdev->ops->enable(dssdev); r = dssdev->ops->enable(dssdev);
if (r) { if (r) {
dev_err(dev->dev, "Failed to enable display '%s': %d\n", dev_err(dev->dev, "Failed to enable display '%s': %d\n",
......
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