Re: [PATCH] staging: sm750fb: replace magic number with defined constant
From: Dan Carpenter
Date: Wed Jan 28 2026 - 06:58:15 EST
On Tue, Jan 27, 2026 at 01:27:58PM +0000, Madhumitha Sundar wrote:
> The hardware wait loop in hw_sm750_de_wait uses a hardcoded magic
> number (0x10000000) for the timeout counter.
>
> Define a constant SM750_MAX_LOOP in sm750.h and use it to improve
> code readability and maintainability.
Timeout counters have no special meaning. They aren't intended to be
re-used in multiple places.
There is a kind of bug where people think we exit with the counter set
to zero but actually we exit with it set the -1. Normally, when I see
this sort of bug, I change the timer from cnt-- to --cnt which changes
loop from iterating 100 times to iterating 99 times. It's fine. No
one cares if about the exact number, just the approximate range.
The original was more clear.
regards,
dan carpenter