public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v1 0/7] i2c: busses: Introduce and use HZ_PER_GHZ
@ 2026-01-12 13:46 Andy Shevchenko
  2026-01-12 13:46 ` [PATCH v1 1/7] units: Add HZ_PER_GHZ Andy Shevchenko
                   ` (9 more replies)
  0 siblings, 10 replies; 17+ messages in thread
From: Andy Shevchenko @ 2026-01-12 13:46 UTC (permalink / raw)
  To: Andi Shyti, Andy Shevchenko, Wolfram Sang, Qianfeng Rong,
	linux-i2c, linux-kernel, linux-arm-kernel, linux-mediatek,
	linux-rockchip
  Cc: Khalil Blaiech, Asmaa Mnebhi, Andi Shyti, Qii Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Linus Walleij,
	Heiko Stuebner, Patrice Chotard, Ard Biesheuvel

A few drivers for I²C host controllers use HZ_PER_GHZ in numeric form.
This is less readable and prone to subtle mistakes. Instead, introduce
a well defined constant and use it in the drivers. No functional change
implied except one case where 64-bit division replaced with 32-bit one.

Andy Shevchenko (7):
  units: Add HZ_PER_GHZ
  i2c: mlxbf: Use HZ_PER_GHZ constant instead of custom one
  i2c: mt65xx: Use HZ_PER_GHZ constant instead of plain number
  i2c: nomadik: Use HZ_PER_GHZ constant instead of plain number
  i2c: rk3x: Use HZ_PER_GHZ constant instead of plain number
  i2c: st: Use HZ_PER_GHZ constant instead of plain number
  i2c: synquacer: Use HZ_PER_GHZ constant instead of plain number

 drivers/i2c/busses/i2c-mlxbf.c     |  5 ++---
 drivers/i2c/busses/i2c-mt65xx.c    | 11 ++++++-----
 drivers/i2c/busses/i2c-nomadik.c   |  7 ++++---
 drivers/i2c/busses/i2c-rk3x.c      | 12 ++++++------
 drivers/i2c/busses/i2c-st.c        |  3 ++-
 drivers/i2c/busses/i2c-synquacer.c |  3 ++-
 include/linux/units.h              |  3 +++
 7 files changed, 25 insertions(+), 19 deletions(-)

-- 
2.50.1



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v1 1/7] units: Add HZ_PER_GHZ
  2026-01-12 13:46 [PATCH v1 0/7] i2c: busses: Introduce and use HZ_PER_GHZ Andy Shevchenko
@ 2026-01-12 13:46 ` Andy Shevchenko
  2026-01-12 15:48   ` Linus Walleij
  2026-01-13 14:23   ` Andi Shyti
  2026-01-12 13:46 ` [PATCH v1 2/7] i2c: mlxbf: Use HZ_PER_GHZ constant instead of custom one Andy Shevchenko
                   ` (8 subsequent siblings)
  9 siblings, 2 replies; 17+ messages in thread
From: Andy Shevchenko @ 2026-01-12 13:46 UTC (permalink / raw)
  To: Andi Shyti, Andy Shevchenko, Wolfram Sang, Qianfeng Rong,
	linux-i2c, linux-kernel, linux-arm-kernel, linux-mediatek,
	linux-rockchip
  Cc: Khalil Blaiech, Asmaa Mnebhi, Andi Shyti, Qii Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Linus Walleij,
	Heiko Stuebner, Patrice Chotard, Ard Biesheuvel

The is going to be a new user of the HZ_PER_GHZ definition besides
possibly existing ones. Add that one to the header.

While at it, split Hz and kHz groups of the multipliers for better
maintenance and readability.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/units.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/units.h b/include/linux/units.h
index 00e15de33eca..0c296a004e89 100644
--- a/include/linux/units.h
+++ b/include/linux/units.h
@@ -25,9 +25,12 @@
 #define MICROHZ_PER_HZ		1000000UL
 #define MILLIHZ_PER_HZ		1000UL
 
+/* Hz based multipliers */
 #define HZ_PER_KHZ		1000UL
 #define HZ_PER_MHZ		1000000UL
+#define HZ_PER_GHZ		1000000000UL
 
+/* kHz based multipliers */
 #define KHZ_PER_MHZ		1000UL
 #define KHZ_PER_GHZ		1000000UL
 
-- 
2.50.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v1 2/7] i2c: mlxbf: Use HZ_PER_GHZ constant instead of custom one
  2026-01-12 13:46 [PATCH v1 0/7] i2c: busses: Introduce and use HZ_PER_GHZ Andy Shevchenko
  2026-01-12 13:46 ` [PATCH v1 1/7] units: Add HZ_PER_GHZ Andy Shevchenko
