diff mbox series

[RFC,07/13] mux: mmio: Only complain about idle-states if it is malformed

Message ID 20210205043924.149504-8-seanga2@gmail.com
State RFC
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series spi: dw: Add support for XIP mode | expand

Commit Message

Sean Anderson Feb. 5, 2021, 4:39 a.m. UTC
idle-states is optional, so don't complain if it doesn't exist.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
---

 drivers/mux/mmio.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Pratyush Yadav Feb. 5, 2021, 11:06 a.m. UTC | #1
On 04/02/21 11:39PM, Sean Anderson wrote:
> idle-states is optional, so don't complain if it doesn't exist.

This commit doesn't just silence the complaint. It also changes the 
behavior of the function if the error code is ENODATA or EOVERFLOW. Make 
sure the commit message reflects that.

> 
> Signed-off-by: Sean Anderson <seanga2@gmail.com>
> ---
> 
>  drivers/mux/mmio.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mux/mmio.c b/drivers/mux/mmio.c
> index 00e0282dcc..82b1cc6aab 100644
> --- a/drivers/mux/mmio.c
> +++ b/drivers/mux/mmio.c
> @@ -87,8 +87,11 @@ static int mmio_mux_probe(struct udevice *dev)
>  
>  	ret = dev_read_u32_array(dev, "idle-states", idle_states, num_fields);
>  	if (ret < 0) {
> -		log_err("idle-states");
>  		devm_kfree(dev, idle_states);
> +		/* dev_read_u32_array returns -EINVAL on missing property */
> +		if (ret != -EINVAL)
> +			return log_msg_ret("idle-states", -EINVAL);

Return ret here. I don't see any reason to return -EINVAL when the error 
is _not_ -EINVAL.

> +
>  		idle_states = NULL;
>  	}
>  
> -- 
> 2.29.2
>
Sean Anderson Feb. 5, 2021, 1:28 p.m. UTC | #2
On 2/5/21 6:06 AM, Pratyush Yadav wrote:
> On 04/02/21 11:39PM, Sean Anderson wrote:
>> idle-states is optional, so don't complain if it doesn't exist.
> 
> This commit doesn't just silence the complaint. It also changes the
> behavior of the function if the error code is ENODATA or EOVERFLOW. Make
> sure the commit message reflects that.

Sure.

> 
>>
>> Signed-off-by: Sean Anderson <seanga2@gmail.com>
>> ---
>>
>>   drivers/mux/mmio.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mux/mmio.c b/drivers/mux/mmio.c
>> index 00e0282dcc..82b1cc6aab 100644
>> --- a/drivers/mux/mmio.c
>> +++ b/drivers/mux/mmio.c
>> @@ -87,8 +87,11 @@ static int mmio_mux_probe(struct udevice *dev)
>>   
>>   	ret = dev_read_u32_array(dev, "idle-states", idle_states, num_fields);
>>   	if (ret < 0) {
>> -		log_err("idle-states");
>>   		devm_kfree(dev, idle_states);
>> +		/* dev_read_u32_array returns -EINVAL on missing property */
>> +		if (ret != -EINVAL)
>> +			return log_msg_ret("idle-states", -EINVAL);
> 
> Return ret here. I don't see any reason to return -EINVAL when the error
> is _not_ -EINVAL.

EINVAL is the traditional return value for when a binding is malformed.
Though I don't mind returning ENODATA or EOVERFLOW here. Will be
updated.

--Sean

> 
>> +
>>   		idle_states = NULL;
>>   	}
>>   
>> -- 
>> 2.29.2
>>
>
diff mbox series

Patch

diff --git a/drivers/mux/mmio.c b/drivers/mux/mmio.c
index 00e0282dcc..82b1cc6aab 100644
--- a/drivers/mux/mmio.c
+++ b/drivers/mux/mmio.c
@@ -87,8 +87,11 @@  static int mmio_mux_probe(struct udevice *dev)
 
 	ret = dev_read_u32_array(dev, "idle-states", idle_states, num_fields);
 	if (ret < 0) {
-		log_err("idle-states");
 		devm_kfree(dev, idle_states);
+		/* dev_read_u32_array returns -EINVAL on missing property */
+		if (ret != -EINVAL)
+			return log_msg_ret("idle-states", -EINVAL);
+
 		idle_states = NULL;
 	}