diff mbox series

cxl/acpi: simplify returning pointer without cleanup

Message ID 20240703083055.95864-1-krzysztof.kozlowski@linaro.org
State New, archived
Headers show
Series cxl/acpi: simplify returning pointer without cleanup | expand

Commit Message

Krzysztof Kozlowski July 3, 2024, 8:30 a.m. UTC
Use 'return_ptr' helper for returning a pointer without cleanup for
shorter code.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/cxl/acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dan Williams July 3, 2024, 4:07 p.m. UTC | #1
Krzysztof Kozlowski wrote:
> Use 'return_ptr' helper for returning a pointer without cleanup for
> shorter code.

No, thank you. For CXL, I am not a fan of macros with hidden 'return'
statements.
Alison Schofield July 3, 2024, 4:55 p.m. UTC | #2
On Wed, Jul 03, 2024 at 10:30:55AM +0200, Krzysztof Kozlowski wrote:
> Use 'return_ptr' helper for returning a pointer without cleanup for
> shorter code.
> 

My first thought on this was that I prefer the explicitness
of pairing __free(kfree) with no_free_ptr as was done here.

cleanup.h defines this: 
#define return_ptr(p)   return no_free_ptr(p)

I did read the comments and am still confused. I see you posted a
handful of no_free_ptr to return_ptr patches. What is your selection
process for changing these?

--Alison


> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
>  drivers/cxl/acpi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c
> index 571069863c62..1e4bed8a933e 100644
> --- a/drivers/cxl/acpi.c
> +++ b/drivers/cxl/acpi.c
> @@ -339,7 +339,7 @@ static struct resource *alloc_cxl_resource(resource_size_t base,
>  	if (!res->name)
>  		return NULL;
>  
> -	return no_free_ptr(res);
> +	return_ptr(res);
>  }
>  
>  static int add_or_reset_cxl_resource(struct resource *parent, struct resource *res)
> -- 
> 2.43.0
>
Krzysztof Kozlowski July 4, 2024, 6:17 a.m. UTC | #3
On 03/07/2024 18:07, Dan Williams wrote:
> Krzysztof Kozlowski wrote:
>> Use 'return_ptr' helper for returning a pointer without cleanup for
>> shorter code.
> 
> No, thank you. For CXL, I am not a fan of macros with hidden 'return'
> statements.

Sure, maybe the macro is not helpful in the first place.

Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c
index 571069863c62..1e4bed8a933e 100644
--- a/drivers/cxl/acpi.c
+++ b/drivers/cxl/acpi.c
@@ -339,7 +339,7 @@  static struct resource *alloc_cxl_resource(resource_size_t base,
 	if (!res->name)
 		return NULL;
 
-	return no_free_ptr(res);
+	return_ptr(res);
 }
 
 static int add_or_reset_cxl_resource(struct resource *parent, struct resource *res)