@ 2026-01-12 13:46 ` Andy Shevchenko
  2026-01-12 13:46 ` [PATCH v1 3/7] i2c: mt65xx: Use HZ_PER_GHZ constant instead of plain number Andy Shevchenko
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Andy Shevchenko @ 2026-01-12 13:46 UTC (permalink / raw)
  To: Andi Shyti, Andy Shevchenko, Wolfram Sang, Qianfeng Rong,
	linux-i2c, linux-kernel, linux-arm-kernel, linux-mediatek,
	linux-rockchip
  Cc: Khalil Blaiech, Asmaa Mnebhi, Andi Shyti, Qii Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Linus Walleij,
	Heiko Stuebner, Patrice Chotard, Ard Biesheuvel

Use HZ_PER_GHZ constant instead of custom one. No functional changes.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/i2c-mlxbf.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mlxbf.c b/drivers/i2c/busses/i2c-mlxbf.c
index 8345f7e6385d..746f65989138 100644
--- a/drivers/i2c/busses/i2c-mlxbf.c
+++ b/drivers/i2c/busses/i2c-mlxbf.c
@@ -20,6 +20,7 @@
 #include <linux/platform_device.h>
 #include <linux/string.h>
 #include <linux/string_choices.h>
+#include <linux/units.h>
 
 /* Defines what functionality is present. */
 #define MLXBF_I2C_FUNC_SMBUS_BLOCK \
@@ -72,8 +73,6 @@
 /* Constant used to determine the PLL frequency. */
 #define MLNXBF_I2C_COREPLL_CONST    16384ULL
 
-#define MLXBF_I2C_FREQUENCY_1GHZ  1000000000ULL
-
 /* PLL registers. */
 #define MLXBF_I2C_CORE_PLL_REG1         0x4
 #define MLXBF_I2C_CORE_PLL_REG2         0x8
