diff mbox

treewide: compress lines for immediate return

Message ID 1472812610-31539-1-git-send-email-yamada.masahiro@socionext.com
State New
Headers show

Commit Message

Masahiro Yamada Sept. 2, 2016, 10:36 a.m. UTC
-ret = expression;
  -if (ret)
  -        return ret;
  -return 0;
  +return expression;

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

---

 arch/arm/cpu/armv7/bcm235xx/clk-bsc.c           |  6 +-----
 arch/arm/cpu/armv7/bcm281xx/clk-bsc.c           |  6 +-----
 arch/arm/mach-rockchip/rk3288/sdram_rk3288.c    | 11 ++++------
 arch/arm/mach-uniphier/dram/umc-ld20.c          |  6 +-----
 arch/powerpc/lib/bootm.c                        |  6 +-----
 arch/x86/cpu/baytrail/valleyview.c              |  8 +------
 arch/x86/cpu/broadwell/cpu.c                    |  6 +-----
 arch/x86/cpu/broadwell/sata.c                   |  7 +------
 arch/x86/cpu/ivybridge/bd82x6x.c                |  6 +-----
 arch/x86/cpu/ivybridge/cpu.c                    |  6 +-----
 arch/x86/cpu/ivybridge/gma.c                    |  6 +-----
 arch/x86/cpu/ivybridge/ivybridge.c              |  8 +------
 arch/x86/cpu/qemu/qemu.c                        |  8 +------
 arch/x86/cpu/queensbay/tnc.c                    | 14 ++-----------
 board/compulab/cm_fx6/cm_fx6.c                  |  6 +-----
 board/freescale/common/fsl_validate.c           |  6 +-----
 board/freescale/mx6qsabreauto/mx6qsabreauto.c   | 11 +++-------
 board/freescale/mx6sxsabreauto/mx6sxsabreauto.c | 11 +++-------
 board/keymile/km_arm/fpga_config.c              | 14 ++-----------
 board/kosagi/novena/novena.c                    |  6 +-----
 board/samsung/goni/goni.c                       |  8 +------
 board/ti/common/board_detect.c                  |  6 +-----
 drivers/adc/adc-uclass.c                        | 12 ++---------
 drivers/core/root.c                             | 12 ++---------
 drivers/dfu/dfu_sf.c                            |  8 ++-----
 drivers/gpio/74x164_gpio.c                      |  7 +------
 drivers/gpio/axp_gpio.c                         |  6 +-----
 drivers/misc/cros_ec.c                          |  6 +-----
 drivers/misc/pca9551_led.c                      | 13 ++----------
 drivers/misc/tegra186_bpmp.c                    |  6 +-----
 drivers/mmc/atmel_sdhci.c                       |  7 +------
 drivers/mmc/davinci_mmc.c                       |  6 +-----
 drivers/mmc/exynos_dw_mmc.c                     |  7 +------
 drivers/mmc/mmc-uclass.c                        |  7 +------
 drivers/mmc/mmc_boot.c                          | 28 +++++++------------------
 drivers/mmc/mmc_legacy.c                        |  7 +------
 drivers/mmc/msm_sdhci.c                         |  7 +------
 drivers/mmc/mxcmmc.c                            |  6 +-----
 drivers/mmc/pxa_mmc_gen.c                       | 21 +++----------------
 drivers/mmc/rockchip_dw_mmc.c                   |  7 +------
 drivers/mmc/rockchip_sdhci.c                    |  7 +------
 drivers/mmc/sandbox_mmc.c                       |  7 +------
 drivers/mmc/zynq_sdhci.c                        |  7 +------
 drivers/mtd/nand/fsl_elbc_nand.c                |  6 +-----
 drivers/mtd/nand/fsl_ifc_nand.c                 |  5 +----
 drivers/mtd/nand/tegra_nand.c                   |  6 +-----
 drivers/mtd/nand/vf610_nfc.c                    |  6 +-----
 drivers/mtd/ubi/attach.c                        | 14 ++++---------
 drivers/net/fm/eth.c                            |  6 +-----
 drivers/net/mvpp2.c                             | 16 ++++----------
 drivers/net/phy/mv88e6352.c                     |  6 +-----
 drivers/net/xilinx_emaclite.c                   |  7 +------
 drivers/pci/pcie_imx.c                          | 12 ++---------
 drivers/power/axp809.c                          |  8 +------
 drivers/rtc/i2c_rtc_emul.c                      | 13 ++----------
 drivers/usb/host/ehci-atmel.c                   |  8 +------
 drivers/usb/host/ehci-fsl.c                     |  8 +------
 drivers/usb/host/ehci-marvell.c                 |  8 +------
 drivers/usb/host/ehci-mx6.c                     |  8 +------
 drivers/usb/host/ehci-pci.c                     |  8 +------
 drivers/usb/host/ehci-zynq.c                    |  8 +------
 drivers/usb/host/xhci-fsl.c                     |  7 +------
 drivers/usb/ulpi/ulpi.c                         |  6 +-----
 drivers/video/bridge/ptn3460.c                  |  8 +------
 drivers/video/rockchip/rk_edp.c                 |  6 +-----
 drivers/video/simple_panel.c                    |  7 +------
 drivers/video/tegra124/display.c                |  8 +------
 drivers/video/vidconsole-uclass.c               |  7 +------
 fs/ubifs/budget.c                               |  7 ++-----
 fs/ubifs/gc.c                                   |  5 +----
 fs/ubifs/lpt_commit.c                           |  5 +----
 fs/ubifs/ubifs.c                                |  6 +-----
 lib/libfdt/fdt_rw.c                             |  6 +-----
 lib/rsa/rsa-checksum.c                          |  6 +-----
 lib/tpm.c                                       |  7 +------
 tools/mxsimage.c                                |  6 +-----
 76 files changed, 107 insertions(+), 509 deletions(-)

-- 
1.9.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Comments

Masahiro Yamada Sept. 2, 2016, 1:09 p.m. UTC | #1
2016-09-02 20:58 GMT+09:00 Marek Vasut <marex@denx.de>:
> On 09/02/2016 12:36 PM, Masahiro Yamada wrote:

>>   -ret = expression;

>>   -if (ret)

>>   -        return ret;

>>   -return 0;

>>   +return expression;

>>

>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

>> ---

>

> The thing I miss in the commit message is -- why is this change

> beneficial/needed ?

>


I thought the benefit was apparent.

Wasn't it to you?



-- 
Best Regards
Masahiro Yamada
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Masahiro Yamada Sept. 3, 2016, 11:38 p.m. UTC | #2
2016-09-02 23:12 GMT+09:00 Marek Vasut <marex@denx.de>:
> On 09/02/2016 03:09 PM, Masahiro Yamada wrote:

>> 2016-09-02 20:58 GMT+09:00 Marek Vasut <marex@denx.de>:

>>> On 09/02/2016 12:36 PM, Masahiro Yamada wrote:

>>>>   -ret = expression;

>>>>   -if (ret)

>>>>   -        return ret;

>>>>   -return 0;

>>>>   +return expression;

>>>>

>>>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

>>>> ---

>>>

>>> The thing I miss in the commit message is -- why is this change

>>> beneficial/needed ?

>>>

>>

>> I thought the benefit was apparent.

>>

>> Wasn't it to you?

>

> Nope, please explain.

>


This is a cleanup patch; it removes
unneeded variable assignments, if conditionals.



-- 
Best Regards
Masahiro Yamada
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Masahiro Yamada Sept. 3, 2016, 11:38 p.m. UTC | #3
2016-09-03 2:15 GMT+09:00 Stephen Warren <swarren@wwwdotorg.org>:
> On 09/02/2016 04:36 AM, Masahiro Yamada wrote:

>>

>>   -ret = expression;

>>   -if (ret)

>>   -        return ret;

>>   -return 0;

>>   +return expression;

>

>

> I disagree with this change if applied blindly; I think both coding styles

> have their merit depending on the semantic context.

>

> In the case of a simple wrapper function that just calls another with

> different arguments, directly returning the result from the called function

> make sense. For example:

>

>> int device_bind(struct udevice *parent, const struct driver *drv,

>>                 const char *name, void *platdata, int of_offset,

>>                 struct udevice **devp)

>> {

>>         return device_bind_common(parent, drv, name, platdata, 0,

>> of_offset, 0,

>>                                   devp);

>> }

>

>

> However, where the top-level function is more complex, especially where it

> calls multiple functions in its body, I think it's best to use the exact

> same style to call all functions in the top-level body, and just "return 0"

> separately at the end. For example:

>

>> static int tegra186_bpmp_bind(struct udevice *dev)

>> {

>>         int ret;

>>         struct udevice *child;

>>

>>         debug("%s(dev=%p)\n", __func__, dev);

>>

>>         ret = device_bind_driver_to_node(dev, "tegra186_clk",

>> "tegra186_clk",

>>                                          dev->of_offset, &child);

>>         if (ret)

>>                 return ret;

>>

>>         ret = device_bind_driver_to_node(dev, "tegra186_reset",

>>                                          "tegra186_reset", dev->of_offset,

>>                                          &child);

>>         if (ret)

>>                 return ret;

>>

>>         ret = device_bind_driver_to_node(dev, "tegra186_power_domain",

>>                                          "tegra186_power_domain",

>>                                          dev->of_offset, &child);

>>         if (ret)

>>                 return ret;

>>

>>         ret = dm_scan_fdt_dev(dev);

>>         if (ret)

>>                 return ret;

>>

>>         return 0;

>> }

>

>

> All child function calls are structured the same, so someone reading the

> code will always see the same structure irrespective of where in a function

> a child function is called. This gives uniformity. This also yields a few

> maintenance advantages below, and helps keep all code uniform even if any of

> the maintenance operations below have been applied to some functions and

> aren't needed in others.






Did you think I ran a semantic patch with Coccinelle
and then sent it blindly?

No, this patch passed my eyes' check, at least.


Please notice this patch did not transform
the following function in arch/arm/cpu/armv7/am33xx/clk_synthesizer.c


