Skip to contentSkip to conversation

i2c: designware: Use better constants from units.h

PATCH Applied Andy Shevchenko 4 participants 4 messages Apr 16, 2025 – Apr 17, 2025

Subsystems (3)
lore
Share & tools
lore

Andy Shevchenko

author reviewer
#0 lore raw

PATCH 1/1 i2c: designware: Use better constants from units.h

When we use constants in a time or frequency related contexts, it's better to utilise the respective definitions that have encoded units in them. This will make code better to read and understand.

---
 drivers/i2c/busses/i2c-designware-platdrv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-designware-platdrv.c +1 -1
index d6e1ee935399..879719e91df2 100644
@@ -34,7 +34,7 @@
 
 static u32 i2c_dw_get_clk_rate_khz(struct dw_i2c_dev *dev)
 {
-	return clk_get_rate(dev->clk) / KILO;
+	return clk_get_rate(dev->clk) / HZ_PER_KHZ;
 }
 
 #ifdef CONFIG_OF
Signature · 1 line
2.47.2
Acked-by on v1 1/1
#1 lore raw
Quoted 15 lines · Andy Shevchenko

When we use constants in a time or frequency related contexts, it's better to utilise the respective definitions that have encoded units in them. This will make code better to read and understand.

---
  drivers/i2c/busses/i2c-designware-platdrv.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-designware-platdrv.c +0 -0
index d6e1ee935399..879719e91df2 100644

drivers/i2c/busses/i2c-designware-platdrv.c line 40

Quoted 8 lines
drivers/i2c/busses/i2c-designware-platdrv.c +1 -1
@@ -34,7 +34,7 @@
 
  static u32 i2c_dw_get_clk_rate_khz(struct dw_i2c_dev *dev)
  {
-	return clk_get_rate(dev->clk) / KILO;
+	return clk_get_rate(dev->clk) / HZ_PER_KHZ;
  }
 
  #ifdef CONFIG_OF
Acked-by on v1 1/1
#2 lore raw
In reply to Andy Shevchenko
Quoted 10 lines · Andy Shevchenko

When we use constants in a time or frequency related contexts, it's better to utilise the respective definitions that have encoded units in them. This will make code better to read and understand.

---
  drivers/i2c/busses/i2c-designware-platdrv.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
maintainer Applied
#3 lore raw
In reply to Andy Shevchenko

Hi Andy,

Quoted 6 lines · Andy Shevchenko

When we use constants in a time or frequency related contexts, it's better to utilise the respective definitions that have encoded units in them. This will make code better to read and understand.

merged to i2c/i2c-host.

Thanks,
Andi