@@ -1083,7 +1082,7 @@ static u32 mlxbf_i2c_get_ticks(struct mlxbf_i2c_priv *priv, u64 nanoseconds,
 	 *         Frequency
 	 */
 	frequency = priv->frequency;
-	ticks = div_u64(nanoseconds * frequency, MLXBF_I2C_FREQUENCY_1GHZ);
+	ticks = div_u64(nanoseconds * frequency, HZ_PER_GHZ);
 	/*
 	 * The number of ticks is rounded down and if minimum is equal to 1
 	 * then add one tick.
-- 
2.50.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v1 3/7] i2c: mt65xx: Use HZ_PER_GHZ constant instead of plain number
  2026-01-12 13:46 [PATCH v1 0/7] i2c: busses: Introduce and use HZ_PER_GHZ Andy Shevchenko
  2026-01-12 13:46 ` [PATCH v1 1/7] units: Add HZ_PER_GHZ Andy Shevchenko
  2026-01-12 13:46 ` [PATCH v1 2/7] i2c: mlxbf: Use HZ_PER_GHZ constant instead of custom one Andy Shevchenko
@ 2026-01-12 13:46 ` Andy Shevchenko
  2026-01-12 13:46 ` [PATCH v1 4/7] i2c: nomadik: " Andy Shevchenko
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Andy Shevchenko @ 2026-01-12 13:46 UTC (permalink / raw)
  To: Andi Shyti, Andy Shevchenko, Wolfram Sang, Qianfeng Rong,
	linux-i2c, linux-kernel, linux-arm-kernel, linux-mediatek,
	linux-rockchip
  Cc: Khalil Blaiech, Asmaa Mnebhi, Andi Shyti, Qii Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Linus Walleij,
	Heiko Stuebner, Patrice Chotard, Ard Biesheuvel

Use defined constant to avoid the possible mistakes and to provide
an additional information on the units.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/i2c-mt65xx.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
index aefdbee1f03c..cb4d3aa709d0 100644
--- a/drivers/i2c/busses/i2c-mt65xx.c
+++ b/drivers/i2c/busses/i2c-mt65xx.c
@@ -24,6 +24,7 @@
 #include <linux/scatterlist.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
+#include <linux/units.h>
 
 #define I2C_RS_TRANSFER			(1 << 4)
 #define I2C_ARB_LOST			(1 << 3)
@@ -685,7 +686,7 @@ static int mtk_i2c_get_clk_div_restri(struct mtk_i2c *i2c,
  * Check and Calculate i2c ac-timing
  *
  * Hardware design:
- * sample_ns = (1000000000 * (sample_cnt + 1)) / clk_src
+ * sample_ns = (HZ_PER_GHZ * (sample_cnt + 1)) / clk_src
  * xxx_cnt_div =  spec->min_xxx_ns / sample_ns
  *
  * Sample_ns is rounded down for xxx_cnt_div would be greater
@@ -701,9 +702,8 @@ static int mtk_i2c_check_ac_timing(struct mtk_i2c *i2c,
 {
 	const struct i2c_spec_values *spec;
 	unsigned int su_sta_cnt, low_cnt, high_cnt, max_step_cnt;
-	unsigned int sda_max, sda_min, clk_ns, max_sta_cnt = 0x3f;
-	unsigned int sample_ns = div_u64(1000000000ULL * (sample_cnt + 1),
-					 clk_src);
+	unsigned int sda_max, sda_min, max_sta_cnt = 0x3f;
+	unsigned int clk_ns, sample_ns;
 
 	if (!i2c->dev_comp->timing_adjust)
 		return 0;
@@ -713,8 +713,9 @@ static int mtk_i2c_check_ac_timing(struct mtk_i2c *i2c,
 
 	spec = mtk_i2c_get_spec(check_speed);
 
+	sample_ns = div_u64(1ULL * HZ_PER_GHZ * (sample_cnt + 1), clk_src);
 	if (i2c->dev_comp->ltiming_adjust)
-		clk_ns = 1000000000 / clk_src;
+		clk_ns = HZ_PER_GHZ / clk_src;
 	else
 		clk_ns = sample_ns / 2;
 
-- 
2.50.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v1 4/7] i2c: nomadik: Use HZ_PER_GHZ constant instead of plain number
  2026-01-12 13:46 [PATCH v1 0/7] i2c: busses: Introduce and use HZ_PER_GHZ Andy Shevchenko
                   ` (2 preceding siblings ...)
  2026-01-12 13:46 ` [PATCH v1 3/7] i2c: mt65xx: Use HZ_PER_GHZ constant instead of plain number Andy Shevchenko
@ 2026-01-12 13:46 ` Andy Shevchenko
  2026-01-12 15:52   ` Linus Walleij
  2026-01-12 13:46 ` [PATCH v1 5/7] i2c: rk3x: " Andy Shevchenko
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 17+ messages in thread
From: Andy Shevchenko @ 2026-01-12 13:46 UTC (permalink / raw)
  To: Andi Shyti, Andy Shevchenko, Wolfram Sang, Qianfeng Rong,
	linux-i2c, linux-kernel, linux-arm-kernel, linux-mediatek,
	linux-rockchip
  Cc: Khalil Blaiech, Asmaa Mnebhi, Andi Shyti, Qii Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Linus Walleij,
	Heiko Stuebner, Patrice Chotard, Ard Biesheuvel

Use defined constant to avoid the possible mistakes and to provide
an additional information on the units.

While at it, drop unneeded 64-bit division, all operands fit 32-bit.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/i2c-nomadik.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 19b648fc094d..b63ee51c1652 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -31,6 +31,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
+#include <linux/units.h>
 
 #define DRIVER_NAME "nmk-i2c"
 
@@ -419,10 +420,10 @@ static void setup_i2c_controller(struct nmk_i2c_dev *priv)
 	 * modes are 250ns, 100ns, 10ns respectively.
 	 *
 	 * As the time for one cycle T in nanoseconds is
-	 * T = (1/f) * 1000000000 =>
-	 * slsu = cycles / (1000000000 / f) + 1
+	 * T = (1/f) * HZ_PER_GHZ =>
+	 * slsu = cycles / (HZ_PER_GHZ / f) + 1
 	 */
-	ns = DIV_ROUND_UP_ULL(1000000000ULL, i2c_clk);
+	ns = DIV_ROUND_UP(HZ_PER_GHZ, i2c_clk);
 	switch (priv->sm) {
 	case I2C_FREQ_MODE_FAST:
 	case I2C_FREQ_MODE_FAST_PLUS:
-- 
2.50.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v1 5/7] i2c: rk3x: Use HZ_PER_GHZ constant instead of plain number
  2026-01-12 13:46 [PATCH v1 0/7] i2c: busses: Introduce and use HZ_PER_GHZ Andy Shevchenko
                   ` (3 preceding siblings ...)
  2026-01-12 13:46 ` [PATCH v1 4/7] i2c: nomadik: " Andy Shevchenko
@ 2026-01-12 13:46 ` Andy Shevchenko
  2026-01-13 15:10   ` Heiko Stübner
  2026-01-12 13:46 ` [PATCH v1 6/7] i2c: st: " Andy Shevchenko
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 17+ messages in thread
From: Andy Shevchenko @ 2026-01-12 13:46 UTC (permalink / raw)
  To: Andi Shyti, Andy Shevchenko, Wolfram Sang, Qianfeng Rong,
	linux-i2c, linux-kernel, linux-arm-kernel, linux-mediatek,
	linux-rockchip
  Cc: Khalil Blaiech, Asmaa Mnebhi, Andi Shyti, Qii Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Linus Walleij,
	Heiko Stuebner, Patrice Chotard, Ard Biesheuvel

Use defined constant to avoid the possible mistakes and to provide
an additional information on the units.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/i2c-rk3x.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c
index d4e9196445c0..fcede9f6ed54 100644
--- a/drivers/i2c/busses/i2c-rk3x.c
+++ b/drivers/i2c/busses/i2c-rk3x.c
@@ -19,6 +19,7 @@
 #include <linux/of_irq.h>
 #include <linux/spinlock.h>
 #include <linux/clk.h>
+#include <linux/units.h>
 #include <linux/wait.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
@@ -896,13 +897,12 @@ static void rk3x_i2c_adapt_div(struct rk3x_i2c *i2c, unsigned long clk_rate)
 
 	clk_disable(i2c->pclk);
 
-	t_low_ns = div_u64(((u64)calc.div_low + 1) * 8 * 1000000000, clk_rate);
-	t_high_ns = div_u64(((u64)calc.div_high + 1) * 8 * 1000000000,
-			    clk_rate);
+	t_low_ns = div_u64(8ULL * HZ_PER_GHZ * (calc.div_low + 1), clk_rate);
+	t_high_ns = div_u64(8ULL * HZ_PER_GHZ * (calc.div_high + 1), clk_rate);
 	dev_dbg(i2c->dev,
-		"CLK %lukhz, Req %uns, Act low %lluns high %lluns\n",
-		clk_rate / 1000,
-		1000000000 / t->bus_freq_hz,
+		"CLK %lukHz, Req %luns, Act low %lluns high %lluns\n",
+		clk_rate / HZ_PER_KHZ,
+		HZ_PER_GHZ / t->bus_freq_hz,
 		t_low_ns, t_high_ns);
 }
 
-- 
2.50.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v1 6/7] i2c: st: Use HZ_PER_GHZ constant instead of plain number
  2026-01-12 13:46 [PATCH v1 0/7] i2c: busses: Introduce and use HZ_PER_GHZ Andy Shevchenko
                   ` (4 preceding siblings ...)
  2026-01-12 13:46 ` [PATCH v1 5/7] i2c: rk3x: " Andy Shevchenko
@ 2026-01-12 13:46 ` Andy Shevchenko
  2026-01-13 15:29   ` Patrice CHOTARD
  2026-01-12 13:46 ` [PATCH v1 7/7] i2c: synquacer: " Andy Shevchenko
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 17+ messages in thread
From: Andy Shevchenko @ 2026-01-12 13:46 UTC (permalink / raw)
  To: Andi Shyti, Andy Shevchenko, Wolfram Sang, Qianfeng Rong,
	linux-i2c, linux-kernel, linux-arm-kernel, linux-mediatek,
	linux-rockchip
  Cc: Khalil Blaiech, Asmaa Mnebhi, Andi Shyti, Qii Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Linus Walleij,
	Heiko Stuebner, Patrice Chotard, Ard Biesheuvel

Use defined constant to avoid the possible mistakes and to provide
an additional information on the units.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/i2c-st.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-st.c b/drivers/i2c/busses/i2c-st.c
index 97d70e667227..751ea421caaf 100644
--- a/drivers/i2c/busses/i2c-st.c
+++ b/drivers/i2c/busses/i2c-st.c
@@ -20,6 +20,7 @@
 #include <linux/of.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
+#include <linux/units.h>
 
 /* SSC registers */
 #define SSC_BRG				0x000
@@ -285,7 +286,7 @@ static void st_i2c_hw_config(struct st_i2c_dev *i2c_dev)
 	writel_relaxed(val, i2c_dev->base + SSC_CTL);
 
 	rate = clk_get_rate(i2c_dev->clk);
-	ns_per_clk = 1000000000 / rate;
+	ns_per_clk = HZ_PER_GHZ / rate;
 
 	/* Baudrate */
 	val = rate / (2 * t->rate);
-- 
2.50.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v1 7/7] i2c: synquacer: Use HZ_PER_GHZ constant instead of plain number
  2026-01-12 13:46 [PATCH v1 0/7] i2c: busses: Introduce and use HZ_PER_GHZ Andy Shevchenko
                   ` (5 preceding siblings ...)
  2026-01-12 13:46 ` [PATCH v1 6/7] i2c: st: " Andy Shevchenko
