diff mbox series

sparc/irq: Remove unneeded if check in sun4v_cookie_only_virqs()

Message ID 20250114202502.912690-1-thorsten.blum@linux.dev
State New
Headers show
Series sparc/irq: Remove unneeded if check in sun4v_cookie_only_virqs() | expand

Commit Message

Thorsten Blum Jan. 14, 2025, 8:25 p.m. UTC
Remove the unnecessary if check and return the result directly.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 arch/sparc/kernel/irq_64.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

John Paul Adrian Glaubitz Jan. 14, 2025, 8:29 p.m. UTC | #1
Hi Thorsten,

On Tue, 2025-01-14 at 21:25 +0100, Thorsten Blum wrote:
> Remove the unnecessary if check and return the result directly.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  arch/sparc/kernel/irq_64.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/arch/sparc/kernel/irq_64.c b/arch/sparc/kernel/irq_64.c
> index aff0d24f8c6f..81fb49b089a8 100644
> --- a/arch/sparc/kernel/irq_64.c
> +++ b/arch/sparc/kernel/irq_64.c
> @@ -146,9 +146,7 @@ static int hv_irq_version;
>   */
>  static bool sun4v_cookie_only_virqs(void)
>  {
> -	if (hv_irq_version >= 3)
> -		return true;
> -	return false;
> +	return hv_irq_version >= 3;
>  }
>  
>  static void __init irq_init_hv(void)

I'm not sure whether this change is really necessary nor will it improve
the readability of the code. I think the compiler will optimize the code
the same way, for both variants.

Adrian
Thorsten Blum Jan. 15, 2025, 4:11 p.m. UTC | #2
Hi Adrian,

On 14. Jan 2025, at 21:29, John Paul Adrian Glaubitz wrote:
> On Tue, 2025-01-14 at 21:25 +0100, Thorsten Blum wrote:
>> Remove the unnecessary if check and return the result directly.
>> 
>> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
>> ---
>> arch/sparc/kernel/irq_64.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>> 
>> diff --git a/arch/sparc/kernel/irq_64.c b/arch/sparc/kernel/irq_64.c
>> index aff0d24f8c6f..81fb49b089a8 100644
>> --- a/arch/sparc/kernel/irq_64.c
>> +++ b/arch/sparc/kernel/irq_64.c
>> @@ -146,9 +146,7 @@ static int hv_irq_version;
>>  */
>> static bool sun4v_cookie_only_virqs(void)
>> {
>> - if (hv_irq_version >= 3)
>> - return true;
>> - return false;
>> + return hv_irq_version >= 3;
>> }
>> 
>> static void __init irq_init_hv(void)
> 
> I'm not sure whether this change is really necessary nor will it improve
> the readability of the code. I think the compiler will optimize the code
> the same way, for both variants.

It's not strictly necessary, but it's shorter, less verbose, and imo
improves the code's readability. Personally, I'd even consider the
current version a code smell, but feel free to ignore the patch.

Thanks,
Thorsten
Andreas Larsson Jan. 17, 2025, 3:21 p.m. UTC | #3
On 2025-01-15 17:11, Thorsten Blum wrote:
> Hi Adrian,
> 
> On 14. Jan 2025, at 21:29, John Paul Adrian Glaubitz wrote:
>> On Tue, 2025-01-14 at 21:25 +0100, Thorsten Blum wrote:
>>> Remove the unnecessary if check and return the result directly.
>>>
>>> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
>>> ---
>>> arch/sparc/kernel/irq_64.c | 4 +---
>>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>>
>>> diff --git a/arch/sparc/kernel/irq_64.c b/arch/sparc/kernel/irq_64.c
>>> index aff0d24f8c6f..81fb49b089a8 100644
>>> --- a/arch/sparc/kernel/irq_64.c
>>> +++ b/arch/sparc/kernel/irq_64.c
>>> @@ -146,9 +146,7 @@ static int hv_irq_version;
>>>  */
>>> static bool sun4v_cookie_only_virqs(void)
>>> {
>>> - if (hv_irq_version >= 3)
>>> - return true;
>>> - return false;
>>> + return hv_irq_version >= 3;
>>> }
>>>
>>> static void __init irq_init_hv(void)
>>
>> I'm not sure whether this change is really necessary nor will it improve
>> the readability of the code. I think the compiler will optimize the code
>> the same way, for both variants.
> 
> It's not strictly necessary, but it's shorter, less verbose, and imo
> improves the code's readability. Personally, I'd even consider the
> current version a code smell, but feel free to ignore the patch.

I could see it both ways, but personally agree about it being slightly
more readable. As I'll pick up the other sun4v_cookie_only_virqs()
related patch I might as well take this one as well.

Reviewed-by: Andreas Larsson <andreas@gaisler.com>

Picking this up to my for-next.

Thanks,
Andreas
diff mbox series

Patch

diff --git a/arch/sparc/kernel/irq_64.c b/arch/sparc/kernel/irq_64.c
index aff0d24f8c6f..81fb49b089a8 100644
--- a/arch/sparc/kernel/irq_64.c
+++ b/arch/sparc/kernel/irq_64.c
@@ -146,9 +146,7 @@  static int hv_irq_version;
  */
 static bool sun4v_cookie_only_virqs(void)
 {
-	if (hv_irq_version >= 3)
-		return true;
-	return false;
+	return hv_irq_version >= 3;
 }
 
 static void __init irq_init_hv(void)