Skip to content

Commit e9d373c

Browse files
larsclausenwsakernel
authored andcommitted
i2c: cadence: Remove always false ternary operator
When selecting the clock dividers the Cadence I2C driver skips settings where the resulting I2C bus frequency is larger than the requested frequency. If the resulting frequency is lower it will compute the error to actual frequency. When calculating the difference it also handles the case where the resulting frequency is larger. Since the resulting frequency is always smaller or equal the computation of the error can be simplified by only considering this case. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Michal Simek <michal.simek@amd.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
1 parent 89151f6 commit e9d373c

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/i2c/busses/i2c-cadence.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,8 +1030,7 @@ static int cdns_i2c_calc_divs(unsigned long *f, unsigned long input_clk,
10301030
if (actual_fscl > fscl)
10311031
continue;
10321032

1033-
current_error = ((actual_fscl > fscl) ? (actual_fscl - fscl) :
1034-
(fscl - actual_fscl));
1033+
current_error = fscl - actual_fscl;
10351034

10361035
if (last_error > current_error) {
10371036
calc_div_a = div_a;

0 commit comments

Comments
 (0)