Re: [PATCH v5 10/13] drm/bridge: tc358762: Move tc358762_init() into tc358762_enable()
From: Andreas Kemnade
Date: Mon Nov 16 2026 - 04:05:54 EST
On Thu, 15 Oct 2026 14:16:01 +0300
Tomi Valkeinen <tomi.valkeinen@xxxxxxxxxxxxxxxx> wrote:
> The only thing tc358762_enable() does is call tc358762_init(). Inline
> the tc358762_init() into tc358762_enable(), for simplicity and to make
> it easier to improve the tc358762_enable() in the following commits. No
> functional change.
>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@xxxxxxxxxxxxxxxx>
Reviewed-by: Andreas Kemnade <andreas@xxxxxxxxxxxx>
> ---
> drivers/gpu/drm/bridge/tc358762.c | 104 ++++++++++++++++++--------------------
> 1 file changed, 49 insertions(+), 55 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/tc358762.c b/drivers/gpu/drm/bridge/tc358762.c
> index 2baacef685a5..a91cf159ba27 100644
> --- a/drivers/gpu/drm/bridge/tc358762.c
> +++ b/drivers/gpu/drm/bridge/tc358762.c
> @@ -138,9 +138,56 @@ static inline struct tc358762 *bridge_to_tc358762(struct drm_bridge *bridge)
> return container_of(bridge, struct tc358762, bridge);
> }
>
> -static int tc358762_init(struct tc358762 *ctx)
> +static void tc358762_post_disable(struct drm_bridge *bridge,
> + struct drm_atomic_commit *state)
> +{
> + struct tc358762 *ctx = bridge_to_tc358762(bridge);
> + int ret;
> +
> + /*
> + * The post_disable hook might be called multiple times.
> + * We want to avoid regulator imbalance below.
> + */
> + if (!ctx->pre_enabled)
> + return;
> +
> + ctx->pre_enabled = false;
> +
> + /* Turn off the DPI output */
> + tc358762_write(ctx, LCDCTRL, 0);
> +
> + if (ctx->reset_gpio)
> + gpiod_set_value_cansleep(ctx->reset_gpio, 0);
> +
> + ret = regulator_disable(ctx->regulator);
> + if (ret < 0)
> + dev_err(ctx->dev, "error disabling regulators (%d)\n", ret);
> +}
> +
> +static void tc358762_pre_enable(struct drm_bridge *bridge,
> + struct drm_atomic_commit *state)
> {
> + struct tc358762 *ctx = bridge_to_tc358762(bridge);
> + int ret;
> +
> + ret = regulator_enable(ctx->regulator);
> + if (ret < 0)
> + dev_err(ctx->dev, "error enabling regulators (%d)\n", ret);
> +
> + if (ctx->reset_gpio) {
> + gpiod_set_value_cansleep(ctx->reset_gpio, 1);
> + usleep_range(5000, 10000);
> + }
> +
> + ctx->pre_enabled = true;
> +}
> +
> +static void tc358762_enable(struct drm_bridge *bridge,
> + struct drm_atomic_commit *state)
> +{
> + struct tc358762 *ctx = bridge_to_tc358762(bridge);
> u32 lcdctrl;
> + int ret;
>
> /*
> * DPIENABLE has reset default of 1. Make sure we don't output on
> @@ -203,60 +250,7 @@ static int tc358762_init(struct tc358762 *ctx)
>
> msleep(100);
>
> - return tc358762_clear_error(ctx);
> -}
> -
> -static void tc358762_post_disable(struct drm_bridge *bridge,
> - struct drm_atomic_commit *state)
> -{
> - struct tc358762 *ctx = bridge_to_tc358762(bridge);
> - int ret;
> -
> - /*
> - * The post_disable hook might be called multiple times.
> - * We want to avoid regulator imbalance below.
> - */
> - if (!ctx->pre_enabled)
> - return;
> -
> - ctx->pre_enabled = false;
> -
> - /* Turn off the DPI output */
> - tc358762_write(ctx, LCDCTRL, 0);
> -
> - if (ctx->reset_gpio)
> - gpiod_set_value_cansleep(ctx->reset_gpio, 0);
> -
> - ret = regulator_disable(ctx->regulator);
> - if (ret < 0)
> - dev_err(ctx->dev, "error disabling regulators (%d)\n", ret);
> -}
> -
> -static void tc358762_pre_enable(struct drm_bridge *bridge,
> - struct drm_atomic_commit *state)
> -{
> - struct tc358762 *ctx = bridge_to_tc358762(bridge);
> - int ret;
> -
> - ret = regulator_enable(ctx->regulator);
> - if (ret < 0)
> - dev_err(ctx->dev, "error enabling regulators (%d)\n", ret);
> -
> - if (ctx->reset_gpio) {
> - gpiod_set_value_cansleep(ctx->reset_gpio, 1);
> - usleep_range(5000, 10000);
> - }
> -
> - ctx->pre_enabled = true;
> -}
> -
> -static void tc358762_enable(struct drm_bridge *bridge,
> - struct drm_atomic_commit *state)
> -{
> - struct tc358762 *ctx = bridge_to_tc358762(bridge);
> - int ret;
> -
> - ret = tc358762_init(ctx);
> + ret = tc358762_clear_error(ctx);
> if (ret < 0)
> dev_err(ctx->dev, "error initializing bridge (%d)\n", ret);
> }
>