Re: [PATCH v1 5/7] cxl/core: Use guard() to drop goto pattern of cxl_dpa_alloc()
From: Jonathan Cameron
Date: Tue Feb 11 2025 - 12:32:19 EST
On Tue, 11 Feb 2025 15:57:25 +0800
Li Ming <ming.li@xxxxxxxxxxxx> wrote:
> In cxl_dpa_alloc(), some checking and operations need to be protected by
> a rwsem called cxl_dpa_rwsem, so there is a goto pattern in
> cxl_dpa_alloc() to release the rwsem. The goto pattern can be optimized
> by using guard() to hold the rwsem.
>
> Creating a new function called __cxl_dpa_alloc() to include all checking
> and operations needed to be procted by cxl_dpa_rwsem. Using
> guard(rwsem_write()) to hold cxl_dpa_rwsem at the beginning of the new
> function.
>
> Signed-off-by: Li Ming <ming.li@xxxxxxxxxxxx>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>