@ 2026-01-12 13:46 ` Andy Shevchenko
  2026-01-12 16:15 ` [PATCH v1 0/7] i2c: busses: Introduce and use HZ_PER_GHZ AngeloGioacchino Del Regno
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Andy Shevchenko @ 2026-01-12 13:46 UTC (permalink / raw)
  To: Andi Shyti, Andy Shevchenko, Wolfram Sang, Qianfeng Rong,
	linux-i2c, linux-kernel, linux-arm-kernel, linux-mediatek,
	linux-rockchip
  Cc: Khalil Blaiech, Asmaa Mnebhi, Andi Shyti, Qii Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Linus Walleij,
	Heiko Stuebner, Patrice Chotard, Ard Biesheuvel

Use defined constant to avoid the possible mistakes and to provide
an additional information on the units.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/i2c-synquacer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-synquacer.c b/drivers/i2c/busses/i2c-synquacer.c
index 1230f51e1624..4891d68bf0ee 100644
--- a/drivers/i2c/busses/i2c-synquacer.c
+++ b/drivers/i2c/busses/i2c-synquacer.c
@@ -18,9 +18,10 @@
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/units.h>
 
 #define WAIT_PCLK(n, rate)	\
-	ndelay(DIV_ROUND_UP(DIV_ROUND_UP(1000000000, rate), n) + 10)
+	ndelay(DIV_ROUND_UP(DIV_ROUND_UP(HZ_PER_GHZ, rate), n) + 10)
 
 /* I2C register address definitions */
 #define SYNQUACER_I2C_REG_BSR		(0x00 << 2) // Bus Status