int setup_clock_synthesizer(struct clk_synth *data)
{
        int rc;
        uint8_t val;

        rc =  i2c_probe(CLK_SYNTHESIZER_I2C_ADDR);
        if (rc) {
                printf("i2c probe failed at address 0x%x\n",
                       CLK_SYNTHESIZER_I2C_ADDR);
                return rc;
        }

        rc = clk_synthesizer_reg_read(CLK_SYNTHESIZER_ID_REG, &val);
        if (val != data->id)
                return rc;

        /* Crystal Load capacitor selection */
        rc = clk_synthesizer_reg_write(CLK_SYNTHESIZER_XCSEL, data->capacitor);
        if (rc)
                return rc;
        rc = clk_synthesizer_reg_write(CLK_SYNTHESIZER_MUX_REG, data->mux);
        if (rc)
                return rc;
        rc = clk_synthesizer_reg_write(CLK_SYNTHESIZER_PDIV2_REG, data->pdiv2);
        if (rc)
                return rc;
        rc = clk_synthesizer_reg_write(CLK_SYNTHESIZER_PDIV3_REG, data->pdiv3);
        if (rc)
                return rc;

        return 0;
}



We can transform this function if we like
but it would badly break the uniformity.
So, I did not.

So, I agree your statement to some extent.


I guess the matter is, where we should draw a line.
What is uniform and what is not uniform?



If you want to stick to the safest side,
a semantic patch like follows would do the job.

 @@
 type t;
 expression e;
 identifier ret;
 @@
 -   t ret;
 -   ret = e;
 -   if (ret)
 -       return ret;
 -   return 0;
 +
 +   return e;



> 1)

>

> If tegra186_bpmp_bind() were modified to call an additional function in its

> body, the diff for that addition would look identical no matter whether the

> new call was added at the start/middle/end of the body. We wouldn't ever

> have to do something like:

>

> -       return dm_scan_fdt_dev(dev);

> +       ret = dm_scan_fdt_dev(dev);

> +       if (ret)

> +               return ret;

>

> ... which is an edit to a piece of code that's unrelated to the code being

> added, and thus makes the patch more confusing.

>

> 2)

>

> There's always an obvious place to put any debug()/error() invocations, or

> translate return values; inside the if (ret) body. There's only one way for

> the code to look so it doesn't change based on what exactly we do with the

> return value.

>

> 3)

>

> If we add the need for cleanup logic in the failure case, we can just

> blindly change "return ret" to "goto fail" without re-structuring code.



I am not sure if 2) and 3) are realistic.

If we start to consider things that may happen or may not happen,
we end up with adding redundancy all the time.



Are you positive or negative for the following hunk?


> diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c

> index f621f14..b27a6af 100644

> --- a/drivers/mtd/nand/fsl_elbc_nand.c

> +++ b/drivers/mtd/nand/fsl_elbc_nand.c

> @@ -788,11 +788,7 @@ static int fsl_elbc_chip_init(int devnum, u8 *addr)

>         if (ret)

>                 return ret;

>

> -       ret = nand_register(devnum, mtd);

> -       if (ret)

> -               return ret;

> -

> -       return 0;

> +       return nand_register(devnum, mtd);

>  }


I think probe/init function can return a value
of register function directly, from my best common sense.

This change will lose 2)
in case fsl_elbc_chip_init() fails to do nand_register, though.



-- 
Best Regards
Masahiro Yamada
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Masahiro Yamada Sept. 7, 2016, 12:56 a.m. UTC | #4
Hi Stefano,

2016-09-06 18:25 GMT+09:00 Stefano Babic <sbabic@denx.de>:

>

> Nothing against, but it looks to me just a different and allowed coding

> style - where is the advantages of this ?

>


This had already been superseded.
Please check v3, where I mostly transformed
simple wrapper functions only.


-- 
Best Regards
Masahiro Yamada
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Masahiro Yamada Sept. 7, 2016, 1:14 a.m. UTC | #5
Hi Stephen,

2016-09-07 1:09 GMT+09:00 Stephen Warren <swarren@wwwdotorg.org>:

>>> All child function calls are structured the same, so someone reading the

>>> code will always see the same structure irrespective of where in a

>>> function

>>> a child function is called. This gives uniformity. This also yields a few

>>> maintenance advantages below, and helps keep all code uniform even if any

>>> of

>>> the maintenance operations below have been applied to some functions and

>>> aren't needed in others.

>>

>>

>>

>> Did you think I ran a semantic patch with Coccinelle

>> and then sent it blindly?

>>

>> No, this patch passed my eyes' check, at least.

>>

>> Please notice this patch did not transform

>> the following function in arch/arm/cpu/armv7/am33xx/clk_synthesizer.c

>

> ...

>

> The patch description clearly stated that the patch was purely the result of

> applying the Coccinelle script. If there were exceptions or other edits,

> they should have been explicitly mentioned too.


Right.
The git-log implied a semantic patch, but I did not mention that
I sent the output of Coccinelle as is.

Actually, I cherry-picked reasonable hunks.

Coccinelle may sometimes do false positive jobs (or undesirable output
like this case),
so I think "Coccinelle + checking by eyes" is a good practice.


I dropped a semantic patch snippet from v3 git-log.



>> If we start to consider things that may happen or may not happen,

>> we end up with adding redundancy all the time.

>>

>> Are you positive or negative for the following hunk?

>>

>>> diff --git a/drivers/mtd/nand/fsl_elbc_nand.c

>>> b/drivers/mtd/nand/fsl_elbc_nand.c

>>> index f621f14..b27a6af 100644

>>> --- a/drivers/mtd/nand/fsl_elbc_nand.c

>>> +++ b/drivers/mtd/nand/fsl_elbc_nand.c

>>> @@ -788,11 +788,7 @@ static int fsl_elbc_chip_init(int devnum, u8 *addr)

>>>         if (ret)

>>>                 return ret;

>>>

>>> -       ret = nand_register(devnum, mtd);

>>> -       if (ret)

>>> -               return ret;

>>> -

>>> -       return 0;

>>> +       return nand_register(devnum, mtd);

>>>  }

>

>

> I'd probably tend not to do that particular conversion, for consistency with

> the immediately preceding nand_scan_tail() case. Still, this one isn't such

> an obvious call so I wouldn't feel particularly strongly about it,

> especially as it isn't a driver I work on.

>

>> I think probe/init function can return a value

>> of register function directly, from my best common sense.

>>

>> This change will lose 2)

>> in case fsl_elbc_chip_init() fails to do nand_register, though.


OK.  I dropped those changes in v2.

(I still personally believe "return *_register();" is good coding style, though.
This might be a matter of preference...)


In v3, I only fixed drivers/video/vidconsole-uclass.c
because I thought it is simple enough.
http://patchwork.ozlabs.org/patch/666560/

and it was acked by Anatolij.




-- 
Best Regards
Masahiro Yamada
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
diff mbox

Patch

diff --git a/arch/arm/cpu/armv7/bcm235xx/clk-bsc.c b/arch/arm/cpu/armv7/bcm235xx/clk-bsc.c
index d263068..328a63f 100644
--- a/arch/arm/cpu/armv7/bcm235xx/clk-bsc.c
+++ b/arch/arm/cpu/armv7/bcm235xx/clk-bsc.c
@@ -44,9 +44,5 @@  int clk_bsc_enable(void *base)
 	if (ret)
 		return ret;
 
-	ret = clk_get_and_enable(bscstr);
-	if (ret)
-		return ret;
-
-	return 0;
+	return clk_get_and_enable(bscstr);
 }
diff --git a/arch/arm/cpu/armv7/bcm281xx/clk-bsc.c b/arch/arm/cpu/armv7/bcm281xx/clk-bsc.c
index ba55d0a..777ea21 100644
--- a/arch/arm/cpu/armv7/bcm281xx/clk-bsc.c
+++ b/arch/arm/cpu/armv7/bcm281xx/clk-bsc.c
@@ -44,9 +44,5 @@  int clk_bsc_enable(void *base)
 	if (ret)
 		return ret;
 
-	ret = clk_get_and_enable(bscstr);
-	if (ret)
-		return ret;
-
-	return 0;
+	return clk_get_and_enable(bscstr);
 }
diff --git a/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c b/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c
index cf9ef2e..2b77646 100644
--- a/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c
+++ b/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c
@@ -869,7 +869,7 @@  static int conv_of_platdata(struct udevice *dev)
 {
 	struct rk3288_sdram_params *plat = dev_get_platdata(dev);
 	struct dtd_rockchip_rk3288_dmc *of_plat = &plat->of_plat;
-	int i, ret;
+	int i;
 
 	for (i = 0; i < 2; i++) {
 		memcpy(&plat->ch[i], of_plat->rockchip_sdram_channel,
@@ -881,13 +881,10 @@  static int conv_of_platdata(struct udevice *dev)
 	       sizeof(plat->phy_timing));
 	memcpy(&plat->base, of_plat->rockchip_sdram_params, sizeof(plat->base));
 	plat->num_channels = of_plat->rockchip_num_channels;
-	ret = regmap_init_mem_platdata(dev, of_plat->reg,
-				       ARRAY_SIZE(of_plat->reg) / 2,
-				       &plat->map);
-	if (ret)
-		return ret;
 
-	return 0;
+	return regmap_init_mem_platdata(dev, of_plat->reg,
+					ARRAY_SIZE(of_plat->reg) / 2,
+					&plat->map);
 }
 #endif
 
diff --git a/arch/arm/mach-uniphier/dram/umc-ld20.c b/arch/arm/mach-uniphier/dram/umc-ld20.c
index 186a398..00032c2 100644
--- a/arch/arm/mach-uniphier/dram/umc-ld20.c
+++ b/arch/arm/mach-uniphier/dram/umc-ld20.c
@@ -246,11 +246,7 @@  static int umc_ch_init(void __iomem *umc_ch_base, void __iomem *phy_ch_base,
 	if (ret)
 		return ret;
 
-	ret = ddrphy_training(phy_base);
-	if (ret)
-		return ret;
-
-	return 0;
+	return ddrphy_training(phy_base);
 }
 
 static void um_init(void __iomem *um_base)
diff --git a/arch/powerpc/lib/bootm.c b/arch/powerpc/lib/bootm.c
index ef15e7a..fb83b59 100644
--- a/arch/powerpc/lib/bootm.c
+++ b/arch/powerpc/lib/bootm.c
@@ -220,11 +220,7 @@  static int boot_body_linux(bootm_headers_t *images)
 	if (ret)
 		return ret;
 
-	ret = image_setup_linux(images);
-	if (ret)
-		return ret;
-
-	return 0;
+	return image_setup_linux(images);
 }
 
 noinline
diff --git a/arch/x86/cpu/baytrail/valleyview.c b/arch/x86/cpu/baytrail/valleyview.c
index b31f24e..b312d9f 100644
--- a/arch/x86/cpu/baytrail/valleyview.c
+++ b/arch/x86/cpu/baytrail/valleyview.c
@@ -25,15 +25,9 @@  int cpu_mmc_init(bd_t *bis)
 #ifndef CONFIG_EFI_APP
 int arch_cpu_init(void)
 {
-	int ret;
-
 	post_code(POST_CPU_INIT);
 
-	ret = x86_cpu_init_f();
-	if (ret)
-		return ret;
-
-	return 0;
+	return x86_cpu_init_f();
 }
 
 int arch_misc_init(void)
diff --git a/arch/x86/cpu/broadwell/cpu.c b/arch/x86/cpu/broadwell/cpu.c
index 3ba21aa..813ca54 100644
--- a/arch/x86/cpu/broadwell/cpu.c
+++ b/arch/x86/cpu/broadwell/cpu.c
@@ -93,11 +93,7 @@  int arch_cpu_init_dm(void)
 		return ret;
 	if (!dev)
 		return -ENODEV;
-	ret = cpu_set_flex_ratio_to_tdp_nominal();
-	if (ret)
-		return ret;
-
-	return 0;
+	return cpu_set_flex_ratio_to_tdp_nominal();
 }
 
 void set_max_freq(void)
diff --git a/arch/x86/cpu/broadwell/sata.c b/arch/x86/cpu/broadwell/sata.c
index 2e47082..e2cfcad 100644
--- a/arch/x86/cpu/broadwell/sata.c
+++ b/arch/x86/cpu/broadwell/sata.c
@@ -213,7 +213,6 @@  static int broadwell_sata_enable(struct udevice *dev)
 	struct sata_platdata *plat = dev_get_platdata(dev);
 	struct gpio_desc desc;
 	u16 map;
-	int ret;
 
 	/*
 	 * Set SATA controller mode early so the resource allocator can
@@ -224,11 +223,7 @@  static int broadwell_sata_enable(struct udevice *dev)
 	map |= (plat->port_map ^ 0x3f) << 8;
 	dm_pci_write_config16(dev, 0x90, map);
 
-	ret = gpio_request_by_name(dev, "reset-gpio", 0, &desc, GPIOD_IS_OUT);
-	if (ret)
-		return ret;
-
-	return 0;
+	return gpio_request_by_name(dev, "reset-gpio", 0, &desc, GPIOD_IS_OUT);
 }
 
 static int broadwell_sata_ofdata_to_platdata(struct udevice *dev)
diff --git a/arch/x86/cpu/ivybridge/bd82x6x.c b/arch/x86/cpu/ivybridge/bd82x6x.c
index 5b58d6c..fce8295 100644
--- a/arch/x86/cpu/ivybridge/bd82x6x.c
+++ b/arch/x86/cpu/ivybridge/bd82x6x.c
@@ -167,11 +167,7 @@  static int bd82x6x_probe(struct udevice *dev)
 	ret = syscon_get_by_driver_data(X86_SYSCON_GMA, &gma_dev);
 	if (ret)
 		return ret;
-	ret = gma_func0_init(gma_dev);
-	if (ret)
-		return ret;
-
-	return 0;
+	return gma_func0_init(gma_dev);
 }
 #endif /* CONFIG_HAVE_FSP */
 
diff --git a/arch/x86/cpu/ivybridge/cpu.c b/arch/x86/cpu/ivybridge/cpu.c
index 85e361a..ddee237 100644
--- a/arch/x86/cpu/ivybridge/cpu.c
+++ b/arch/x86/cpu/ivybridge/cpu.c
@@ -76,11 +76,7 @@  int arch_cpu_init_dm(void)
 	 * up. Perhaps this should move to later. Our next lot of init
 	 * happens in print_cpuinfo() when we have a console
 	 */
-	ret = set_flex_ratio_to_tdp_nominal();
-	if (ret)
-		return ret;
-
-	return 0;
+	return set_flex_ratio_to_tdp_nominal();
 }
 
 #define PCH_EHCI0_TEMP_BAR0 0xe8000000
diff --git a/arch/x86/cpu/ivybridge/gma.c b/arch/x86/cpu/ivybridge/gma.c
index 37e2e6e..aafd76b 100644
--- a/arch/x86/cpu/ivybridge/gma.c
+++ b/arch/x86/cpu/ivybridge/gma.c
@@ -842,9 +842,5 @@  int gma_func0_init(struct udevice *dev)
 	debug("BIOS ran in %lums\n", get_timer(start));
 #endif
 	/* Post VBIOS init */
-	ret = gma_pm_init_post_vbios(dev, rev, gtt_bar);
-	if (ret)
-		return ret;
-
-	return 0;
+	return gma_pm_init_post_vbios(dev, rev, gtt_bar);
 }
diff --git a/arch/x86/cpu/ivybridge/ivybridge.c b/arch/x86/cpu/ivybridge/ivybridge.c
index c770b53..e817eb9 100644
--- a/arch/x86/cpu/ivybridge/ivybridge.c
+++ b/arch/x86/cpu/ivybridge/ivybridge.c
@@ -10,13 +10,7 @@ 
 
 int arch_cpu_init(void)
 {
-	int ret;
-
 	post_code(POST_CPU_INIT);
 
-	ret = x86_cpu_init_f();
-	if (ret)
-		return ret;
-
-	return 0;
+	return x86_cpu_init_f();
 }
diff --git a/arch/x86/cpu/qemu/qemu.c b/arch/x86/cpu/qemu/qemu.c
index 680e558..c3092f2 100644
--- a/arch/x86/cpu/qemu/qemu.c
+++ b/arch/x86/cpu/qemu/qemu.c
@@ -139,15 +139,9 @@  static void qemu_chipset_init(void)
 
 int arch_cpu_init(void)
 {
-	int ret;
-
 	post_code(POST_CPU_INIT);
 
-	ret = x86_cpu_init_f();
-	if (ret)
-		return ret;
-
-	return 0;
+	return x86_cpu_init_f();
 }
 
 #ifndef CONFIG_EFI_STUB
diff --git a/arch/x86/cpu/queensbay/tnc.c b/arch/x86/cpu/queensbay/tnc.c
index b226e4c..16ff75e 100644
--- a/arch/x86/cpu/queensbay/tnc.c
+++ b/arch/x86/cpu/queensbay/tnc.c
@@ -85,24 +85,14 @@  static int __maybe_unused disable_igd(void)
 	ret = device_remove(sdvo);
 	if (ret)
 		return ret;
-	ret = device_unbind(sdvo);
-	if (ret)
-		return ret;
-
-	return 0;
+	return device_unbind(sdvo);
 }
 
 int arch_cpu_init(void)
 {
-	int ret;
-
 	post_code(POST_CPU_INIT);
 
-	ret = x86_cpu_init_f();
-	if (ret)
-		return ret;
-
-	return 0;
+	return x86_cpu_init_f();
 }
 
 int arch_early_init_r(void)
diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c
index 566c19b..a244a60 100644
--- a/board/compulab/cm_fx6/cm_fx6.c
+++ b/board/compulab/cm_fx6/cm_fx6.c
@@ -198,11 +198,7 @@  static int cm_fx6_setup_issd(void)
 			return ret;
 	}
 
-	ret = gpio_request(CM_FX6_SATA_PWLOSS_INT, "sata_pwloss_int");
-	if (ret)
-		return ret;
-
-	return 0;
+	return gpio_request(CM_FX6_SATA_PWLOSS_INT, "sata_pwloss_int");
 }
 
 #define CM_FX6_SATA_INIT_RETRIES	10
diff --git a/board/freescale/common/fsl_validate.c b/board/freescale/common/fsl_validate.c
index 8c171b1..e652cc7 100644
--- a/board/freescale/common/fsl_validate.c
+++ b/board/freescale/common/fsl_validate.c
@@ -575,11 +575,7 @@  static int calc_esbchdr_esbc_hash(struct fsl_secboot_img_priv *img)
 		return ret;
 
 	/* Copy hash at destination buffer */
