Re: [PATCH v3 05/23] media: iris: Prevent HFI queue writes when core is in deinit state

From: Konrad Dybcio
Date: Fri May 02 2025 - 09:54:43 EST


On 5/2/25 2:22 PM, Bryan O'Donoghue wrote:
> On 01/05/2025 20:13, Dikshita Agarwal wrote:
>> -    if (core->state == IRIS_CORE_ERROR)
>> +    if (core->state == IRIS_CORE_ERROR || core->state == IRIS_CORE_DEINIT)
>>           return -EINVAL;
>
> Instead of checking for 2/3 of the states why not just check for the 1/3 ?
>
> enum iris_core_state {
>         IRIS_CORE_DEINIT,
>         IRIS_CORE_INIT,
>         IRIS_CORE_ERROR,
> };
>
> if (core->state != IRIS_CORE_INIT)
>     return -EINVAL;
>
> Cleaner and more explicit - declaring the state you must be in, as opposed to a list of states you should not be in.

Being explicit in state machines helps maintainability - if we get
e.g. IRIS_CORE_LIGHT_SLEEP down the line, this could easily fail

Konrad