diff mbox series

[2/2,V6] acpi/prmt: refactor acpi_platformrt_space_handler to drop gotos

Message ID 20241006153611.1165482-2-kobak@nvidia.com
State New
Headers show
Series [1/2,V6] acpi/prmt: find block with specific type | expand

Commit Message

KobaK Oct. 6, 2024, 3:36 p.m. UTC
From: koba ko <kobak@nvidia.com>

Replace gotos with returns

Signed-off-by: koba ko <kobak@nvidia.com>
---
 drivers/acpi/prmt.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

Comments

Zhang Rui Oct. 8, 2024, 3:24 a.m. UTC | #1
On Sun, 2024-10-06 at 23:36 +0800, KobaK wrote:
> From: koba ko <kobak@nvidia.com>
> 
> Replace gotos with returns
> 
> Signed-off-by: koba ko <kobak@nvidia.com>

I think my previous comment was valid because a different prm_status is
returned, say, PRM_HANDLER_ERROR.

Given that we return AE_OK directly for PRM_HANDLER_ERROR case in patch
1/2, I think it is okay to drop this patch.

thanks,
rui

> ---
>  drivers/acpi/prmt.c | 22 ++++++++++++----------
>  1 file changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/acpi/prmt.c b/drivers/acpi/prmt.c
> index 970207bc8f4a..b0cf4428f7e3 100644
> --- a/drivers/acpi/prmt.c
> +++ b/drivers/acpi/prmt.c
> @@ -288,8 +288,10 @@ static acpi_status
> acpi_platformrt_space_handler(u32 function,
>  
>                 handler = find_prm_handler(&buffer->handler_guid);
>                 module = find_prm_module(&buffer->handler_guid);
> -               if (!handler || !module)
> -                       goto invalid_guid;
> +               if (!handler || !module) {
> +                       buffer->prm_status =
> PRM_HANDLER_GUID_NOT_FOUND;
> +                       return AE_OK;
> +               }
>  
>                 if (!handler->handler_addr || !handler-
> >static_data_buffer_addr ||
>                         !handler->acpi_param_buffer_addr) {
> @@ -318,8 +320,10 @@ static acpi_status
> acpi_platformrt_space_handler(u32 function,
>         case PRM_CMD_START_TRANSACTION:
>  
>                 module = find_prm_module(&buffer->handler_guid);
> -               if (!module)
> -                       goto invalid_guid;
> +               if (!module) {
> +                       buffer->prm_status =
> PRM_HANDLER_GUID_NOT_FOUND;
> +                       return AE_OK;
> +               }
>  
>                 if (module->updatable)
>                         module->updatable = false;
> @@ -330,8 +334,10 @@ static acpi_status
> acpi_platformrt_space_handler(u32 function,
>         case PRM_CMD_END_TRANSACTION:
>  
>                 module = find_prm_module(&buffer->handler_guid);
> -               if (!module)
> -                       goto invalid_guid;
> +               if (!module) {
> +                       buffer->prm_status =
> PRM_HANDLER_GUID_NOT_FOUND;
> +                       return AE_OK;
> +               }
>  
>                 if (module->updatable)
>                         buffer->prm_status =
> UPDATE_UNLOCK_WITHOUT_LOCK;
> @@ -346,10 +352,6 @@ static acpi_status
> acpi_platformrt_space_handler(u32 function,
>         }
>  
>         return AE_OK;
> -
> -invalid_guid:
> -       buffer->prm_status = PRM_HANDLER_GUID_NOT_FOUND;
> -       return AE_OK;
>  }
>  
>  void __init init_prmt(void)
Ard Biesheuvel Oct. 8, 2024, 9:11 a.m. UTC | #2
On Tue, 8 Oct 2024 at 05:24, Zhang, Rui <rui.zhang@intel.com> wrote:
>
> On Sun, 2024-10-06 at 23:36 +0800, KobaK wrote:
> > From: koba ko <kobak@nvidia.com>
> >
> > Replace gotos with returns
> >
> > Signed-off-by: koba ko <kobak@nvidia.com>
>
> I think my previous comment was valid because a different prm_status is
> returned, say, PRM_HANDLER_ERROR.
>
> Given that we return AE_OK directly for PRM_HANDLER_ERROR case in patch
> 1/2, I think it is okay to drop this patch.
>


Agreed
diff mbox series

Patch

diff --git a/drivers/acpi/prmt.c b/drivers/acpi/prmt.c
index 970207bc8f4a..b0cf4428f7e3 100644
--- a/drivers/acpi/prmt.c
+++ b/drivers/acpi/prmt.c
@@ -288,8 +288,10 @@  static acpi_status acpi_platformrt_space_handler(u32 function,
 
 		handler = find_prm_handler(&buffer->handler_guid);
 		module = find_prm_module(&buffer->handler_guid);
-		if (!handler || !module)
-			goto invalid_guid;
+		if (!handler || !module) {
+			buffer->prm_status = PRM_HANDLER_GUID_NOT_FOUND;
+			return AE_OK;
+		}
 
 		if (!handler->handler_addr || !handler->static_data_buffer_addr ||
 			!handler->acpi_param_buffer_addr) {
@@ -318,8 +320,10 @@  static acpi_status acpi_platformrt_space_handler(u32 function,
 	case PRM_CMD_START_TRANSACTION:
 
 		module = find_prm_module(&buffer->handler_guid);
-		if (!module)
-			goto invalid_guid;
+		if (!module) {
+			buffer->prm_status = PRM_HANDLER_GUID_NOT_FOUND;
+			return AE_OK;
+		}
 
 		if (module->updatable)
 			module->updatable = false;
@@ -330,8 +334,10 @@  static acpi_status acpi_platformrt_space_handler(u32 function,
 	case PRM_CMD_END_TRANSACTION:
 
 		module = find_prm_module(&buffer->handler_guid);
-		if (!module)
-			goto invalid_guid;
+		if (!module) {
+			buffer->prm_status = PRM_HANDLER_GUID_NOT_FOUND;
+			return AE_OK;
+		}
 
 		if (module->updatable)
 			buffer->prm_status = UPDATE_UNLOCK_WITHOUT_LOCK;
@@ -346,10 +352,6 @@  static acpi_status acpi_platformrt_space_handler(u32 function,
 	}
 
 	return AE_OK;
-
-invalid_guid:
-	buffer->prm_status = PRM_HANDLER_GUID_NOT_FOUND;
-	return AE_OK;
 }
 
 void __init init_prmt(void)