-	ret = algo->hash_finish(algo, ctx, hash_val, algo->digest_size);
-	if (ret)
-		return ret;
-
-	return 0;
+	return algo->hash_finish(algo, ctx, hash_val, algo->digest_size);
 }
 
 /*
diff --git a/board/freescale/mx6qsabreauto/mx6qsabreauto.c b/board/freescale/mx6qsabreauto/mx6qsabreauto.c
index a3ed4cd..1802bc5 100644
--- a/board/freescale/mx6qsabreauto/mx6qsabreauto.c
+++ b/board/freescale/mx6qsabreauto/mx6qsabreauto.c
@@ -161,14 +161,9 @@  static int port_exp_direction_output(unsigned gpio, int value)
 	if (ret)
 		return ret;
 
-	ret = pca953x_set_val(PORTEXP_IO_TO_CHIP(gpio),
-		(1 << PORTEXP_IO_TO_PIN(gpio)),
-		(value << PORTEXP_IO_TO_PIN(gpio)));
-
-	if (ret)
-		return ret;
-
-	return 0;
+	return pca953x_set_val(PORTEXP_IO_TO_CHIP(gpio),
+			       1 << PORTEXP_IO_TO_PIN(gpio),
+			       value << PORTEXP_IO_TO_PIN(gpio));
 }
 
 static iomux_v3_cfg_t const eimnor_pads[] = {
diff --git a/board/freescale/mx6sxsabreauto/mx6sxsabreauto.c b/board/freescale/mx6sxsabreauto/mx6sxsabreauto.c
index 44e6a7d..0a81c28 100644
--- a/board/freescale/mx6sxsabreauto/mx6sxsabreauto.c
+++ b/board/freescale/mx6sxsabreauto/mx6sxsabreauto.c
@@ -94,14 +94,9 @@  static int port_exp_direction_output(unsigned gpio, int value)
 	if (ret)
 		return ret;
 
-	ret = pca953x_set_val(PORTEXP_IO_TO_CHIP(gpio),
-		(1 << PORTEXP_IO_TO_PIN(gpio)),
-		(value << PORTEXP_IO_TO_PIN(gpio)));
-
-	if (ret)
-		return ret;
-
-	return 0;
+	return pca953x_set_val(PORTEXP_IO_TO_CHIP(gpio),
+			       1 << PORTEXP_IO_TO_PIN(gpio),
+			       value << PORTEXP_IO_TO_PIN(gpio));
 }
 
 int dram_init(void)
diff --git a/board/keymile/km_arm/fpga_config.c b/board/keymile/km_arm/fpga_config.c
index 51a3cfe..301e084 100644
--- a/board/keymile/km_arm/fpga_config.c
+++ b/board/keymile/km_arm/fpga_config.c
@@ -238,11 +238,7 @@  int fpga_reset(void)
 	/* small delay for the pulse */
 	udelay(10);
 
-	ret = boco_set_bits(PRST1, resets);
-	if (ret)
-		return ret;
-
-	return 0;
+	return boco_set_bits(PRST1, resets);
 }
 #endif
 
@@ -250,16 +246,10 @@  int fpga_reset(void)
  * is available from the Bobcat SPI bus */
 int toggle_eeprom_spi_bus(void)
 {
-	int ret = 0;
-
 	if (!check_boco2()) {
 		/* we do not have BOCO2, this is not really used */
 		return 0;
 	}
 
-	ret = boco_set_bits(SPI_REG, CFG_EEPROM);
-	if (ret)
-		return ret;
-
-	return 0;
+	return boco_set_bits(SPI_REG, CFG_EEPROM);
 }
diff --git a/board/kosagi/novena/novena.c b/board/kosagi/novena/novena.c
index b3159d3..223007b 100644
--- a/board/kosagi/novena/novena.c
+++ b/board/kosagi/novena/novena.c
@@ -91,11 +91,7 @@  int drv_keyboard_init(void)
 	input_add_tables(&button_input, false);
 	button_input.read_keys = novena_gpio_button_read_keys;
 
-	error = input_stdio_register(&dev);
-	if (error)
-		return error;
-
-	return 0;
+	return input_stdio_register(&dev);
 }
 #endif
 
diff --git a/board/samsung/goni/goni.c b/board/samsung/goni/goni.c
index 1600568..e8329bb 100644
--- a/board/samsung/goni/goni.c
+++ b/board/samsung/goni/goni.c
@@ -45,17 +45,11 @@  void i2c_init_board(void)
 
 int power_init_board(void)
 {
-	int ret;
-
 	/*
 	 * For PMIC the I2C bus is named as I2C5, but it is connected
 	 * to logical I2C adapter 0
 	 */
-	ret = pmic_init(I2C_0);
-	if (ret)
-		return ret;
-
-	return 0;
+	return pmic_init(I2C_0);
 }
 
 int dram_init(void)
diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
index e0ae1a5..84c2fbb 100644
--- a/board/ti/common/board_detect.c
+++ b/board/ti/common/board_detect.c
@@ -109,11 +109,7 @@  static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
 	if (hdr_read != header)
 		return -1;
 
-	rc = i2c_read(dev_addr, 0x0, byte, ep, size);
-	if (rc)
-		return rc;
-
-	return 0;
+	return i2c_read(dev_addr, 0x0, byte, ep, size);
 }
 
 int __maybe_unused ti_i2c_eeprom_am_get(int bus_addr, int dev_addr)
diff --git a/drivers/adc/adc-uclass.c b/drivers/adc/adc-uclass.c
index 9233fcd..e4b6696 100644
--- a/drivers/adc/adc-uclass.c
+++ b/drivers/adc/adc-uclass.c
@@ -194,11 +194,7 @@  int adc_channel_single_shot(const char *name, int channel, unsigned int *data)
 	if (ret)
 		return ret;
 
-	ret = adc_channel_data(dev, channel, data);
-	if (ret)
-		return ret;
-
-	return 0;
+	return adc_channel_data(dev, channel, data);
 }
 
 static int _adc_channels_single_shot(struct udevice *dev,
@@ -243,11 +239,7 @@  int adc_channels_single_shot(const char *name, unsigned int channel_mask,
 	if (ret)
 		goto try_manual;
 
-	ret = adc_channels_data(dev, channel_mask, channels);
-	if (ret)
-		return ret;
-
-	return 0;
+	return adc_channels_data(dev, channel_mask, channels);
 
 try_manual:
 	if (ret != -ENOSYS)
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 33dc9c0..b254ee0 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -160,11 +160,7 @@  int dm_init(void)
 #if CONFIG_IS_ENABLED(OF_CONTROL)
 	DM_ROOT_NON_CONST->of_offset = 0;
 #endif
-	ret = device_probe(DM_ROOT_NON_CONST);
-	if (ret)
-		return ret;
-
-	return 0;
+	return device_probe(DM_ROOT_NON_CONST);
 }
 
 int dm_uninit(void)
@@ -261,11 +257,7 @@  int dm_init_and_scan(bool pre_reloc_only)
 		}
 	}
 
-	ret = dm_scan_other(pre_reloc_only);
-	if (ret)
-		return ret;
-
-	return 0;
+	return dm_scan_other(pre_reloc_only);
 }
 
 /* This is the root driver - all drivers are children of this */
diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c
index 9702eee..965c9dc 100644
--- a/drivers/dfu/dfu_sf.c
+++ b/drivers/dfu/dfu_sf.c
@@ -40,12 +40,8 @@  static int dfu_write_medium_sf(struct dfu_entity *dfu,
 	if (ret)
 		return ret;
 
-	ret = spi_flash_write(dfu->data.sf.dev, dfu->data.sf.start + offset,
-			      *len, buf);
-	if (ret)
-		return ret;
-
-	return 0;
+	return spi_flash_write(dfu->data.sf.dev, dfu->data.sf.start + offset,
+			       *len, buf);
 }
 
 static int dfu_flush_medium_sf(struct dfu_entity *dfu)
diff --git a/drivers/gpio/74x164_gpio.c b/drivers/gpio/74x164_gpio.c
index 9ac10a7..109fcc5 100644
--- a/drivers/gpio/74x164_gpio.c
+++ b/drivers/gpio/74x164_gpio.c
@@ -75,18 +75,13 @@  static int gen_74x164_set_value(struct udevice *dev, unsigned offset,
 	struct gen_74x164_priv *priv = dev_get_priv(dev);
 	uint bank = priv->nregs - 1 - offset / 8;
 	uint pin = offset % 8;
-	int ret;
 
 	if (value)
 		priv->buffer[bank] |= 1 << pin;
 	else
 		priv->buffer[bank] &= ~(1 << pin);
 
-	ret = gen_74x164_write_conf(dev);
-	if (ret)
-		return ret;
-
-	return 0;
+	return gen_74x164_write_conf(dev);
 }
 
 static int gen_74x164_direction_input(struct udevice *dev, unsigned offset)
diff --git a/drivers/gpio/axp_gpio.c b/drivers/gpio/axp_gpio.c
index ec00827..b92a02a 100644
--- a/drivers/gpio/axp_gpio.c
+++ b/drivers/gpio/axp_gpio.c
@@ -172,9 +172,5 @@  int axp_gpio_init(void)
 		return ret;
 
 	/* There is no devicetree support for the axp yet, so bind directly */
-	ret = device_bind_driver(dm_root(), "gpio_axp", "AXP-gpio", &dev);
-	if (ret)
-		return ret;
-
-	return 0;
+	return device_bind_driver(dm_root(), "gpio_axp", "AXP-gpio", &dev);
 }
diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index aea8d61..f8bec6f 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -896,11 +896,7 @@  int cros_ec_flash_update_rw(struct cros_ec_dev *dev,
 		return ret;
 
 	/* Write the image */
-	ret = cros_ec_flash_write(dev, image, rw_offset, image_size);
-	if (ret)
-		return ret;
-
-	return 0;
+	return cros_ec_flash_write(dev, image, rw_offset, image_size);
 }
 
 int cros_ec_read_vbnvcontext(struct cros_ec_dev *dev, uint8_t *block)
diff --git a/drivers/misc/pca9551_led.c b/drivers/misc/pca9551_led.c
index 4da0319..116f117 100644
--- a/drivers/misc/pca9551_led.c
+++ b/drivers/misc/pca9551_led.c
@@ -84,17 +84,12 @@  static int pca9551_led_set_state(int led, int state)
 
 	buf = (buf & ~mask) | ((state & 0x03) << shift);
 
