A single error handling block at the end of the function could be brought in to make code a little more concise. Signed-off-by: Cai Huoqing <caihuoqing@xxxxxxxxx> --- drivers/video/backlight/l4f00242t03.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/video/backlight/l4f00242t03.c b/drivers/video/backlight/l4f00242t03.c index 46f97d1c3d21..c6f540f1b507 100644 --- a/drivers/video/backlight/l4f00242t03.c +++ b/drivers/video/backlight/l4f00242t03.c @@ -65,14 +65,12 @@ static void l4f00242t03_lcd_init(struct spi_device *spi) ret = regulator_set_voltage(priv->core_reg, 2800000, 2800000); if (ret) { dev_err(&spi->dev, "failed to set the core regulator voltage.\n"); - regulator_disable(priv->io_reg); - return; + goto err_disable_reg; } ret = regulator_enable(priv->core_reg); if (ret) { dev_err(&spi->dev, "failed to enable the core regulator.\n"); - regulator_disable(priv->io_reg); - return; + goto err_disable_reg; } l4f00242t03_reset(priv->reset); @@ -80,6 +78,10 @@ static void l4f00242t03_lcd_init(struct spi_device *spi) gpiod_set_value(priv->enable, 1); msleep(60); spi_write(spi, (const u8 *)cmd, ARRAY_SIZE(cmd) * sizeof(u16)); + return; + +err_disable_reg: + regulator_disable(priv->io_reg); } static void l4f00242t03_lcd_powerdown(struct spi_device *spi) -- 2.25.1