Re: [PATCH] regulator: Fix return type of of_map_mode()

From: Doug Anderson
Date: Tue Apr 17 2018 - 23:35:27 EST


Hi,

On Tue, Apr 17, 2018 at 10:48 AM, Javier Martinez Canillas
<javier@xxxxxxxxxxxx> wrote:
>>> Let's fix the return type of all of the current of_map_mode()
>>> functions. While we're at it, we'll remove one pointless "inline".
>>
>> Ah, I see... the thing here is that the mode is always an unsigned int
>> since it's a bitmask - this goes out beying the use in of_map_mode() and
>> into all the other APIs. We only actually use 4 bits currently so I
>> think there's no problem switching to int but it seems we should
>> probably do that consistently throughout the API so that things don't
>> get missed later on.
>
> Maybe another option could be to add a REGULATOR_MODE_INVALID with
> value 0x0, and fix the drivers that are returning -EINVAL to return
> that instead?
>
> In of_get_regulation_constraints() we could check for that and
> propagate -EINVAL.

I like this idea. Posted at
<https://patchwork.kernel.org/patch/10347345/>. Note that there's no
actual error to propagate since of_get_regulation_constraints() just
prints the error and continues on its merry way.

-Doug