-	ret = i2c_write(CONFIG_PCA9551_I2C_ADDR, reg, 1, &buf, 1);
-	if (ret)
-		return ret;
-
-	return 0;
+	return i2c_write(CONFIG_PCA9551_I2C_ADDR, reg, 1, &buf, 1);
 }
 
 static int pca9551_led_set_blink_rate(int idx, struct pca9551_blink_rate rate)
 {
 	unsigned int reg;
-	int ret;
 
 	switch (idx) {
 	case 0:
@@ -108,11 +103,7 @@  static int pca9551_led_set_blink_rate(int idx, struct pca9551_blink_rate rate)
 	}
 	reg |= PCA9551_CTRL_AI;
 
-	ret = i2c_write(CONFIG_PCA9551_I2C_ADDR, reg, 1, (u8 *)&rate, 2);
-	if (ret)
-		return ret;
-
-	return 0;
+	return i2c_write(CONFIG_PCA9551_I2C_ADDR, reg, 1, (u8 *)&rate, 2);
 }
 
 /*
diff --git a/drivers/misc/tegra186_bpmp.c b/drivers/misc/tegra186_bpmp.c
index f4ddbea3..29145d2 100644
--- a/drivers/misc/tegra186_bpmp.c
+++ b/drivers/misc/tegra186_bpmp.c
@@ -128,11 +128,7 @@  static int tegra186_bpmp_bind(struct udevice *dev)
 	if (ret)
 		return ret;
 
-	ret = dm_scan_fdt_dev(dev);
-	if (ret)
-		return ret;
-
-	return 0;
+	return dm_scan_fdt_dev(dev);
 }
 
 static ulong tegra186_bpmp_get_shmem(struct udevice *dev, int index)
diff --git a/drivers/mmc/atmel_sdhci.c b/drivers/mmc/atmel_sdhci.c
index dd6bd33..d8f8087 100644
--- a/drivers/mmc/atmel_sdhci.c
+++ b/drivers/mmc/atmel_sdhci.c
@@ -136,13 +136,8 @@  static int atmel_sdhci_probe(struct udevice *dev)
 static int atmel_sdhci_bind(struct udevice *dev)
 {
 	struct atmel_sdhci_plat *plat = dev_get_platdata(dev);
-	int ret;
 
-	ret = sdhci_bind(dev, &plat->mmc, &plat->cfg);
-	if (ret)
-		return ret;
-
-	return 0;
+	return sdhci_bind(dev, &plat->mmc, &plat->cfg);
 }
 
 static const struct udevice_id atmel_sdhci_ids[] = {
diff --git a/drivers/mmc/davinci_mmc.c b/drivers/mmc/davinci_mmc.c
index b495c75..90735cb 100644
--- a/drivers/mmc/davinci_mmc.c
+++ b/drivers/mmc/davinci_mmc.c
@@ -305,11 +305,7 @@  dmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
 		}
 	}
 
-	err = dmmc_check_status(regs, &mmcstatus, MMCST0_DATDNE, status_err);
-	if (err)
-		return err;
-
-	return 0;
+	return dmmc_check_status(regs, &mmcstatus, MMCST0_DATDNE, status_err);
 }
 
 /* Initialize Davinci MMC controller */
diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c
index 57271f1..568fed7 100644
--- a/drivers/mmc/exynos_dw_mmc.c
+++ b/drivers/mmc/exynos_dw_mmc.c
@@ -284,13 +284,8 @@  static int exynos_dwmmc_probe(struct udevice *dev)
 static int exynos_dwmmc_bind(struct udevice *dev)
 {
 	struct exynos_mmc_plat *plat = dev_get_platdata(dev);
-	int ret;
 
-	ret = dwmci_bind(dev, &plat->mmc, &plat->cfg);
-	if (ret)
-		return ret;
-
-	return 0;
+	return dwmci_bind(dev, &plat->mmc, &plat->cfg);
 }
 
 static const struct udevice_id exynos_dwmmc_ids[] = {
diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index 425abb1..29d85ce 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -243,7 +243,6 @@  static int mmc_select_hwpart(struct udevice *bdev, int hwpart)
 	struct udevice *mmc_dev = dev_get_parent(bdev);
 	struct mmc *mmc = mmc_get_mmc_dev(mmc_dev);
 	struct blk_desc *desc = dev_get_uclass_platdata(bdev);
-	int ret;
 
 	if (desc->hwpart == hwpart)
 		return 0;
@@ -251,11 +250,7 @@  static int mmc_select_hwpart(struct udevice *bdev, int hwpart)
 	if (mmc->part_config == MMCPART_NOAVAILABLE)
 		return -EMEDIUMTYPE;
 
-	ret = mmc_switch_part(mmc, hwpart);
-	if (ret)
-		return ret;
-
-	return 0;
+	return mmc_switch_part(mmc, hwpart);
 }
 
 static const struct blk_ops mmc_blk_ops = {
diff --git a/drivers/mmc/mmc_boot.c b/drivers/mmc/mmc_boot.c
index 756a982..ac6f56f 100644
--- a/drivers/mmc/mmc_boot.c
+++ b/drivers/mmc/mmc_boot.c
@@ -85,16 +85,10 @@  int mmc_boot_partition_size_change(struct mmc *mmc, unsigned long bootsize,
  */
 int mmc_set_boot_bus_width(struct mmc *mmc, u8 width, u8 reset, u8 mode)
 {
-	int err;
-
-	err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_BUS_WIDTH,
-			 EXT_CSD_BOOT_BUS_WIDTH_MODE(mode) |
-			 EXT_CSD_BOOT_BUS_WIDTH_RESET(reset) |
-			 EXT_CSD_BOOT_BUS_WIDTH_WIDTH(width));
-
-	if (err)
-		return err;
-	return 0;
+	return mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_BUS_WIDTH,
+			  EXT_CSD_BOOT_BUS_WIDTH_MODE(mode) |
+			  EXT_CSD_BOOT_BUS_WIDTH_RESET(reset) |
+			  EXT_CSD_BOOT_BUS_WIDTH_WIDTH(width));
 }
 
 /*
@@ -106,16 +100,10 @@  int mmc_set_boot_bus_width(struct mmc *mmc, u8 width, u8 reset, u8 mode)
  */
 int mmc_set_part_conf(struct mmc *mmc, u8 ack, u8 part_num, u8 access)
 {
-	int err;
-
-	err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONF,
-			 EXT_CSD_BOOT_ACK(ack) |
-			 EXT_CSD_BOOT_PART_NUM(part_num) |
-			 EXT_CSD_PARTITION_ACCESS(access));
-
-	if (err)
-		return err;
-	return 0;
+	return mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONF,
+			  EXT_CSD_BOOT_ACK(ack) |
+			  EXT_CSD_BOOT_PART_NUM(part_num) |
+			  EXT_CSD_PARTITION_ACCESS(access));
 }
 
 /*
diff --git a/drivers/mmc/mmc_legacy.c b/drivers/mmc/mmc_legacy.c
index 25361d1..00b9975 100644
--- a/drivers/mmc/mmc_legacy.c
+++ b/drivers/mmc/mmc_legacy.c
@@ -161,7 +161,6 @@  void mmc_destroy(struct mmc *mmc)
 static int mmc_select_hwpartp(struct blk_desc *desc, int hwpart)
 {
 	struct mmc *mmc = find_mmc_device(desc->devnum);
-	int ret;
 
 	if (!mmc)
 		return -ENODEV;
@@ -172,11 +171,7 @@  static int mmc_select_hwpartp(struct blk_desc *desc, int hwpart)
 	if (mmc->part_config == MMCPART_NOAVAILABLE)
 		return -EMEDIUMTYPE;
 
-	ret = mmc_switch_part(mmc, hwpart);
-	if (ret)
-		return ret;
-
-	return 0;
+	return mmc_switch_part(mmc, hwpart);
 }
 
 static int mmc_get_dev(int dev, struct blk_desc **descp)
diff --git a/drivers/mmc/msm_sdhci.c b/drivers/mmc/msm_sdhci.c
index 8d4399e..1b82991 100644
--- a/drivers/mmc/msm_sdhci.c
+++ b/drivers/mmc/msm_sdhci.c
@@ -190,13 +190,8 @@  static int msm_ofdata_to_platdata(struct udevice *dev)
 static int msm_sdc_bind(struct udevice *dev)
 {
 	struct msm_sdhc_plat *plat = dev_get_platdata(dev);
-	int ret;
 
-	ret = sdhci_bind(dev, &plat->mmc, &plat->cfg);
-	if (ret)
-		return ret;
-
-	return 0;
+	return sdhci_bind(dev, &plat->mmc, &plat->cfg);
 }
 
 static const struct udevice_id msm_mmc_ids[] = {
diff --git a/drivers/mmc/mxcmmc.c b/drivers/mmc/mxcmmc.c
index 8038f90..82e09a4 100644
--- a/drivers/mmc/mxcmmc.c
+++ b/drivers/mmc/mxcmmc.c
@@ -331,11 +331,7 @@  static int mxcmci_push(struct mxcmci_host *host, const void *_buf, int bytes)
 		writel(tmp, &host->base->buffer_access);
 	}
 
-	stat = mxcmci_poll_status(host, STATUS_BUF_WRITE_RDY);
-	if (stat)
-		return stat;
-
-	return 0;
+	return mxcmci_poll_status(host, STATUS_BUF_WRITE_RDY);
 }
 
 static int mxcmci_transfer_data(struct mxcmci_host *host)
diff --git a/drivers/mmc/pxa_mmc_gen.c b/drivers/mmc/pxa_mmc_gen.c
index 19ae81d..bbe8548 100644
--- a/drivers/mmc/pxa_mmc_gen.c
+++ b/drivers/mmc/pxa_mmc_gen.c
@@ -100,7 +100,6 @@  static int pxa_mmc_start_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
 {
 	struct pxa_mmc_priv *priv = mmc->priv;
 	struct pxa_mmc_regs *regs = priv->regs;
-	int ret;
 
 	/* The card can send a "busy" response */
 	if (cmd->resp_type & MMC_RSP_BUSY)
@@ -131,12 +130,7 @@  static int pxa_mmc_start_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
 	/* Start the controller clock and wait until they are started */
 	writel(MMC_STRPCL_START_CLK, &regs->strpcl);
 
-	ret = pxa_mmc_wait(mmc, MMC_STAT_CLK_EN);
-	if (ret)
-		return ret;
-
-	/* Correct and happy end */
-	return 0;
+	return pxa_mmc_wait(mmc, MMC_STAT_CLK_EN);
 }
 
 static int pxa_mmc_cmd_done(struct mmc *mmc, struct mmc_cmd *cmd)
