[PATCH] cxl/core: Use FIELD_MODIFY()

Hans Zhang posted 1 patch 1 month, 2 weeks ago
drivers/cxl/core/edac.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
[PATCH] cxl/core: Use FIELD_MODIFY()
Posted by Hans Zhang 1 month, 2 weeks ago
Use FIELD_MODIFY() to remove open-coded bit manipulation.
No functional change intended.

Signed-off-by: Hans Zhang <18255117159@163.com>
---
 drivers/cxl/core/edac.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/cxl/core/edac.c b/drivers/cxl/core/edac.c
index b321971fef58..a374e8ebac87 100644
--- a/drivers/cxl/core/edac.c
+++ b/drivers/cxl/core/edac.c
@@ -717,8 +717,7 @@ static int cxl_set_ecs_count_mode(struct device *dev, u8 *log_cap, u16 *config,
 		return -EINVAL;
 	}
 
-	*config &= ~CXL_ECS_COUNT_MODE_MASK;
-	*config |= FIELD_PREP(CXL_ECS_COUNT_MODE_MASK, val);
+	FIELD_MODIFY(CXL_ECS_COUNT_MODE_MASK, config, val);
 
 	return 0;
 }
@@ -729,8 +728,7 @@ static int cxl_set_ecs_reset_counter(struct device *dev, u8 *log_cap,
 	if (val != CXL_ECS_RESET_COUNTER)
 		return -EINVAL;
 
-	*config &= ~CXL_ECS_RESET_COUNTER_MASK;
-	*config |= FIELD_PREP(CXL_ECS_RESET_COUNTER_MASK, val);
+	FIELD_MODIFY(CXL_ECS_RESET_COUNTER_MASK, config, val);
 
 	return 0;
 }

base-commit: 3b3bea6d4b9c162f9e555905d96b8c1da67ecd5b
-- 
2.34.1
Re: [PATCH] cxl/core: Use FIELD_MODIFY()
Posted by Dave Jiang 1 month, 2 weeks ago

On 4/30/26 9:27 AM, Hans Zhang wrote:
> Use FIELD_MODIFY() to remove open-coded bit manipulation.
> No functional change intended.
> 
> Signed-off-by: Hans Zhang <18255117159@163.com>

Hi Hans. Thank you for the submission. For the CXL sub-system, we basically have agreed that we will only take cleanups if there are additional work in the area in order to avoid excessive churn in the code for ease of maintenance and debugging (i.e. git bisect). Appreciate the work though.

DJ
 
> ---
>  drivers/cxl/core/edac.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/cxl/core/edac.c b/drivers/cxl/core/edac.c
> index b321971fef58..a374e8ebac87 100644
> --- a/drivers/cxl/core/edac.c
> +++ b/drivers/cxl/core/edac.c
> @@ -717,8 +717,7 @@ static int cxl_set_ecs_count_mode(struct device *dev, u8 *log_cap, u16 *config,
>  		return -EINVAL;
>  	}
>  
> -	*config &= ~CXL_ECS_COUNT_MODE_MASK;
> -	*config |= FIELD_PREP(CXL_ECS_COUNT_MODE_MASK, val);
> +	FIELD_MODIFY(CXL_ECS_COUNT_MODE_MASK, config, val);
>  
>  	return 0;
>  }
> @@ -729,8 +728,7 @@ static int cxl_set_ecs_reset_counter(struct device *dev, u8 *log_cap,
>  	if (val != CXL_ECS_RESET_COUNTER)
>  		return -EINVAL;
>  
> -	*config &= ~CXL_ECS_RESET_COUNTER_MASK;
> -	*config |= FIELD_PREP(CXL_ECS_RESET_COUNTER_MASK, val);
> +	FIELD_MODIFY(CXL_ECS_RESET_COUNTER_MASK, config, val);
>  
>  	return 0;
>  }
> 
> base-commit: 3b3bea6d4b9c162f9e555905d96b8c1da67ecd5b
Re: [PATCH] cxl/core: Use FIELD_MODIFY()
Posted by Hans Zhang 1 month, 2 weeks ago

On 5/1/26 04:21, Dave Jiang wrote:
> 
> 
> On 4/30/26 9:27 AM, Hans Zhang wrote:
>> Use FIELD_MODIFY() to remove open-coded bit manipulation.
>> No functional change intended.
>>
>> Signed-off-by: Hans Zhang <18255117159@163.com>
> 
> Hi Hans. Thank you for the submission. For the CXL sub-system, we basically have agreed that we will only take cleanups if there are additional work in the area in order to avoid excessive churn in the code for ease of maintenance and debugging (i.e. git bisect). Appreciate the work though.

Hi Dave,

Thank you for you reply. I see.

Best regards,
Hans

> 
> DJ
>   
>> ---
>>   drivers/cxl/core/edac.c | 6 ++----
>>   1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/cxl/core/edac.c b/drivers/cxl/core/edac.c
>> index b321971fef58..a374e8ebac87 100644
>> --- a/drivers/cxl/core/edac.c
>> +++ b/drivers/cxl/core/edac.c
>> @@ -717,8 +717,7 @@ static int cxl_set_ecs_count_mode(struct device *dev, u8 *log_cap, u16 *config,
>>   		return -EINVAL;
>>   	}
>>   
>> -	*config &= ~CXL_ECS_COUNT_MODE_MASK;
>> -	*config |= FIELD_PREP(CXL_ECS_COUNT_MODE_MASK, val);
>> +	FIELD_MODIFY(CXL_ECS_COUNT_MODE_MASK, config, val);
>>   
>>   	return 0;
>>   }
>> @@ -729,8 +728,7 @@ static int cxl_set_ecs_reset_counter(struct device *dev, u8 *log_cap,
>>   	if (val != CXL_ECS_RESET_COUNTER)
>>   		return -EINVAL;
>>   
>> -	*config &= ~CXL_ECS_RESET_COUNTER_MASK;
>> -	*config |= FIELD_PREP(CXL_ECS_RESET_COUNTER_MASK, val);
>> +	FIELD_MODIFY(CXL_ECS_RESET_COUNTER_MASK, config, val);
>>   
>>   	return 0;
>>   }
>>
>> base-commit: 3b3bea6d4b9c162f9e555905d96b8c1da67ecd5b