Hi On 2/24/20 5:14 PM, Andy Shevchenko wrote:
Since we have generic definitions for bus frequencies, let's use them. Cc: Thor Thayer <thor.thayer@xxxxxxxxxxxxxxx> Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> --- drivers/i2c/busses/i2c-altera.c | 8 ++++---- include/linux/i2c.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-altera.c b/drivers/i2c/busses/i2c-altera.c index 5255d3755411..1f70bbd6e084 100644 --- a/drivers/i2c/busses/i2c-altera.c +++ b/drivers/i2c/busses/i2c-altera.c @@ -142,12 +142,12 @@ static inline void altr_i2c_stop(struct altr_i2c_dev *idev) static void altr_i2c_init(struct altr_i2c_dev *idev) { u32 divisor = clk_get_rate(idev->i2c_clk) / idev->bus_clk_rate; - u32 clk_mhz = clk_get_rate(idev->i2c_clk) / 1000000; + u32 clk_mhz = clk_get_rate(idev->i2c_clk) / HZ_PER_MHZ;
IMHO these kind of defines don't improve readability in formulas. What is HZ_PER_MHZ? You have to go and grep it first in order to be sure. Of course it protects against typos like "100000" or "10000000" that are difficult to spot at quick look.
Better would be just "1MHz" or even better calc_something_MHz(). -- Jarkko