@@ -188,7 +182,6 @@  static int pxa_mmc_do_read_xfer(struct mmc *mmc, struct mmc_data *data)
 	uint32_t len;
 	uint32_t *buf = (uint32_t *)data->dest;
 	int size;
-	int ret;
 
 	len = data->blocks * data->blocksize;
 
@@ -210,11 +203,7 @@  static int pxa_mmc_do_read_xfer(struct mmc *mmc, struct mmc_data *data)
 	}
 
 	/* Wait for the transmission-done interrupt */
-	ret = pxa_mmc_wait(mmc, MMC_STAT_DATA_TRAN_DONE);
-	if (ret)
-		return ret;
-
-	return 0;
+	return pxa_mmc_wait(mmc, MMC_STAT_DATA_TRAN_DONE);
 }
 
 static int pxa_mmc_do_write_xfer(struct mmc *mmc, struct mmc_data *data)
@@ -252,11 +241,7 @@  static int pxa_mmc_do_write_xfer(struct mmc *mmc, struct mmc_data *data)
 		return ret;
 
 	/* Wait until the data are really written to the card */
-	ret = pxa_mmc_wait(mmc, MMC_STAT_PRG_DONE);
-	if (ret)
-		return ret;
-
-	return 0;
+	return pxa_mmc_wait(mmc, MMC_STAT_PRG_DONE);
 }
 
 static int pxa_mmc_request(struct mmc *mmc, struct mmc_cmd *cmd,
diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c
index 020a59b..859760b 100644
--- a/drivers/mmc/rockchip_dw_mmc.c
+++ b/drivers/mmc/rockchip_dw_mmc.c
@@ -142,13 +142,8 @@  static int rockchip_dwmmc_probe(struct udevice *dev)
 static int rockchip_dwmmc_bind(struct udevice *dev)
 {
 	struct rockchip_mmc_plat *plat = dev_get_platdata(dev);
-	int ret;
 
-	ret = dwmci_bind(dev, &plat->mmc, &plat->cfg);
-	if (ret)
-		return ret;
-
-	return 0;
+	return dwmci_bind(dev, &plat->mmc, &plat->cfg);
 }
 
 static const struct udevice_id rockchip_dwmmc_ids[] = {
diff --git a/drivers/mmc/rockchip_sdhci.c b/drivers/mmc/rockchip_sdhci.c
index 624029b..c56e1a3 100644
--- a/drivers/mmc/rockchip_sdhci.c
+++ b/drivers/mmc/rockchip_sdhci.c
@@ -62,13 +62,8 @@  static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev)
 static int rockchip_sdhci_bind(struct udevice *dev)
 {
 	struct rockchip_sdhc_plat *plat = dev_get_platdata(dev);
-	int ret;
 
-	ret = sdhci_bind(dev, &plat->mmc, &plat->cfg);
-	if (ret)
-		return ret;
-
-	return 0;
+	return sdhci_bind(dev, &plat->mmc, &plat->cfg);
 }
 
 static const struct udevice_id arasan_sdhci_ids[] = {
diff --git a/drivers/mmc/sandbox_mmc.c b/drivers/mmc/sandbox_mmc.c
index 5f1333b..fdb29a5 100644
--- a/drivers/mmc/sandbox_mmc.c
+++ b/drivers/mmc/sandbox_mmc.c
@@ -112,7 +112,6 @@  int sandbox_mmc_bind(struct udevice *dev)
 {
 	struct sandbox_mmc_plat *plat = dev_get_platdata(dev);
 	struct mmc_config *cfg = &plat->cfg;
-	int ret;
 
 	cfg->name = dev->name;
 	cfg->host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS | MMC_MODE_8BIT;
@@ -121,11 +120,7 @@  int sandbox_mmc_bind(struct udevice *dev)
 	cfg->f_max = 52000000;
 	cfg->b_max = U32_MAX;
 
-	ret = mmc_bind(dev, &plat->mmc, cfg);
-	if (ret)
-		return ret;
-
-	return 0;
+	return mmc_bind(dev, &plat->mmc, cfg);
 }
 
 int sandbox_mmc_unbind(struct udevice *dev)
diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c
index 3815b94..b991102 100644
--- a/drivers/mmc/zynq_sdhci.c
+++ b/drivers/mmc/zynq_sdhci.c
@@ -63,13 +63,8 @@  static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev)
 static int arasan_sdhci_bind(struct udevice *dev)
 {
 	struct arasan_sdhci_plat *plat = dev_get_platdata(dev);
-	int ret;
 
-	ret = sdhci_bind(dev, &plat->mmc, &plat->cfg);
-	if (ret)
-		return ret;
-
-	return 0;
+	return sdhci_bind(dev, &plat->mmc, &plat->cfg);
 }
 
 static const struct udevice_id arasan_sdhci_ids[] = {
diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index f621f14..b27a6af 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -788,11 +788,7 @@  static int fsl_elbc_chip_init(int devnum, u8 *addr)
 	if (ret)
 		return ret;
 
-	ret = nand_register(devnum, mtd);
-	if (ret)
-		return ret;
-
-	return 0;
+	return nand_register(devnum, mtd);
 }
 
 #ifndef CONFIG_SYS_NAND_BASE_LIST
diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c
index 7001cbd..7081312 100644
--- a/drivers/mtd/nand/fsl_ifc_nand.c
+++ b/drivers/mtd/nand/fsl_ifc_nand.c
@@ -1044,10 +1044,7 @@  static int fsl_ifc_chip_init(int devnum, u8 *addr)
 	if (ret)
 		return ret;
 
-	ret = nand_register(devnum, mtd);
-	if (ret)
-		return ret;
-	return 0;
+	return nand_register(devnum, mtd);
 }
 
 #ifndef CONFIG_SYS_NAND_BASE_LIST
diff --git a/drivers/mtd/nand/tegra_nand.c b/drivers/mtd/nand/tegra_nand.c
index 38bd7a5..0978eea 100644
--- a/drivers/mtd/nand/tegra_nand.c
+++ b/drivers/mtd/nand/tegra_nand.c
@@ -975,11 +975,7 @@  int tegra_nand_init(struct nand_chip *nand, int devnum)
 	if (ret)
 		return ret;
 
-	ret = nand_register(devnum, our_mtd);
-	if (ret)
-		return ret;
-
-	return 0;
+	return nand_register(devnum, our_mtd);
 }
 
 void board_nand_init(void)
diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c
index f99bdaf..2285d76 100644
--- a/drivers/mtd/nand/vf610_nfc.c
+++ b/drivers/mtd/nand/vf610_nfc.c
@@ -751,11 +751,7 @@  static int vf610_nfc_nand_init(int devnum, void __iomem *addr)
 	if (err)
 		return err;
 
-	err = nand_register(devnum, mtd);
-	if (err)
-		return err;
-
-	return 0;
+	return nand_register(devnum, mtd);
 
 error:
 	return err;
diff --git a/drivers/mtd/ubi/attach.c b/drivers/mtd/ubi/attach.c
index 90fb74a..96ee624 100644
--- a/drivers/mtd/ubi/attach.c
+++ b/drivers/mtd/ubi/attach.c
@@ -1002,11 +1002,8 @@  static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
 				ubi_msg(ubi, "\"delete\" compatible internal volume %d:%d found, will remove it",
 					vol_id, lnum);
 			}