-- 
2.50.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH v1 1/7] units: Add HZ_PER_GHZ
  2026-01-12 13:46 ` [PATCH v1 1/7] units: Add HZ_PER_GHZ Andy Shevchenko
@ 2026-01-12 15:48   ` Linus Walleij
  2026-01-13 14:23   ` Andi Shyti
  1 sibling, 0 replies; 17+ messages in thread
From: Linus Walleij @ 2026-01-12 15:48 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Andi Shyti, Wolfram Sang, Qianfeng Rong, linux-i2c, linux-kernel,
	linux-arm-kernel, linux-mediatek, linux-rockchip, Khalil Blaiech,
	Asmaa Mnebhi, Andi Shyti, Qii Wang, Matthias Brugger,
	AngeloGioacchino Del Regno, Heiko Stuebner, Patrice Chotard,
	Ard Biesheuvel

On Mon, Jan 12, 2026 at 2:49 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> The is going to be a new user of the HZ_PER_GHZ definition besides
> possibly existing ones. Add that one to the header.
>
> While at it, split Hz and kHz groups of the multipliers for better
> maintenance and readability.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

This looks right to me:
Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v1 4/7] i2c: nomadik: Use HZ_PER_GHZ constant instead of plain number
  2026-01-12 13:46 ` [PATCH v1 4/7] i2c: nomadik: " Andy Shevchenko
@ 2026-01-12 15:52   ` Linus Walleij
  0 siblings, 0 replies; 17+ messages in thread
From: Linus Walleij @ 2026-01-12 15:52 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Andi Shyti, Wolfram Sang, Qianfeng Rong, linux-i2c, linux-kernel,
	linux-arm-kernel, linux-mediatek, linux-rockchip, Khalil Blaiech,
	Asmaa Mnebhi, Andi Shyti, Qii Wang, Matthias Brugger,
	AngeloGioacchino Del Regno, Heiko Stuebner, Patrice Chotard,
	Ard Biesheuvel

On Mon, Jan 12, 2026 at 2:49 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> Use defined constant to avoid the possible mistakes and to provide
> an additional information on the units.
>
> While at it, drop unneeded 64-bit division, all operands fit 32-bit.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

It makes perfect sense, I don't remember why I put ULL in there
anymore :/

Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v1 0/7] i2c: busses: Introduce and use HZ_PER_GHZ
  2026-01-12 13:46 [PATCH v1 0/7] i2c: busses: Introduce and use HZ_PER_GHZ Andy Shevchenko
                   ` (6 preceding siblings ...)
  2026-01-12 13:46 ` [PATCH v1 7/7] i2c: synquacer: " Andy Shevchenko
@ 2026-01-12 16:15 ` AngeloGioacchino Del Regno
  2026-01-13 15:28 ` Wolfram Sang
  2026-01-14  7:36 ` Andi Shyti
  9 siblings, 0 replies; 17+ messages in thread
