diff mbox series

[v2,4/7] i2c: designware: Drop unneeded condition in i2c_dw_validate_speed()

Message ID 20200519125043.6069-4-andriy.shevchenko@linux.intel.com
State Accepted
Commit 462cfcb4aa1c92239cb16177fd3ceb65326955ff
Headers show
Series [v2,1/7] i2c: designware: Get rid of PCI driver specifics in common code | expand

Commit Message

Andy Shevchenko May 19, 2020, 12:50 p.m. UTC
We may bailout directly from the loop instead of breaking it and
testing a loop counter. This also gives advantages such as decreased
indentation level along with dropped unneeded condition.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: new patch
 drivers/i2c/busses/i2c-designware-common.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c
index 9f06567be54a..2fd5372b1237 100644
--- a/drivers/i2c/busses/i2c-designware-common.c
+++ b/drivers/i2c/busses/i2c-designware-common.c
@@ -127,16 +127,14 @@  int i2c_dw_validate_speed(struct dw_i2c_dev *dev)
 	 */
 	for (i = 0; i < ARRAY_SIZE(i2c_dw_supported_speeds); i++) {
 		if (t->bus_freq_hz == i2c_dw_supported_speeds[i])
-			break;
-	}
-	if (i == ARRAY_SIZE(i2c_dw_supported_speeds)) {
-		dev_err(dev->dev,
-			"%d Hz is unsupported, only 100kHz, 400kHz, 1MHz and 3.4MHz are supported\n",
-			t->bus_freq_hz);
-		return -EINVAL;
+			return 0;
 	}
 
-	return 0;
+	dev_err(dev->dev,
+		"%d Hz is unsupported, only 100kHz, 400kHz, 1MHz and 3.4MHz are supported\n",
+		t->bus_freq_hz);
+
+	return -EINVAL;
 }
 EXPORT_SYMBOL_GPL(i2c_dw_validate_speed);