-			err = add_to_list(ai, pnum, vol_id, lnum,
-					  ec, 1, &ai->erase);
-			if (err)
-				return err;
-			return 0;
+			return add_to_list(ai, pnum, vol_id, lnum, ec, 1,
+					   &ai->erase);
 
 		case UBI_COMPAT_RO:
 			ubi_msg(ubi, "read-only compatible internal volume %d:%d found, switch to read-only mode",
@@ -1017,11 +1014,8 @@  static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
 		case UBI_COMPAT_PRESERVE:
 			ubi_msg(ubi, "\"preserve\" compatible internal volume %d:%d found",
 				vol_id, lnum);
-			err = add_to_list(ai, pnum, vol_id, lnum,
-					  ec, 0, &ai->alien);
-			if (err)
-				return err;
-			return 0;
+			return add_to_list(ai, pnum, vol_id, lnum, ec, 0,
+					   &ai->alien);
 
 		case UBI_COMPAT_REJECT:
 			ubi_err(ubi, "incompatible internal volume %d:%d found",
diff --git a/drivers/net/fm/eth.c b/drivers/net/fm/eth.c
index eb8e936..2f06e65 100644
--- a/drivers/net/fm/eth.c
+++ b/drivers/net/fm/eth.c
@@ -368,11 +368,7 @@  static int fm_eth_init(struct fm_eth *fm_eth)
 	if (ret)
 		return ret;
 
-	ret = fm_eth_tx_port_parameter_init(fm_eth);
-	if (ret)
-		return ret;
-
-	return 0;
+	return fm_eth_tx_port_parameter_init(fm_eth);
 }
 
 static int fm_eth_startup(struct fm_eth *fm_eth)
diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 900a04c..16cd235 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -1864,7 +1864,7 @@  static int mvpp2_prs_etype_init(struct mvpp2 *priv)
 static int mvpp2_prs_default_init(struct udevice *dev,
 				  struct mvpp2 *priv)
 {
-	int err, index, i;
+	int index, i;
 
 	/* Enable tcam table */
 	mvpp2_write(priv, MVPP2_PRS_TCAM_CTRL_REG, MVPP2_PRS_TCAM_EN_MASK);
@@ -1901,11 +1901,7 @@  static int mvpp2_prs_default_init(struct udevice *dev,
 
 	mvpp2_prs_mac_init(priv);
 
-	err = mvpp2_prs_etype_init(priv);
-	if (err)
-		return err;
-
-	return 0;
+	return mvpp2_prs_etype_init(priv);
 }
 
 /* Compare MAC DA with tcam entry data */
@@ -3460,7 +3456,7 @@  static int mvpp2_port_init(struct udevice *dev, struct mvpp2_port *port)
 {
 	struct mvpp2 *priv = port->priv;
 	struct mvpp2_txq_pcpu *txq_pcpu;
-	int queue, cpu, err;
+	int queue, cpu;
 
 	if (port->first_rxq + rxq_number > MVPP2_RXQ_TOTAL_NUM)
 		return -EINVAL;
@@ -3547,11 +3543,7 @@  static int mvpp2_port_init(struct udevice *dev, struct mvpp2_port *port)
 	port->pkt_size = MVPP2_RX_PKT_SIZE(PKTSIZE_ALIGN);
 
 	/* Initialize pools for swf */
-	err = mvpp2_swf_bm_pool_init(port);
-	if (err)
-		return err;
-
-	return 0;
+	return mvpp2_swf_bm_pool_init(port);
 }
 
 /* Ports initialization */
diff --git a/drivers/net/phy/mv88e6352.c b/drivers/net/phy/mv88e6352.c
index f639a42..ac67c47 100644
--- a/drivers/net/phy/mv88e6352.c
+++ b/drivers/net/phy/mv88e6352.c
@@ -102,11 +102,7 @@  static int sw_reg_write(const char *devname, u8 phy_addr, u8 port,
 	if (ret)
 		return ret;
 
-	ret = sw_wait_rdy(devname, phy_addr);
-	if (ret)
-		return ret;
-
-	return 0;
+	return sw_wait_rdy(devname, phy_addr);
 }
 
 static int ppu_enable(const char *devname, u8 phy_addr)
diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c
index 7b85aa0..667e053 100644
--- a/drivers/net/xilinx_emaclite.c
+++ b/drivers/net/xilinx_emaclite.c
@@ -555,7 +555,6 @@  static int emaclite_miiphy_write(struct mii_dev *bus, int addr, int devad,
 static int emaclite_probe(struct udevice *dev)
 {
 	struct xemaclite *emaclite = dev_get_priv(dev);
-	int ret;
 
 	emaclite->bus = mdio_alloc();
 	emaclite->bus->read = emaclite_miiphy_read;
@@ -563,11 +562,7 @@  static int emaclite_probe(struct udevice *dev)
 	emaclite->bus->priv = emaclite;
 	strcpy(emaclite->bus->name, "emaclite");
 
-	ret = mdio_register(emaclite->bus);
-	if (ret)
-		return ret;
-
-	return 0;
+	return mdio_register(emaclite->bus);
 }
 
 static int emaclite_remove(struct udevice *dev)
diff --git a/drivers/pci/pcie_imx.c b/drivers/pci/pcie_imx.c
index 732d59d..f0d3119 100644
--- a/drivers/pci/pcie_imx.c
+++ b/drivers/pci/pcie_imx.c
@@ -131,11 +131,7 @@  static int pcie_phy_wait_ack(void __iomem *dbi_base, int addr)
 	val = addr << PCIE_PHY_CTRL_DATA_LOC;
 	writel(val, dbi_base + PCIE_PHY_CTRL);
 
-	ret = pcie_phy_poll_ack(dbi_base, 0);
-	if (ret)
-		return ret;
-
-	return 0;
+	return pcie_phy_poll_ack(dbi_base, 0);
 }
 
 /* Read from the 16-bit PCIe PHY control registers (not memory-mapped) */
@@ -162,11 +158,7 @@  static int pcie_phy_read(void __iomem *dbi_base, int addr , int *data)
 	/* deassert Read signal */
 	writel(0x00, dbi_base + PCIE_PHY_CTRL);
 
-	ret = pcie_phy_poll_ack(dbi_base, 0);
-	if (ret)
-		return ret;
-
-	return 0;
+	return pcie_phy_poll_ack(dbi_base, 0);
 }
 
 static int pcie_phy_write(void __iomem *dbi_base, int addr, int data)
diff --git a/drivers/power/axp809.c b/drivers/power/axp809.c
index c8b76cf..c5b608d 100644
--- a/drivers/power/axp809.c
+++ b/drivers/power/axp809.c
@@ -217,13 +217,7 @@  int axp_set_sw(bool on)
 
 int axp_init(void)
 {
-	int ret;
-
-	ret = pmic_bus_init();
-	if (ret)
-		return ret;
-
-	return 0;
+	return pmic_bus_init();
 }
 
 int do_poweroff(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
diff --git a/drivers/rtc/i2c_rtc_emul.c b/drivers/rtc/i2c_rtc_emul.c
index 20827fd..767c821 100644
--- a/drivers/rtc/i2c_rtc_emul.c
+++ b/drivers/rtc/i2c_rtc_emul.c
@@ -146,7 +146,6 @@  static int sandbox_i2c_rtc_complete_write(struct udevice *emul)
 {
 	struct sandbox_i2c_rtc_plat_data *plat = dev_get_platdata(emul);
 	struct rtc_time time;
-	int ret;
 
 	time.tm_sec = plat->reg[REG_SEC];
 	time.tm_min = plat->reg[REG_MIN];
@@ -156,11 +155,7 @@  static int sandbox_i2c_rtc_complete_write(struct udevice *emul)
 	time.tm_year = plat->reg[REG_YEAR] + 1900;
 	time.tm_wday = plat->reg[REG_WDAY];
 
-	ret = sandbox_i2c_rtc_set(emul, &time);
-	if (ret)
-		return ret;
-
-	return 0;
+	return sandbox_i2c_rtc_set(emul, &time);
 }
 
 static int sandbox_i2c_rtc_xfer(struct udevice *emul, struct i2c_msg *msg,
@@ -202,11 +197,7 @@  static int sandbox_i2c_rtc_xfer(struct udevice *emul, struct i2c_msg *msg,
 				reset_time(emul);
 		}
 	}
-	ret = sandbox_i2c_rtc_complete_write(emul);
-	if (ret)
-		return ret;
-
-	return 0;
+	return sandbox_i2c_rtc_complete_write(emul);
 }
 
 struct dm_i2c_ops sandbox_i2c_rtc_emul_ops = {
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index d65bbe9..cd460a2 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -130,13 +130,7 @@  static int ehci_atmel_probe(struct udevice *dev)
 
 static int ehci_atmel_remove(struct udevice *dev)
 {
-	int ret;
-
-	ret = ehci_deregister(dev);
-	if (ret)
-		return ret;
-
-	return 0;
+	return ehci_deregister(dev);
 }
 
 static const struct udevice_id ehci_usb_ids[] = {
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index f5e3ae7..fb65480 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -120,13 +120,7 @@  static int ehci_fsl_probe(struct udevice *dev)
 
 static int ehci_fsl_remove(struct udevice *dev)
 {
-	int ret;
-
-	ret = ehci_deregister(dev);
-	if (ret)
-		return ret;
-
-	return 0;
+	return ehci_deregister(dev);
 }
 
 static const struct udevice_id ehci_usb_ids[] = {
diff --git a/drivers/usb/host/ehci-marvell.c b/drivers/usb/host/ehci-marvell.c
index 5b0f46a..2ecf282 100644
--- a/drivers/usb/host/ehci-marvell.c
+++ b/drivers/usb/host/ehci-marvell.c
@@ -96,13 +96,7 @@  static int ehci_mvebu_probe(struct udevice *dev)
 
 static int ehci_mvebu_remove(struct udevice *dev)
 {
-	int ret;
-
-	ret = ehci_deregister(dev);
-	if (ret)
-		return ret;
-
-	return 0;
+	return ehci_deregister(dev);
 }
 
 static const struct udevice_id ehci_usb_ids[] = {
diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index 602fec5..a785bb8 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -453,13 +453,7 @@  static int ehci_usb_probe(struct udevice *dev)
 
 static int ehci_usb_remove(struct udevice *dev)
 {
-	int ret;
-
-	ret = ehci_deregister(dev);
-	if (ret)
-		return ret;
-
-	return 0;
+	return ehci_deregister(dev);
 }
 
 static const struct udevice_id mx6_usb_ids[] = {
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index f21a1fa..2228f91 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -128,13 +128,7 @@  static int ehci_pci_probe(struct udevice *dev)
 
 static int ehci_pci_remove(struct udevice *dev)
 {
-	int ret;
-
-	ret = ehci_deregister(dev);
-	if (ret)
-		return ret;
-
-	return 0;
+	return ehci_deregister(dev);
 }
 
 static const struct udevice_id ehci_pci_ids[] = {
diff --git a/drivers/usb/host/ehci-zynq.c b/drivers/usb/host/ehci-zynq.c
index 76642cd..1fe00bfe 100644
--- a/drivers/usb/host/ehci-zynq.c
+++ b/drivers/usb/host/ehci-zynq.c
@@ -75,13 +75,7 @@  static int ehci_zynq_probe(struct udevice *dev)
 
 static int ehci_zynq_remove(struct udevice *dev)
 {
-	int ret;
-
-	ret = ehci_deregister(dev);
-	if (ret)
-		return ret;
-
-	return 0;
+	return ehci_deregister(dev);
 }
 
 static const struct udevice_id ehci_zynq_ids[] = {
diff --git a/drivers/usb/host/xhci-fsl.c b/drivers/usb/host/xhci-fsl.c
index bdcd4f1..6ff450c 100644
--- a/drivers/usb/host/xhci-fsl.c
+++ b/drivers/usb/host/xhci-fsl.c
@@ -129,15 +129,10 @@  static int xhci_fsl_probe(struct udevice *dev)
 static int xhci_fsl_remove(struct udevice *dev)
 {
 	struct xhci_fsl_priv *priv = dev_get_priv(dev);
-	int ret;
 
 	fsl_xhci_core_exit(&priv->ctx);
 
-	ret = xhci_deregister(dev);
-	if (ret)
-		return ret;
-
-	return 0;
+	return xhci_deregister(dev);
 }
 
 static const struct udevice_id xhci_usb_ids[] = {
diff --git a/drivers/usb/ulpi/ulpi.c b/drivers/usb/ulpi/ulpi.c
index f3d1856..d4b6c2c 100644
--- a/drivers/usb/ulpi/ulpi.c
+++ b/drivers/usb/ulpi/ulpi.c
@@ -129,11 +129,7 @@  int ulpi_set_vbus_indicator(struct ulpi_viewport *ulpi_vp, int external,
 
 	val = val & ~(ULPI_IFACE_PASSTHRU & ULPI_IFACE_EXTVBUS_COMPLEMENT);
 	val |= flags;
-	val = ulpi_write(ulpi_vp, &ulpi->iface_ctrl, val);
-	if (val)
-		return val;
-
-	return 0;
+	return ulpi_write(ulpi_vp, &ulpi->iface_ctrl, val);
 }
 
 int ulpi_set_pd(struct ulpi_viewport *ulpi_vp, int enable)
diff --git a/drivers/video/bridge/ptn3460.c b/drivers/video/bridge/ptn3460.c
index 2e2ae7c..8916863 100644
--- a/drivers/video/bridge/ptn3460.c
+++ b/drivers/video/bridge/ptn3460.c
@@ -11,14 +11,8 @@ 
 
 static int ptn3460_attach(struct udevice *dev)
 {
-	int ret;
-
 	debug("%s: %s\n", __func__, dev->name);
-	ret = video_bridge_set_active(dev, true);
-	if (ret)
-		return ret;
-
-	return 0;
+	return video_bridge_set_active(dev, true);
 }
 
 struct video_bridge_ops ptn3460_ops = {
diff --git a/drivers/video/rockchip/rk_edp.c b/drivers/video/rockchip/rk_edp.c
index 7ece038..bfe972f 100644
--- a/drivers/video/rockchip/rk_edp.c
+++ b/drivers/video/rockchip/rk_edp.c
@@ -768,11 +768,7 @@  static int rk_edp_set_link_train(struct rk_edp_priv *edp)
 		return ret;
 	}
 
-	ret = rk_edp_hw_link_training(edp);
-	if (ret)
-		return ret;
-
-	return 0;
+	return rk_edp_hw_link_training(edp);
 }
 
 static void rk_edp_init_video(struct rk3288_edp *regs)
diff --git a/drivers/video/simple_panel.c b/drivers/video/simple_panel.c
index b2fe345..289e2b7 100644
--- a/drivers/video/simple_panel.c
+++ b/drivers/video/simple_panel.c
@@ -23,14 +23,9 @@  struct simple_panel_priv {
 static int simple_panel_enable_backlight(struct udevice *dev)
 {
 	struct simple_panel_priv *priv = dev_get_priv(dev);
-	int ret;
 
 	dm_gpio_set_value(&priv->enable, 1);
-	ret = backlight_enable(priv->backlight);
-	if (ret)
-		return ret;
-
-	return 0;
+	return backlight_enable(priv->backlight);
 }
 
 static int simple_panel_ofdata_to_platdata(struct udevice *dev)
diff --git a/drivers/video/tegra124/display.c b/drivers/video/tegra124/display.c
index 2f1f0df..d8999c3 100644
--- a/drivers/video/tegra124/display.c
+++ b/drivers/video/tegra124/display.c
@@ -326,13 +326,7 @@  static int display_update_config_from_edid(struct udevice *dp_dev,
 					   int *panel_bppp,
 					   struct display_timing *timing)
 {
-	int ret;
-
-	ret = display_read_timing(dp_dev, timing);
-	if (ret)
-		return ret;
-
-	return 0;
+	return display_read_timing(dp_dev, timing);
 }
 
 static int display_init(struct udevice *dev, void *lcdbase,
diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
index c8cc05e..0c71fc0 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -190,7 +190,6 @@  static int vidconsole_post_probe(struct udevice *dev)
 {
 	struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
 	struct stdio_dev *sdev = &priv->sdev;
-	int ret;
 
 	if (!priv->tab_width_frac)
 		priv->tab_width_frac = VID_TO_POS(priv->x_charsize) * 8;
@@ -206,11 +205,7 @@  static int vidconsole_post_probe(struct udevice *dev)
 	sdev->putc = vidconsole_putc;
 	sdev->puts = vidconsole_puts;
 	sdev->priv = dev;
-	ret = stdio_register(sdev);
-	if (ret)
-		return ret;
-
-	return 0;
+	return stdio_register(sdev);
 }
 
 UCLASS_DRIVER(vidconsole) = {
diff --git a/fs/ubifs/budget.c b/fs/ubifs/budget.c
index 1b4683f..6b7a00b 100644
--- a/fs/ubifs/budget.c
+++ b/fs/ubifs/budget.c
@@ -71,7 +71,7 @@  static void shrink_liability(struct ubifs_info *c, int nr_to_write)
  */
 static int run_gc(struct ubifs_info *c)
 {
-	int err, lnum;
+	int lnum;
 
 	/* Make some free space by garbage-collecting dirty space */
 	down_read(&c->commit_sem);
@@ -82,10 +82,7 @@  static int run_gc(struct ubifs_info *c)
 
 	/* GC freed one LEB, return it to lprops */
 	dbg_budg("GC freed LEB %d", lnum);
-	err = ubifs_return_leb(c, lnum);
-	if (err)
-		return err;
-	return 0;
+	return ubifs_return_leb(c, lnum);
 }
 
 /**
diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c
index c6657a2..829163b 100644
--- a/fs/ubifs/gc.c
+++ b/fs/ubifs/gc.c
@@ -292,10 +292,7 @@  static int sort_nodes(struct ubifs_info *c, struct ubifs_scan_leb *sleb,
 	err = dbg_check_data_nodes_order(c, &sleb->nodes);
 	if (err)
 		return err;
-	err = dbg_check_nondata_nodes_order(c, nondata);
-	if (err)
-		return err;
-	return 0;
+	return dbg_check_nondata_nodes_order(c, nondata);
 }
 
 /**
diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c
index 2df9130..8e74377 100644
--- a/fs/ubifs/lpt_commit.c
+++ b/fs/ubifs/lpt_commit.c
@@ -310,10 +310,7 @@  static int layout_cnodes(struct ubifs_info *c)
 	alen = ALIGN(offs, c->min_io_size);
 	upd_ltab(c, lnum, c->leb_size - alen, alen - offs);
 	dbg_chk_lpt_sz(c, 4, alen - offs);
-	err = dbg_chk_lpt_sz(c, 3, alen);
-	if (err)
-		return err;
-	return 0;
+	return dbg_chk_lpt_sz(c, 3, alen);
 
 no_space:
 	ubifs_err(c, "LPT out of space at LEB %d:%d needing %d, done_ltab %d, done_lsave %d",
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index cdc04c6..6603476 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -247,11 +247,7 @@  int __init ubifs_compressors_init(void)
 	if (err)
 		return err;
 
-	err = compr_init(&none_compr);
-	if (err)
-		return err;
-
-	return 0;
+	return compr_init(&none_compr);
 }
 
 /*
diff --git a/lib/libfdt/fdt_rw.c b/lib/libfdt/fdt_rw.c
index e7321cc..47447b2 100644
--- a/lib/libfdt/fdt_rw.c
+++ b/lib/libfdt/fdt_rw.c
@@ -148,17 +148,13 @@  int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size)
 int fdt_del_mem_rsv(void *fdt, int n)
 {
 	struct fdt_reserve_entry *re = _fdt_mem_rsv_w(fdt, n);
-	int err;
 
 	FDT_RW_CHECK_HEADER(fdt);
 
 	if (n >= fdt_num_mem_rsv(fdt))
 		return -FDT_ERR_NOTFOUND;
 
-	err = _fdt_splice_mem_rsv(fdt, re, 1, 0);
-	if (err)
-		return err;
-	return 0;
+	return _fdt_splice_mem_rsv(fdt, re, 1, 0);
 }
 
 static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name,
diff --git a/lib/rsa/rsa-checksum.c b/lib/rsa/rsa-checksum.c
index 68d9d65..47ecc21 100644
--- a/lib/rsa/rsa-checksum.c
+++ b/lib/rsa/rsa-checksum.c
@@ -165,9 +165,5 @@  int hash_calculate(const char *name,
 	ret = algo->hash_update(algo, ctx, region[i].data, region[i].size, 1);
 	if (ret)
 		return ret;
-	ret = algo->hash_finish(algo, ctx, checksum, algo->digest_size);
-	if (ret)
-		return ret;
-
-	return 0;
+	return algo->hash_finish(algo, ctx, checksum, algo->digest_size);
 }
diff --git a/lib/tpm.c b/lib/tpm.c
index 88f2406..1f3a255 100644
--- a/lib/tpm.c
+++ b/lib/tpm.c
@@ -390,7 +390,6 @@  uint32_t tpm_nv_write_value(uint32_t index, const void *data, uint32_t length)
 		TPM_REQUEST_HEADER_LENGTH + write_info_size + length;
 	uint8_t buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE];
 	size_t response_length = sizeof(response);
-	uint32_t err;
 
 	if (pack_byte_string(buf, sizeof(buf), "sddds",
 				0, command, sizeof(command),
@@ -399,11 +398,7 @@  uint32_t tpm_nv_write_value(uint32_t index, const void *data, uint32_t length)
 				length_offset, length,
 				data_offset, data, length))
 		return TPM_LIB_ERROR;
-	err = tpm_sendrecv_command(buf, response, &response_length);
-	if (err)
-		return err;
-
-	return 0;
+	return tpm_sendrecv_command(buf, response, &response_length);
 }
 
 uint32_t tpm_extend(uint32_t index, const void *in_digest, void *out_digest)
diff --git a/tools/mxsimage.c b/tools/mxsimage.c
index 98fc644..5624020 100644
--- a/tools/mxsimage.c
+++ b/tools/mxsimage.c
@@ -1605,11 +1605,7 @@  static int sb_build_tree_from_cfg(struct sb_image_ctx *ictx)
 	if (ret)
 		return ret;
 
-	ret = sb_fixup_sections_and_tags(ictx);
-	if (ret)
-		return ret;
-
-	return 0;
+	return sb_fixup_sections_and_tags(ictx);
 }
 
 static int sb_verify_image_header(struct sb_image_ctx *ictx,