diff mbox series

[v3,3/4] i2c: mpc: Remove redundant NULL check

Message ID 20210413050956.23264-4-chris.packham@alliedtelesis.co.nz
State Accepted
Headers show
Series i2c: mpc: Refactor to improve responsiveness | expand

Commit Message

Chris Packham April 13, 2021, 5:09 a.m. UTC
In mpc_i2c_get_fdr_8xxx div is assigned as we iterate through the
mpc_i2c_dividers_8xxx array. By the time we exit the loop div will
either have the value that matches the requested speed or be pointing at
the last entry in mpc_i2c_dividers_8xxx. Checking for div being NULL
after the loop is redundant so remove the check.

Reported-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
 drivers/i2c/busses/i2c-mpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Wolfram Sang April 13, 2021, 12:27 p.m. UTC | #1
On Tue, Apr 13, 2021 at 05:09:54PM +1200, Chris Packham wrote:
> In mpc_i2c_get_fdr_8xxx div is assigned as we iterate through the
> mpc_i2c_dividers_8xxx array. By the time we exit the loop div will
> either have the value that matches the requested speed or be pointing at
> the last entry in mpc_i2c_dividers_8xxx. Checking for div being NULL
> after the loop is redundant so remove the check.
> 
> Reported-by: Wolfram Sang <wsa@kernel.org>
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>

Applied to for-next, thanks!
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 9818f9f6a553..c30687483147 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -377,7 +377,7 @@  static int mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock,
 	}
 
 	*real_clk = fsl_get_sys_freq() / prescaler / div->divider;
-	return div ? (int)div->fdr : -EINVAL;
+	return (int)div->fdr;
 }
 
 static void mpc_i2c_setup_8xxx(struct device_node *node,