[1/6] platform/x86: wmi: Remove unused variable in address space handler

Message ID 20231216015601.395118-2-W_Armin@gmx.de
State New
Headers
Series [1/6] platform/x86: wmi: Remove unused variable in address space handler |

Commit Message

Armin Wolf Dec. 16, 2023, 1:55 a.m. UTC
  The variable "i" is always zero and only used in shift operations.
Remove it to make the code more readable.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/platform/x86/wmi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--
2.39.2
  

Comments

Ilpo Järvinen Dec. 18, 2023, 12:05 p.m. UTC | #1
On Sat, 16 Dec 2023, Armin Wolf wrote:

> The variable "i" is always zero and only used in shift operations.
> Remove it to make the code more readable.
> 
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> ---
>  drivers/platform/x86/wmi.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
> index 7303702290e5..906d3a2831ae 100644
> --- a/drivers/platform/x86/wmi.c
> +++ b/drivers/platform/x86/wmi.c
> @@ -1144,7 +1144,7 @@ acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address,
>  			  u32 bits, u64 *value,
>  			  void *handler_context, void *region_context)
>  {
> -	int result = 0, i = 0;
> +	int result = 0;
>  	u8 temp = 0;
> 
>  	if ((address > 0xFF) || !value)
> @@ -1158,9 +1158,9 @@ acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address,
> 
>  	if (function == ACPI_READ) {
>  		result = ec_read(address, &temp);
> -		(*value) |= ((u64)temp) << i;
> +		*value = temp;
>  	} else {
> -		temp = 0xff & ((*value) >> i);
> +		temp = 0xff & *value;
>  		result = ec_write(address, temp);
>  	}

Seems to have been like this already when it got introduced...

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
  

Patch

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 7303702290e5..906d3a2831ae 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -1144,7 +1144,7 @@  acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address,
 			  u32 bits, u64 *value,
 			  void *handler_context, void *region_context)
 {
-	int result = 0, i = 0;
+	int result = 0;
 	u8 temp = 0;

 	if ((address > 0xFF) || !value)
@@ -1158,9 +1158,9 @@  acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address,

 	if (function == ACPI_READ) {
 		result = ec_read(address, &temp);
-		(*value) |= ((u64)temp) << i;
+		*value = temp;
 	} else {
-		temp = 0xff & ((*value) >> i);
+		temp = 0xff & *value;
 		result = ec_write(address, temp);
 	}