From: AngeloGioacchino Del Regno @ 2026-01-12 16:15 UTC (permalink / raw)
  To: Andy Shevchenko, Andi Shyti, Wolfram Sang, Qianfeng Rong,
	linux-i2c, linux-kernel, linux-arm-kernel, linux-mediatek,
	linux-rockchip
  Cc: Khalil Blaiech, Asmaa Mnebhi, Andi Shyti, Qii Wang,
	Matthias Brugger, Linus Walleij, Heiko Stuebner, Patrice Chotard,
	Ard Biesheuvel

Il 12/01/26 14:46, Andy Shevchenko ha scritto:
> A few drivers for I²C host controllers use HZ_PER_GHZ in numeric form.
> This is less readable and prone to subtle mistakes. Instead, introduce
> a well defined constant and use it in the drivers. No functional change
> implied except one case where 64-bit division replaced with 32-bit one.
> 
> Andy Shevchenko (7):
>    units: Add HZ_PER_GHZ
>    i2c: mlxbf: Use HZ_PER_GHZ constant instead of custom one
>    i2c: mt65xx: Use HZ_PER_GHZ constant instead of plain number
>    i2c: nomadik: Use HZ_PER_GHZ constant instead of plain number
>    i2c: rk3x: Use HZ_PER_GHZ constant instead of plain number
>    i2c: st: Use HZ_PER_GHZ constant instead of plain number
>    i2c: synquacer: Use HZ_PER_GHZ constant instead of plain number
> 
>   drivers/i2c/busses/i2c-mlxbf.c     |  5 ++---
>   drivers/i2c/busses/i2c-mt65xx.c    | 11 ++++++-----
>   drivers/i2c/busses/i2c-nomadik.c   |  7 ++++---
>   drivers/i2c/busses/i2c-rk3x.c      | 12 ++++++------
>   drivers/i2c/busses/i2c-st.c        |  3 ++-
>   drivers/i2c/busses/i2c-synquacer.c |  3 ++-
>   include/linux/units.h              |  3 +++
>   7 files changed, 25 insertions(+), 19 deletions(-)
> 

Whole series is

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v1 1/7] units: Add HZ_PER_GHZ
  2026-01-12 13:46 ` [PATCH v1 1/7] units: Add HZ_PER_GHZ Andy Shevchenko
  2026-01-12 15:48   ` Linus Walleij
@ 2026-01-13 14:23   ` Andi Shyti
  1 sibling, 0 replies; 17+ messages in thread
From: Andi Shyti @ 2026-01-13 14:23 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Andi Shyti, Wolfram Sang, Qianfeng Rong, linux-i2c, linux-kernel,
	linux-arm-kernel, linux-mediatek, linux-rockchip, Khalil Blaiech,
	Asmaa Mnebhi, Qii Wang, Matthias Brugger,
	AngeloGioacchino Del Regno, Linus Walleij, Heiko Stuebner,
	Patrice Chotard, Ard Biesheuvel

Hi Andy,

On Mon, Jan 12, 2026 at 02:46:09PM +0100, Andy Shevchenko wrote:
> The is going to be a new user of the HZ_PER_GHZ definition besides
> possibly existing ones. Add that one to the header.
> 
> While at it, split Hz and kHz groups of the multipliers for better
> maintenance and readability.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Andi Shyti <andi.shyti@kernel.org>

I'm taking this via i2c if no one is against.

Andi


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v1 5/7] i2c: rk3x: Use HZ_PER_GHZ constant instead of plain number
  2026-01-12 13:46 ` [PATCH v1 5/7] i2c: rk3x: " Andy Shevchenko
