From nobody Fri Dec 19 09:42:07 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3C46EE14C3 for ; Wed, 6 Sep 2023 20:01:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230317AbjIFUB0 (ORCPT ); Wed, 6 Sep 2023 16:01:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243587AbjIFUAg (ORCPT ); Wed, 6 Sep 2023 16:00:36 -0400 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD85119A8 for ; Wed, 6 Sep 2023 13:00:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=XoiQxYsYwOkc6ek7lwwO9Ez6SawCuS1deuBN1MfPurg=; b=Egtst9 yM4k4fxaCGvLCDq51Lf7uyTG7MU4U4qeniiDJpCo5XtVXBUGvTkJUR75yFlHTaRh EMpQorbsTg34hDpsm0NoOIXEPdp8bNM1VA2xD2rEchBy7DWSUsqsDG71Sv9CdTaF acai0tkQAscVvRkbywFCqUuCAKnGXprBQe4HKmb6vlbYS9hGRb/kCJBqLqd0Feez tMEu0TDRY8fzz4nEb8yvOSiEaL5UjaHZscFsODjwxbM83EHsnngPUrC+26X1n9eU NQiAm3/cojYKFG2iU0C+1n8sgLsZ4w0KcK25SN2vaiOJEVorpHxbwDrZgVzxXf2I yQI+sJqnXiNS0X3g== Received: (qmail 2929796 invoked from network); 6 Sep 2023 22:00:27 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 6 Sep 2023 22:00:27 +0200 X-UD-Smtp-Session: l3s3148p1@xLTUMbYEFIsgAQnoAFZhALrSGIaWNE/A From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Wolfram Sang , Andi Shyti , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] i2c: rcar: avoid non-standard use of goto Date: Wed, 6 Sep 2023 22:00:19 +0200 Message-Id: <20230906200024.5305-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230906200024.5305-1-wsa+renesas@sang-engineering.com> References: <20230906200024.5305-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Kernel functions goto somewhere on error conditions. Using goto for the default path is irritating. Let's bail out on error instead and use a proper retval. Signed-off-by: Wolfram Sang Reviewed-by: Geert Uytterhoeven --- I dropped the Rev-bys because I think the changes are not trivial. YMMV. drivers/i2c/busses/i2c-rcar.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c index a32a93f9a60d..49dfbeebf6b8 100644 --- a/drivers/i2c/busses/i2c-rcar.c +++ b/drivers/i2c/busses/i2c-rcar.c @@ -317,12 +317,12 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_p= riv *priv) for (scgd =3D 0; scgd < 0x40; scgd++) { scl =3D ick / (20 + (scgd * 8) + round); if (scl <=3D t.bus_freq_hz) - goto scgd_find; + break; } - dev_err(dev, "it is impossible to calculate best SCL\n"); - return -EIO; =20 -scgd_find: + if (scgd =3D=3D 0x40) + goto err_no_val; + dev_dbg(dev, "clk %d/%d(%lu), round %u, CDF:0x%x, SCGD: 0x%x\n", scl, t.bus_freq_hz, rate, round, cdf, scgd); =20 @@ -330,6 +330,10 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_pr= iv *priv) priv->icccr =3D scgd << cdf_width | cdf; =20 return 0; + +err_no_val: + dev_err(dev, "it is impossible to calculate best SCL\n"); + return -EINVAL; } =20 /* --=20 2.35.1 From nobody Fri Dec 19 09:42:07 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C3F5EE14C3 for ; Wed, 6 Sep 2023 20:01:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244019AbjIFUBw (ORCPT ); Wed, 6 Sep 2023 16:01:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243633AbjIFUAl (ORCPT ); Wed, 6 Sep 2023 16:00:41 -0400 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADFB719AD for ; Wed, 6 Sep 2023 13:00:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=VJ3mLrt5G3E1weRn20fSYxodtrWVlLm96b4uFr3fzos=; b=aZkUzC 6+9fOrQWoPE38eJ2s/a9wtqjWxSe09Lk7hVxr9EaWPgXmsAdKltFIBL6ocJlPUD+ 3yXiLSSRcaB6GxzZTBlem1/JbPKjFVUcLlCbSGeH986ofxC3uzVBmphK6wM8Qzs+ CnrhsLBDZeZ3tIwuw3kW/+nwpae/bdDgRpmffk75K8lYv2/2gP+WnVfEP88dVqZF T1dW1aRqgSRcALSqQ5vLM4Pxge8LB9Au6uOfveg35m4d0Fs/fh1WVyl1ii7oysyT EerjpVimxgAk5ONL0lWoveZumXoHNvNUo2ZDlbLIPQ7aaQpoJXOE5jXB5Wh8FM4d xiFh9DwHXLP3F+ng== Received: (qmail 2929830 invoked from network); 6 Sep 2023 22:00:27 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 6 Sep 2023 22:00:27 +0200 X-UD-Smtp-Session: l3s3148p1@iKnfMbYEJIsgAQnoAFZhALrSGIaWNE/A From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Wolfram Sang , Andi Shyti , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/5] i2c: rcar: properly format a debug output Date: Wed, 6 Sep 2023 22:00:20 +0200 Message-Id: <20230906200024.5305-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230906200024.5305-1-wsa+renesas@sang-engineering.com> References: <20230906200024.5305-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use proper types and spacing. Signed-off-by: Wolfram Sang Reviewed-by: Geert Uytterhoeven --- drivers/i2c/busses/i2c-rcar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c index 49dfbeebf6b8..4bf47e35094f 100644 --- a/drivers/i2c/busses/i2c-rcar.c +++ b/drivers/i2c/busses/i2c-rcar.c @@ -323,7 +323,7 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_pri= v *priv) if (scgd =3D=3D 0x40) goto err_no_val; =20 - dev_dbg(dev, "clk %d/%d(%lu), round %u, CDF:0x%x, SCGD: 0x%x\n", + dev_dbg(dev, "clk %u/%u(%lu), round %u, CDF: %u, SCGD: %u\n", scl, t.bus_freq_hz, rate, round, cdf, scgd); =20 /* keep icccr value */ --=20 2.35.1 From nobody Fri Dec 19 09:42:07 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50A6AEE14C3 for ; Wed, 6 Sep 2023 20:01:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238860AbjIFUBo (ORCPT ); Wed, 6 Sep 2023 16:01:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243634AbjIFUAl (ORCPT ); Wed, 6 Sep 2023 16:00:41 -0400 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8539219B5 for ; Wed, 6 Sep 2023 13:00:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=xJsHUvQhrLbRjhVbZzw9GQZf+nq+ia33sWzU4P2ylJo=; b=LLsSji ouIYueos70JY0o2u+vtusywFfMoaEnLidS6PvOdmV4mHgxGynGnGfcixrXic068k IetzyAorzwCMqmRanV98lI/fGLmh+onLxnL3uUgb5e6RpTjzOSYt0wDjvJ/21Ah1 +0kKr8neBy5ptgfxZjICHX2SJzuJsfRYN5sVo5mRwYDnpXfXYf8+l6EIBtYzSD6a tbLBr2+rSAZwzYLg7rP8iCn7bzZSqr8zPOwAfSHPEKD8U9bbZWvT5ClvSkyB+rUP nSxkHiT+2kemliuzqSYlp1moanQNvTaTFoYz9QrFDavMhQa3XCGZcnYvemLSG2hL RG+5fConjg1c2SAA== Received: (qmail 2929864 invoked from network); 6 Sep 2023 22:00:28 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 6 Sep 2023 22:00:28 +0200 X-UD-Smtp-Session: l3s3148p1@CvrqMbYELIsgAQnoAFZhALrSGIaWNE/A From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Wolfram Sang , Andi Shyti , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/5] i2c: rcar: calculate divider instead of brute-forcing it Date: Wed, 6 Sep 2023 22:00:21 +0200 Message-Id: <20230906200024.5305-4-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230906200024.5305-1-wsa+renesas@sang-engineering.com> References: <20230906200024.5305-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Instead of trying all values, we can actually compute it as the comment suggests. It is unclear what the comment means with "involved", it works nicely. Signed-off-by: Wolfram Sang Reviewed-by: Geert Uytterhoeven --- @Geert: I hope the formulas are more clear now? @Andi: I don't think that replacing 0x3f with a define helps understanding the code, but I am open for discussion. drivers/i2c/busses/i2c-rcar.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c index 4bf47e35094f..2585092bed52 100644 --- a/drivers/i2c/busses/i2c-rcar.c +++ b/drivers/i2c/busses/i2c-rcar.c @@ -303,24 +303,16 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_p= riv *priv) round =3D (round + 500) / 1000; =20 /* - * SCL =3D ick / (20 + SCGD * 8 + F[(ticf + tr + intd) * ick]) - * - * Calculation result (=3D SCL) should be less than - * bus_speed for hardware safety - * - * We could use something along the lines of - * div =3D ick / (bus_speed + 1) + 1; - * scgd =3D (div - 20 - round + 7) / 8; - * scl =3D ick / (20 + (scgd * 8) + round); - * (not fully verified) but that would get pretty involved + * SCL =3D ick / (20 + 8 * SCGD + F[(ticf + tr + intd) * ick]) + * 20 + 8 * SCGD + F[...] =3D ick / SCL + * SCGD =3D ((ick / SCL) - 20 - F[...]) / 8 + * Result (=3D SCL) should be less than bus_speed for hardware safety */ - for (scgd =3D 0; scgd < 0x40; scgd++) { - scl =3D ick / (20 + (scgd * 8) + round); - if (scl <=3D t.bus_freq_hz) - break; - } + scgd =3D DIV_ROUND_UP(ick, t.bus_freq_hz ?: 1); + scgd =3D DIV_ROUND_UP(scgd - 20 - round, 8); + scl =3D ick / (20 + 8 * scgd + round); =20 - if (scgd =3D=3D 0x40) + if (scgd > 0x3f) goto err_no_val; =20 dev_dbg(dev, "clk %u/%u(%lu), round %u, CDF: %u, SCGD: %u\n", --=20 2.35.1 From nobody Fri Dec 19 09:42:07 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D12E2EE14D0 for ; Wed, 6 Sep 2023 20:01:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243608AbjIFUBd (ORCPT ); Wed, 6 Sep 2023 16:01:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243670AbjIFUAr (ORCPT ); Wed, 6 Sep 2023 16:00:47 -0400 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 044AD19BB for ; Wed, 6 Sep 2023 13:00:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=qBxfS0Tf9/DuCfn43C/vkUHINEKl9b1xtv2hh3LyJBc=; b=WtJQe8 FjFl6HiiP8WWG9mzP6zVQ7QuR9MoB+naxEwOr9MyS8o7x3/QlrqH5XO/TebRww0W fAErrRq3ehSD9b9bm3pBZtJ2XMU8A5p9ZRq5cISp7MVKNxmso+NseOJmbYm0g7Yb iFhNpMwcxmXXPXyXu29BSGqnjX4sHnm1YuhfxsgeHQLnXgDCcAkXi8BnLNzQIFN4 CbbNdCpLNlF5jf9omb0zI1vEAof9brCMHSK7WLxJIFC1u2z4P/79658OfngiAd4k TFjxOYyEvw22CxnANUlUvi8C7z6+USSe0O3Dqd3TuYwHxCBv99BqC2omwJTG9lTu tjiE0VEaYSBWu3Xg== Received: (qmail 2929897 invoked from network); 6 Sep 2023 22:00:29 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 6 Sep 2023 22:00:29 +0200 X-UD-Smtp-Session: l3s3148p1@Rij2MbYENIsgAQnoAFZhALrSGIaWNE/A From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Wolfram Sang , Andi Shyti , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/5] i2c: rcar: remove open coded DIV_ROUND_CLOSEST Date: Wed, 6 Sep 2023 22:00:22 +0200 Message-Id: <20230906200024.5305-5-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230906200024.5305-1-wsa+renesas@sang-engineering.com> References: <20230906200024.5305-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" It improves readability if we use the available helper. Signed-off-by: Wolfram Sang Reviewed-by: Geert Uytterhoeven --- drivers/i2c/busses/i2c-rcar.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c index 2585092bed52..5e97635faf78 100644 --- a/drivers/i2c/busses/i2c-rcar.c +++ b/drivers/i2c/busses/i2c-rcar.c @@ -291,16 +291,15 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_p= riv *priv) ick =3D rate / (cdf + 1); =20 /* - * it is impossible to calculate large scale - * number on u32. separate it + * It is impossible to calculate a large scale number on u32. Separate it. * * F[(ticf + tr + intd) * ick] with sum =3D (ticf + tr + intd) * =3D F[sum * ick / 1000000000] * =3D F[(ick / 1000000) * sum / 1000] */ sum =3D t.scl_fall_ns + t.scl_rise_ns + t.scl_int_delay_ns; - round =3D (ick + 500000) / 1000000 * sum; - round =3D (round + 500) / 1000; + round =3D DIV_ROUND_CLOSEST(ick, 1000000); + round =3D DIV_ROUND_CLOSEST(round * sum, 1000); =20 /* * SCL =3D ick / (20 + 8 * SCGD + F[(ticf + tr + intd) * ick]) --=20 2.35.1 From nobody Fri Dec 19 09:42:07 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3860AEE14C3 for ; Wed, 6 Sep 2023 20:01:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244232AbjIFUBh (ORCPT ); Wed, 6 Sep 2023 16:01:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243186AbjIFUAr (ORCPT ); Wed, 6 Sep 2023 16:00:47 -0400 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1733519BF for ; Wed, 6 Sep 2023 13:00:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=b7rT9wKJbxCEtc/9yaA+sRK1E4pHjRX6I/sjz0k8OFI=; b=XkyC9W SX7VufPiTrmKAmknt+S/jhNIMLXAsM5CelCu9rasnkZBlJcVz8lYKgvAJAxTrKcU RoPxNqXTxx20jVaGWZiq9/umbtkdM3Zb5qIBjrCrXIiCiXdBJZhwBnh2R7zdA3gI 9jb6wJ2weDhLDQ/eeaVN1SURDC4aUPY0mjBhzyxhHASxPL6EZ8pzanDZI4eu0I+X oAXFMUq0iR32cGvVPNedhwQ1HcupXLGPJK20bTqs/gGM+XWqHMo5N0lP52Iq5pXB YF0zz1cvHcT4k0gaI1Fqo1xYTtRkjosts1lpOZgxuZNc1yfatSkuyYO3sLrNIWa/ mhya5NnN/zYNuIzw== Received: (qmail 2929932 invoked from network); 6 Sep 2023 22:00:30 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 6 Sep 2023 22:00:30 +0200 X-UD-Smtp-Session: l3s3148p1@kxsBMrYEOIsgAQnoAFZhALrSGIaWNE/A From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Wolfram Sang , Chris Brandt , Andi Shyti , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/5] i2c: riic: avoid potential division by zero Date: Wed, 6 Sep 2023 22:00:23 +0200 Message-Id: <20230906200024.5305-6-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230906200024.5305-1-wsa+renesas@sang-engineering.com> References: <20230906200024.5305-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Value comes from DT, so it could be 0. Unlikely, but could be. Signed-off-by: Wolfram Sang Reviewed-by: Geert Uytterhoeven --- drivers/i2c/busses/i2c-riic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index f0ee8871d5ae..e43ff483c56e 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -313,7 +313,7 @@ static int riic_init_hw(struct riic_dev *riic, struct i= 2c_timings *t) * frequency with only 62 clock ticks max (31 high, 31 low). * Aim for a duty of 60% LOW, 40% HIGH. */ - total_ticks =3D DIV_ROUND_UP(rate, t->bus_freq_hz); + total_ticks =3D DIV_ROUND_UP(rate, t->bus_freq_hz ?: 1); =20 for (cks =3D 0; cks < 7; cks++) { /* --=20 2.35.1