Commit 1a9e51be authored by Martin Blumenstingl's avatar Martin Blumenstingl Committed by Neil Armstrong

drm/meson: improve encoder probe / initialization error handling

Rename meson_encoder_{cvbs,dsi,hdmi}_init() to
meson_encoder_{cvbs,dsi,hdmi}_probe() so it's clear that these functions
are used at probe time during driver initialization. Also switch all
error prints inside those functions to use dev_err_probe() for
consistency.

This makes the code more straight forward to read and makes the error
prints within those functions consistent (by logging all -EPROBE_DEFER
with dev_dbg(), while actual errors are logged with dev_err() and get
the error value printed).
Signed-off-by: default avatarMartin Blumenstingl <martin.blumenstingl@googlemail.com>
Reviewed-by: default avatarNeil Armstrong <neil.armstrong@linaro.org>
Link: https://lore.kernel.org/r/20240218175035.1948165-1-martin.blumenstingl@googlemail.comSigned-off-by: default avatarNeil Armstrong <neil.armstrong@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240218175035.1948165-1-martin.blumenstingl@googlemail.com
parent 239cce65
...@@ -312,7 +312,7 @@ static int meson_drv_bind_master(struct device *dev, bool has_components) ...@@ -312,7 +312,7 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
/* Encoder Initialization */ /* Encoder Initialization */
ret = meson_encoder_cvbs_init(priv); ret = meson_encoder_cvbs_probe(priv);
if (ret) if (ret)
goto exit_afbcd; goto exit_afbcd;
...@@ -326,12 +326,12 @@ static int meson_drv_bind_master(struct device *dev, bool has_components) ...@@ -326,12 +326,12 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
} }
} }
ret = meson_encoder_hdmi_init(priv); ret = meson_encoder_hdmi_probe(priv);
if (ret) if (ret)
goto exit_afbcd; goto exit_afbcd;
if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) { if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
ret = meson_encoder_dsi_init(priv); ret = meson_encoder_dsi_probe(priv);
if (ret) if (ret)
goto exit_afbcd; goto exit_afbcd;
} }
......
...@@ -219,7 +219,7 @@ static const struct drm_bridge_funcs meson_encoder_cvbs_bridge_funcs = { ...@@ -219,7 +219,7 @@ static const struct drm_bridge_funcs meson_encoder_cvbs_bridge_funcs = {
.atomic_reset = drm_atomic_helper_bridge_reset, .atomic_reset = drm_atomic_helper_bridge_reset,
}; };
int meson_encoder_cvbs_init(struct meson_drm *priv) int meson_encoder_cvbs_probe(struct meson_drm *priv)
{ {
struct drm_device *drm = priv->drm; struct drm_device *drm = priv->drm;
struct meson_encoder_cvbs *meson_encoder_cvbs; struct meson_encoder_cvbs *meson_encoder_cvbs;
...@@ -240,10 +240,9 @@ int meson_encoder_cvbs_init(struct meson_drm *priv) ...@@ -240,10 +240,9 @@ int meson_encoder_cvbs_init(struct meson_drm *priv)
meson_encoder_cvbs->next_bridge = of_drm_find_bridge(remote); meson_encoder_cvbs->next_bridge = of_drm_find_bridge(remote);
of_node_put(remote); of_node_put(remote);
if (!meson_encoder_cvbs->next_bridge) { if (!meson_encoder_cvbs->next_bridge)
dev_err(priv->dev, "Failed to find CVBS Connector bridge\n"); return dev_err_probe(priv->dev, -EPROBE_DEFER,
return -EPROBE_DEFER; "Failed to find CVBS Connector bridge\n");
}
/* CVBS Encoder Bridge */ /* CVBS Encoder Bridge */
meson_encoder_cvbs->bridge.funcs = &meson_encoder_cvbs_bridge_funcs; meson_encoder_cvbs->bridge.funcs = &meson_encoder_cvbs_bridge_funcs;
...@@ -259,10 +258,9 @@ int meson_encoder_cvbs_init(struct meson_drm *priv) ...@@ -259,10 +258,9 @@ int meson_encoder_cvbs_init(struct meson_drm *priv)
/* Encoder */ /* Encoder */
ret = drm_simple_encoder_init(priv->drm, &meson_encoder_cvbs->encoder, ret = drm_simple_encoder_init(priv->drm, &meson_encoder_cvbs->encoder,
DRM_MODE_ENCODER_TVDAC); DRM_MODE_ENCODER_TVDAC);
if (ret) { if (ret)
dev_err(priv->dev, "Failed to init CVBS encoder: %d\n", ret); return dev_err_probe(priv->dev, ret,
return ret; "Failed to init CVBS encoder\n");
}
meson_encoder_cvbs->encoder.possible_crtcs = BIT(0); meson_encoder_cvbs->encoder.possible_crtcs = BIT(0);
...@@ -276,10 +274,10 @@ int meson_encoder_cvbs_init(struct meson_drm *priv) ...@@ -276,10 +274,10 @@ int meson_encoder_cvbs_init(struct meson_drm *priv)
/* Initialize & attach Bridge Connector */ /* Initialize & attach Bridge Connector */
connector = drm_bridge_connector_init(priv->drm, &meson_encoder_cvbs->encoder); connector = drm_bridge_connector_init(priv->drm, &meson_encoder_cvbs->encoder);
if (IS_ERR(connector)) { if (IS_ERR(connector))
dev_err(priv->dev, "Unable to create CVBS bridge connector\n"); return dev_err_probe(priv->dev, PTR_ERR(connector),
return PTR_ERR(connector); "Unable to create CVBS bridge connector\n");
}
drm_connector_attach_encoder(connector, &meson_encoder_cvbs->encoder); drm_connector_attach_encoder(connector, &meson_encoder_cvbs->encoder);
priv->encoders[MESON_ENC_CVBS] = meson_encoder_cvbs; priv->encoders[MESON_ENC_CVBS] = meson_encoder_cvbs;
......
...@@ -24,7 +24,7 @@ struct meson_cvbs_mode { ...@@ -24,7 +24,7 @@ struct meson_cvbs_mode {
/* Modes supported by the CVBS output */ /* Modes supported by the CVBS output */
extern struct meson_cvbs_mode meson_cvbs_modes[MESON_CVBS_MODES_COUNT]; extern struct meson_cvbs_mode meson_cvbs_modes[MESON_CVBS_MODES_COUNT];
int meson_encoder_cvbs_init(struct meson_drm *priv); int meson_encoder_cvbs_probe(struct meson_drm *priv);
void meson_encoder_cvbs_remove(struct meson_drm *priv); void meson_encoder_cvbs_remove(struct meson_drm *priv);
#endif /* __MESON_VENC_CVBS_H */ #endif /* __MESON_VENC_CVBS_H */
...@@ -100,7 +100,7 @@ static const struct drm_bridge_funcs meson_encoder_dsi_bridge_funcs = { ...@@ -100,7 +100,7 @@ static const struct drm_bridge_funcs meson_encoder_dsi_bridge_funcs = {
.atomic_reset = drm_atomic_helper_bridge_reset, .atomic_reset = drm_atomic_helper_bridge_reset,
}; };
int meson_encoder_dsi_init(struct meson_drm *priv) int meson_encoder_dsi_probe(struct meson_drm *priv)
{ {
struct meson_encoder_dsi *meson_encoder_dsi; struct meson_encoder_dsi *meson_encoder_dsi;
struct device_node *remote; struct device_node *remote;
...@@ -118,10 +118,9 @@ int meson_encoder_dsi_init(struct meson_drm *priv) ...@@ -118,10 +118,9 @@ int meson_encoder_dsi_init(struct meson_drm *priv)
} }
meson_encoder_dsi->next_bridge = of_drm_find_bridge(remote); meson_encoder_dsi->next_bridge = of_drm_find_bridge(remote);
if (!meson_encoder_dsi->next_bridge) { if (!meson_encoder_dsi->next_bridge)
dev_dbg(priv->dev, "Failed to find DSI transceiver bridge\n"); return dev_err_probe(priv->dev, -EPROBE_DEFER,
return -EPROBE_DEFER; "Failed to find DSI transceiver bridge\n");
}
/* DSI Encoder Bridge */ /* DSI Encoder Bridge */
meson_encoder_dsi->bridge.funcs = &meson_encoder_dsi_bridge_funcs; meson_encoder_dsi->bridge.funcs = &meson_encoder_dsi_bridge_funcs;
...@@ -135,19 +134,17 @@ int meson_encoder_dsi_init(struct meson_drm *priv) ...@@ -135,19 +134,17 @@ int meson_encoder_dsi_init(struct meson_drm *priv)
/* Encoder */ /* Encoder */
ret = drm_simple_encoder_init(priv->drm, &meson_encoder_dsi->encoder, ret = drm_simple_encoder_init(priv->drm, &meson_encoder_dsi->encoder,
DRM_MODE_ENCODER_DSI); DRM_MODE_ENCODER_DSI);
if (ret) { if (ret)
dev_err(priv->dev, "Failed to init DSI encoder: %d\n", ret); return dev_err_probe(priv->dev, ret,
return ret; "Failed to init DSI encoder\n");
}
meson_encoder_dsi->encoder.possible_crtcs = BIT(0); meson_encoder_dsi->encoder.possible_crtcs = BIT(0);
/* Attach DSI Encoder Bridge to Encoder */ /* Attach DSI Encoder Bridge to Encoder */
ret = drm_bridge_attach(&meson_encoder_dsi->encoder, &meson_encoder_dsi->bridge, NULL, 0); ret = drm_bridge_attach(&meson_encoder_dsi->encoder, &meson_encoder_dsi->bridge, NULL, 0);
if (ret) { if (ret)
dev_err(priv->dev, "Failed to attach bridge: %d\n", ret); return dev_err_probe(priv->dev, ret,
return ret; "Failed to attach bridge\n");
}
/* /*
* We should have now in place: * We should have now in place:
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#ifndef __MESON_ENCODER_DSI_H #ifndef __MESON_ENCODER_DSI_H
#define __MESON_ENCODER_DSI_H #define __MESON_ENCODER_DSI_H
int meson_encoder_dsi_init(struct meson_drm *priv); int meson_encoder_dsi_probe(struct meson_drm *priv);
void meson_encoder_dsi_remove(struct meson_drm *priv); void meson_encoder_dsi_remove(struct meson_drm *priv);
#endif /* __MESON_ENCODER_DSI_H */ #endif /* __MESON_ENCODER_DSI_H */
...@@ -366,7 +366,7 @@ static const struct drm_bridge_funcs meson_encoder_hdmi_bridge_funcs = { ...@@ -366,7 +366,7 @@ static const struct drm_bridge_funcs meson_encoder_hdmi_bridge_funcs = {
.atomic_reset = drm_atomic_helper_bridge_reset, .atomic_reset = drm_atomic_helper_bridge_reset,
}; };
int meson_encoder_hdmi_init(struct meson_drm *priv) int meson_encoder_hdmi_probe(struct meson_drm *priv)
{ {
struct meson_encoder_hdmi *meson_encoder_hdmi; struct meson_encoder_hdmi *meson_encoder_hdmi;
struct platform_device *pdev; struct platform_device *pdev;
...@@ -386,8 +386,8 @@ int meson_encoder_hdmi_init(struct meson_drm *priv) ...@@ -386,8 +386,8 @@ int meson_encoder_hdmi_init(struct meson_drm *priv)
meson_encoder_hdmi->next_bridge = of_drm_find_bridge(remote); meson_encoder_hdmi->next_bridge = of_drm_find_bridge(remote);
if (!meson_encoder_hdmi->next_bridge) { if (!meson_encoder_hdmi->next_bridge) {
dev_err(priv->dev, "Failed to find HDMI transceiver bridge\n"); ret = dev_err_probe(priv->dev, -EPROBE_DEFER,
ret = -EPROBE_DEFER; "Failed to find HDMI transceiver bridge\n");
goto err_put_node; goto err_put_node;
} }
...@@ -405,7 +405,7 @@ int meson_encoder_hdmi_init(struct meson_drm *priv) ...@@ -405,7 +405,7 @@ int meson_encoder_hdmi_init(struct meson_drm *priv)
ret = drm_simple_encoder_init(priv->drm, &meson_encoder_hdmi->encoder, ret = drm_simple_encoder_init(priv->drm, &meson_encoder_hdmi->encoder,
DRM_MODE_ENCODER_TMDS); DRM_MODE_ENCODER_TMDS);
if (ret) { if (ret) {
dev_err(priv->dev, "Failed to init HDMI encoder: %d\n", ret); dev_err_probe(priv->dev, ret, "Failed to init HDMI encoder\n");
goto err_put_node; goto err_put_node;
} }
...@@ -415,7 +415,7 @@ int meson_encoder_hdmi_init(struct meson_drm *priv) ...@@ -415,7 +415,7 @@ int meson_encoder_hdmi_init(struct meson_drm *priv)
ret = drm_bridge_attach(&meson_encoder_hdmi->encoder, &meson_encoder_hdmi->bridge, NULL, ret = drm_bridge_attach(&meson_encoder_hdmi->encoder, &meson_encoder_hdmi->bridge, NULL,
DRM_BRIDGE_ATTACH_NO_CONNECTOR); DRM_BRIDGE_ATTACH_NO_CONNECTOR);
if (ret) { if (ret) {
dev_err(priv->dev, "Failed to attach bridge: %d\n", ret); dev_err_probe(priv->dev, ret, "Failed to attach bridge\n");
goto err_put_node; goto err_put_node;
} }
...@@ -423,8 +423,9 @@ int meson_encoder_hdmi_init(struct meson_drm *priv) ...@@ -423,8 +423,9 @@ int meson_encoder_hdmi_init(struct meson_drm *priv)
meson_encoder_hdmi->connector = drm_bridge_connector_init(priv->drm, meson_encoder_hdmi->connector = drm_bridge_connector_init(priv->drm,
&meson_encoder_hdmi->encoder); &meson_encoder_hdmi->encoder);
if (IS_ERR(meson_encoder_hdmi->connector)) { if (IS_ERR(meson_encoder_hdmi->connector)) {
dev_err(priv->dev, "Unable to create HDMI bridge connector\n"); ret = dev_err_probe(priv->dev,
ret = PTR_ERR(meson_encoder_hdmi->connector); PTR_ERR(meson_encoder_hdmi->connector),
"Unable to create HDMI bridge connector\n");
goto err_put_node; goto err_put_node;
} }
drm_connector_attach_encoder(meson_encoder_hdmi->connector, drm_connector_attach_encoder(meson_encoder_hdmi->connector,
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#ifndef __MESON_ENCODER_HDMI_H #ifndef __MESON_ENCODER_HDMI_H
#define __MESON_ENCODER_HDMI_H #define __MESON_ENCODER_HDMI_H
int meson_encoder_hdmi_init(struct meson_drm *priv); int meson_encoder_hdmi_probe(struct meson_drm *priv);
void meson_encoder_hdmi_remove(struct meson_drm *priv); void meson_encoder_hdmi_remove(struct meson_drm *priv);
#endif /* __MESON_ENCODER_HDMI_H */ #endif /* __MESON_ENCODER_HDMI_H */
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