@ 2026-01-13 15:10   ` Heiko Stübner
  0 siblings, 0 replies; 17+ messages in thread
From: Heiko Stübner @ 2026-01-13 15:10 UTC (permalink / raw)
  To: Andi Shyti, Andy Shevchenko, Wolfram Sang, Qianfeng Rong,
	linux-i2c, linux-kernel, linux-arm-kernel, linux-mediatek,
	linux-rockchip, Andy Shevchenko
  Cc: Khalil Blaiech, Asmaa Mnebhi, Andi Shyti, Qii Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Linus Walleij,
	Patrice Chotard, Ard Biesheuvel

Am Montag, 12. Januar 2026, 14:46:13 Mitteleuropäische Normalzeit schrieb Andy Shevchenko:
> Use defined constant to avoid the possible mistakes and to provide
> an additional information on the units.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Heiko Stuebner <heiko@sntech.de>




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v1 0/7] i2c: busses: Introduce and use HZ_PER_GHZ
  2026-01-12 13:46 [PATCH v1 0/7] i2c: busses: Introduce and use HZ_PER_GHZ Andy Shevchenko
                   ` (7 preceding siblings ...)
  2026-01-12 16:15 ` [PATCH v1 0/7] i2c: busses: Introduce and use HZ_PER_GHZ AngeloGioacchino Del Regno
@ 2026-01-13 15:28 ` Wolfram Sang
  2026-01-14  7:36 ` Andi Shyti
  9 siblings, 0 replies; 17+ messages in thread
From: Wolfram Sang @ 2026-01-13 15:28 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Andi Shyti, Qianfeng Rong, linux-i2c, linux-kernel,
	linux-arm-kernel, linux-mediatek, linux-rockchip, Khalil Blaiech,
	Asmaa Mnebhi, Andi Shyti, Qii Wang, Matthias Brugger,
	AngeloGioacchino Del Regno, Linus Walleij, Heiko Stuebner,
	Patrice Chotard, Ard Biesheuvel

On Mon, Jan 12, 2026 at 02:46:08PM +0100, Andy Shevchenko wrote:
> A few drivers for I²C host controllers use HZ_PER_GHZ in numeric form.
> This is less readable and prone to subtle mistakes. Instead, introduce
> a well defined constant and use it in the drivers. No functional change
> implied except one case where 64-bit division replaced with 32-bit one.
> 
> Andy Shevchenko (7):
>   units: Add HZ_PER_GHZ
>   i2c: mlxbf: Use HZ_PER_GHZ constant instead of custom one
>   i2c: mt65xx: Use HZ_PER_GHZ constant instead of plain number
>   i2c: nomadik: Use HZ_PER_GHZ constant instead of plain number
>   i2c: rk3x: Use HZ_PER_GHZ constant instead of plain number
>   i2c: st: Use HZ_PER_GHZ constant instead of plain number
>   i2c: synquacer: Use HZ_PER_GHZ constant instead of plain number
> 

Fine with me:

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v1 6/7] i2c: st: Use HZ_PER_GHZ constant instead of plain number
  2026-01-12 13:46 ` [PATCH v1 6/7] i2c: st: " Andy Shevchenko
@ 2026-01-13 15:29   ` Patrice CHOTARD
  0 siblings, 0 replies; 17+ messages in thread
From: Patrice CHOTARD @ 2026-01-13 15:29 UTC (permalink / raw)
  To: Andy Shevchenko, Andi Shyti, Wolfram Sang, Qianfeng Rong,
	linux-i2c, linux-kernel, linux-arm-kernel, linux-mediatek,
	linux-rockchip
  Cc: Khalil Blaiech, Asmaa Mnebhi, Andi Shyti, Qii Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Linus Walleij,
	Heiko Stuebner, Ard Biesheuvel



On 1/12/26 14:46, Andy Shevchenko wrote:
> Use defined constant to avoid the possible mistakes and to provide
> an additional information on the units.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/i2c/busses/i2c-st.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-st.c b/drivers/i2c/busses/i2c-st.c
> index 97d70e667227..751ea421caaf 100644
> --- a/drivers/i2c/busses/i2c-st.c
> +++ b/drivers/i2c/busses/i2c-st.c
> @@ -20,6 +20,7 @@
>  #include <linux/of.h>
>  #include <linux/pinctrl/consumer.h>
>  #include <linux/platform_device.h>
> +#include <linux/units.h>
>  
>  /* SSC registers */
>  #define SSC_BRG				0x000
> @@ -285,7 +286,7 @@ static void st_i2c_hw_config(struct st_i2c_dev *i2c_dev)
>  	writel_relaxed(val, i2c_dev->base + SSC_CTL);
>  
>  	rate = clk_get_rate(i2c_dev->clk);
> -	ns_per_clk = 1000000000 / rate;
> +	ns_per_clk = HZ_PER_GHZ / rate;
>  
>  	/* Baudrate */
>  	val = rate / (2 * t->rate);

Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v1 0/7] i2c: busses: Introduce and use HZ_PER_GHZ
  2026-01-12 13:46 [PATCH v1 0/7] i2c: busses: Introduce and use HZ_PER_GHZ Andy Shevchenko
                   ` (8 preceding siblings ...)
  2026-01-13 15:28 ` Wolfram Sang
@ 2026-01-14  7:36 ` Andi Shyti
  2026-01-14  8:23   ` Andy Shevchenko
  9 siblings, 1 reply; 17+ messages in thread
From: Andi Shyti @ 2026-01-14  7:36 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Andi Shyti, Wolfram Sang, Qianfeng Rong, linux-i2c, linux-kernel,
	linux-arm-kernel, linux-mediatek, linux-rockchip, Khalil Blaiech,
	Asmaa Mnebhi, Qii Wang, Matthias Brugger,
	AngeloGioacchino Del Regno, Linus Walleij, Heiko Stuebner,
	Patrice Chotard, Ard Biesheuvel

Hi Andy,

> Andy Shevchenko (7):
>   units: Add HZ_PER_GHZ
>   i2c: mlxbf: Use HZ_PER_GHZ constant instead of custom one
>   i2c: mt65xx: Use HZ_PER_GHZ constant instead of plain number
>   i2c: nomadik: Use HZ_PER_GHZ constant instead of plain number
>   i2c: rk3x: Use HZ_PER_GHZ constant instead of plain number
>   i2c: st: Use HZ_PER_GHZ constant instead of plain number
>   i2c: synquacer: Use HZ_PER_GHZ constant instead of plain number

merged to i2c/i2c-host.

Thanks,
Andi


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v1 0/7] i2c: busses: Introduce and use HZ_PER_GHZ
  2026-01-14  7:36 ` Andi Shyti
