spi: rzv2m-csi: Leave readl_poll_timeout calls for last
authorFabrizio Castro <fabrizio.castro.jz@renesas.com>
Sat, 15 Jul 2023 01:04:01 +0000 (02:04 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 17 Jul 2023 11:41:43 +0000 (12:41 +0100)
Both rzv2m_csi_sw_reset and rzv2m_csi_start_stop_operation
call into readl_poll_timeout upon a certain condition, and
return 0 otherwise.
Flip the logic to improve readability.

Signed-off-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20230715010407.1751715-5-fabrizio.castro.jz@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-rzv2m-csi.c

index 621774949bde15df1247e4f76f0cbd7f83c09631..1c65cd5f2039a53ce2b60fb6bb078585edd5bcea 100644 (file)
@@ -131,13 +131,12 @@ static int rzv2m_csi_sw_reset(struct rzv2m_csi_priv *csi, int assert)
 
        rzv2m_csi_reg_write_bit(csi, CSI_CNT, CSI_CNT_CSIRST, assert);
 
-       if (assert) {
-               return readl_poll_timeout(csi->base + CSI_MODE, reg,
-                                         !(reg & CSI_MODE_CSOT), 0,
-                                         CSI_EN_DIS_TIMEOUT_US);
-       }
+       if (!assert)
+               return 0;
 
-       return 0;
+       return readl_poll_timeout(csi->base + CSI_MODE, reg,
+                                 !(reg & CSI_MODE_CSOT), 0,
+                                 CSI_EN_DIS_TIMEOUT_US);
 }
 
 static int rzv2m_csi_start_stop_operation(const struct rzv2m_csi_priv *csi,
@@ -147,12 +146,12 @@ static int rzv2m_csi_start_stop_operation(const struct rzv2m_csi_priv *csi,
 
        rzv2m_csi_reg_write_bit(csi, CSI_MODE, CSI_MODE_CSIE, enable);
 
-       if (!enable && wait)
-               return readl_poll_timeout(csi->base + CSI_MODE, reg,
-                                         !(reg & CSI_MODE_CSOT), 0,
-                                         CSI_EN_DIS_TIMEOUT_US);
+       if (enable || !wait)
+               return 0;
 
-       return 0;
+       return readl_poll_timeout(csi->base + CSI_MODE, reg,
+                                 !(reg & CSI_MODE_CSOT), 0,
+                                 CSI_EN_DIS_TIMEOUT_US);
 }
 
 static int rzv2m_csi_fill_txfifo(struct rzv2m_csi_priv *csi)