cxl/mem: Fix a double shift bug

Message ID a11b0c78-4717-4f4e-90be-f47f300d607c@moroto.mountain
State New
Headers
Series cxl/mem: Fix a double shift bug |

Commit Message

Dan Carpenter July 3, 2023, 2:17 p.m. UTC
  The CXL_FW_CANCEL macro is used with set/test_bit() so it should be a
bit number and not the shifted value.  The original code is the
equivalent of using BIT(BIT(0)) so it's 0x2 instead of 0x1.  This has
no effect on runtime because it's done consistently and nothing else
was using the 0x2 bit.

Fixes: 9521875bbe00 ("cxl: add a firmware update mechanism using the sysfs firmware loader")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/cxl/cxlmem.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Dave Jiang July 5, 2023, 5:43 p.m. UTC | #1
On 7/3/23 07:17, Dan Carpenter wrote:
> The CXL_FW_CANCEL macro is used with set/test_bit() so it should be a
> bit number and not the shifted value.  The original code is the
> equivalent of using BIT(BIT(0)) so it's 0x2 instead of 0x1.  This has
> no effect on runtime because it's done consistently and nothing else
> was using the 0x2 bit.
> 
> Fixes: 9521875bbe00 ("cxl: add a firmware update mechanism using the sysfs firmware loader")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
>   drivers/cxl/cxlmem.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h
> index 79e99c873ca2..499113328586 100644
> --- a/drivers/cxl/cxlmem.h
> +++ b/drivers/cxl/cxlmem.h
> @@ -323,7 +323,7 @@ struct cxl_mbox_activate_fw {
>   
>   /* FW state bits */
>   #define CXL_FW_STATE_BITS		32
> -#define CXL_FW_CANCEL		BIT(0)
> +#define CXL_FW_CANCEL			0
>   
>   /**
>    * struct cxl_fw_state - Firmware upload / activation state
  
Davidlohr Bueso July 12, 2023, 6:03 p.m. UTC | #2
On Mon, 03 Jul 2023, Dan Carpenter wrote:

>The CXL_FW_CANCEL macro is used with set/test_bit() so it should be a
>bit number and not the shifted value.  The original code is the
>equivalent of using BIT(BIT(0)) so it's 0x2 instead of 0x1.  This has
>no effect on runtime because it's done consistently and nothing else
>was using the 0x2 bit.
>
>Fixes: 9521875bbe00 ("cxl: add a firmware update mechanism using the sysfs firmware loader")
>Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
  
Verma, Vishal L July 12, 2023, 7:34 p.m. UTC | #3
On Mon, 2023-07-03 at 17:17 +0300, Dan Carpenter wrote:
> The CXL_FW_CANCEL macro is used with set/test_bit() so it should be a
> bit number and not the shifted value.  The original code is the
> equivalent of using BIT(BIT(0)) so it's 0x2 instead of 0x1.  This has
> no effect on runtime because it's done consistently and nothing else
> was using the 0x2 bit.
> 
> Fixes: 9521875bbe00 ("cxl: add a firmware update mechanism using the sysfs firmware loader")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>

> ---
>  drivers/cxl/cxlmem.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h
> index 79e99c873ca2..499113328586 100644
> --- a/drivers/cxl/cxlmem.h
> +++ b/drivers/cxl/cxlmem.h
> @@ -323,7 +323,7 @@ struct cxl_mbox_activate_fw {
>  
>  /* FW state bits */
>  #define CXL_FW_STATE_BITS              32
> -#define CXL_FW_CANCEL          BIT(0)
> +#define CXL_FW_CANCEL                  0
>  
>  /**
>   * struct cxl_fw_state - Firmware upload / activation state
  

Patch

diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h
index 79e99c873ca2..499113328586 100644
--- a/drivers/cxl/cxlmem.h
+++ b/drivers/cxl/cxlmem.h
@@ -323,7 +323,7 @@  struct cxl_mbox_activate_fw {
 
 /* FW state bits */
 #define CXL_FW_STATE_BITS		32
-#define CXL_FW_CANCEL		BIT(0)
+#define CXL_FW_CANCEL			0
 
 /**
  * struct cxl_fw_state - Firmware upload / activation state