@ 2026-01-14  8:23   ` Andy Shevchenko
  0 siblings, 0 replies; 17+ messages in thread
From: Andy Shevchenko @ 2026-01-14  8:23 UTC (permalink / raw)
  To: Andi Shyti
  Cc: Andi Shyti, Wolfram Sang, Qianfeng Rong, linux-i2c, linux-kernel,
	linux-arm-kernel, linux-mediatek, linux-rockchip, Khalil Blaiech,
	Asmaa Mnebhi, Qii Wang, Matthias Brugger,
	AngeloGioacchino Del Regno, Linus Walleij, Heiko Stuebner,
	Patrice Chotard, Ard Biesheuvel

On Wed, Jan 14, 2026 at 08:36:09AM +0100, Andi Shyti wrote:
> > Andy Shevchenko (7):
> >   units: Add HZ_PER_GHZ
> >   i2c: mlxbf: Use HZ_PER_GHZ constant instead of custom one
> >   i2c: mt65xx: Use HZ_PER_GHZ constant instead of plain number
> >   i2c: nomadik: Use HZ_PER_GHZ constant instead of plain number
> >   i2c: rk3x: Use HZ_PER_GHZ constant instead of plain number
> >   i2c: st: Use HZ_PER_GHZ constant instead of plain number
> >   i2c: synquacer: Use HZ_PER_GHZ constant instead of plain number
> 
> merged to i2c/i2c-host.

Thank you!

-- 
With Best Regards,
Andy Shevchenko




^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2026-01-14  8:24 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-12 13:46 [PATCH v1 0/7] i2c: busses: Introduce and use HZ_PER_GHZ Andy Shevchenko
2026-01-12 13:46 ` [PATCH v1 1/7] units: Add HZ_PER_GHZ Andy Shevchenko
2026-01-12 15:48   ` Linus Walleij
2026-01-13 14:23   ` Andi Shyti
2026-01-12 13:46 ` [PATCH v1 2/7] i2c: mlxbf: Use HZ_PER_GHZ constant instead of custom one Andy Shevchenko
2026-01-12 13:46 ` [PATCH v1 3/7] i2c: mt65xx: Use HZ_PER_GHZ constant instead of plain number Andy Shevchenko
2026-01-12 13:46 ` [PATCH v1 4/7] i2c: nomadik: " Andy Shevchenko
2026-01-12 15:52   ` Linus Walleij
2026-01-12 13:46 ` [PATCH v1 5/7] i2c: rk3x: " Andy Shevchenko
2026-01-13 15:10   ` Heiko Stübner
2026-01-12 13:46 ` [PATCH v1 6/7] i2c: st: " Andy Shevchenko
2026-01-13 15:29   ` Patrice CHOTARD
2026-01-12 13:46 ` [PATCH v1 7/7] i2c: synquacer: " Andy Shevchenko
2026-01-12 16:15 ` [PATCH v1 0/7] i2c: busses: Introduce and use HZ_PER_GHZ AngeloGioacchino Del Regno
2026-01-13 15:28 ` Wolfram Sang
2026-01-14  7:36 ` Andi Shyti
2026-01-14  8:23   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox