From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Artem Shimko <a.shimko.dev@gmail.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>,
Jan Dabros <jsd@semihalf.com>, Andi Shyti <andi.shyti@kernel.org>,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] i2c: designware: Replace magic numbers with named constants
Date: Thu, 4 Dec 2025 20:54:42 +0200 [thread overview]
Message-ID: <aTHY8pP0zjjX1NNB@smile.fi.intel.com> (raw)
In-Reply-To: <20251204161309.750032-1-a.shimko.dev@gmail.com>
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
next prev parent reply other threads:[~2025-12-04 18:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-04 16:13 [PATCH v3] i2c: designware: Replace magic numbers with named constants Artem Shimko
2025-12-04 18:54 ` Andy Shevchenko [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-11-07 6:54 [PATCH v2] " kernel test robot
2025-11-07 7:30 ` [PATCH v3] " Artem Shimko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aTHY8pP0zjjX1NNB@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=a.shimko.dev@gmail.com \
--cc=andi.shyti@kernel.org \
--cc=jsd@semihalf.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox