[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aTHY8pP0zjjX1NNB@smile.fi.intel.com>
Date: Thu, 4 Dec 2025 20:54:42 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Artem Shimko <a.shimko.dev@...il.com>
Cc: Mika Westerberg <mika.westerberg@...ux.intel.com>,
Jan Dabros <jsd@...ihalf.com>, Andi Shyti <andi.shyti@...nel.org>,
linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3] i2c: designware: Replace magic numbers with named
constants
On Thu, Dec 04, 2025 at 07:13:08PM +0300, Artem Shimko wrote:
> Replace various magic numbers with properly named constants to improve
> code readability and maintainability. This includes constants for
> register access, timing adjustments, timeouts, FIFO parameters,
> and default values.
>
> The change makes the code more self-documenting without altering any
s/The change/This/
> functionality.
...
> +#define DW_IC_DEFAULT_BUS_CAPACITANCE_PF 100
_pF
(yes, it's fine to use CamelCase for unit suffixes, some of them historically
use capital letters, but it's better to follow the actual unit spelling from
Système International d'Unité)
> +#define DW_IC_ABORT_TIMEOUT_US 10
> +#define DW_IC_ABORT_TOTAL_TIMEOUT_US 100
Those TOTAL are not needed, just use a multiplier in place, this will be
basically the explicit number of "iterations" (yes, I know that the real
ones are 2x or 4x more).
> +#define DW_IC_BUSY_POLL_TIMEOUT_US 1100
Why not 1000?
(Yeah, I see the original value, but I think it makes no sense to go
specifically with 1100).
And in this case it might be better to write it as (1 * USEC_PER_MSEC)
which makes it easier to get that this is 1 millisecond (in µs units).
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists