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 <[email protected]> --- 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 5d6092e1d190..89c02b2e6832 100644 --- a/drivers/gpu/drm/bridge/tc358762.c +++ b/drivers/gpu/drm/bridge/tc358762.c @@ -139,9 +139,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_state *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_state *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_state *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 @@ -204,60 +251,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_state *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_state *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_state *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); } -- 2.43.0
