[PATCH v8 05/27] sha1: Remove sha1 non-watchdog API

Rasmus Villemoes rasmus.villemoes at prevas.dk
Fri Oct 4 09:50:50 CEST 2024


Raymond Mao <raymond.mao at linaro.org> writes:

> We don't need an API specially for non-watchdog since sha1_csum_wd
> supports it by disabling CONFIG_HW_WATCHDOG and CONFIG_WATCHDOG.
> Set 0x10000 as default chunk size for SHA1.
>

I have to say I believe this is a step in the wrong direction. Having
everybody call a function with that _wd suffix is ugly, as is having
them all pass some pre-defined constant. Moreover, nowadays what happens
every chunksize bytes isn't restricted to watchdog handling.

So yes, we don't need an API specially for non-watchdog, but why not
just make sha1_csum() be the interface to call, and let the "maybe we
need to call schedule() once in a while" be an implementation detail of
sha1_csum().

The same as with our zlib implementaion; we don't have a separate _wd
set of routines, we've just hooked schedule() into the main loop of that
inflate algorithm.

Also, I think the IS_ENABLED(CONFIG_HW_WATCHDOG) || IS_ENABLED(CONFIG_WATCHDOG)
guards are wrong and shouldn't be copy-pasted to new code. Preferably,
the code shouldn't even have any ifdefs, but just always be built as a
loop with the (possibly no-op) schedule() every xxx bytes.

I just sent a series which is the beginning of cleaning up the
CONFIG_HW_WATCHDOG/CONFIG_WATCHDOG/CONFIG_CYCLIC/when is schedule
defined and when should it be called.

Rasmus


More information about the U-Boot mailing list