diff mbox series

wifi: rfkill: Correct parameter type for rfkill_set_hw_state_reason()

Message ID 20240715-rfkill_fix-v1-1-a9f2d56b4716@quicinc.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series wifi: rfkill: Correct parameter type for rfkill_set_hw_state_reason() | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 818 this patch: 818
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 838 this patch: 838
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 847 this patch: 847
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 36 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 20 this patch: 20
netdev/source_inline success Was 0 now: 0

Commit Message

Zijun Hu July 15, 2024, 1:39 p.m. UTC
From: Zijun Hu <quic_zijuhu@quicinc.com>

Change type of parameter @reason to enum rfkill_hard_block_reasons for
API rfkill_set_hw_state_reason() according to its comments.

Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
 include/linux/rfkill.h | 5 ++---
 net/rfkill/core.c      | 7 +------
 2 files changed, 3 insertions(+), 9 deletions(-)


---
base-commit: 338a93cf4a18c2036b567e9f613367f7a52f2511
change-id: 20240715-rfkill_fix-335afa2e88ca

Best regards,

Comments

Jeff Johnson July 26, 2024, 10:51 p.m. UTC | #1
On 7/15/2024 6:39 AM, Zijun Hu wrote:
> From: Zijun Hu <quic_zijuhu@quicinc.com>
> 
> Change type of parameter @reason to enum rfkill_hard_block_reasons for
> API rfkill_set_hw_state_reason() according to its comments.
> 
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
>  include/linux/rfkill.h | 5 ++---
>  net/rfkill/core.c      | 7 +------
>  2 files changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/include/linux/rfkill.h b/include/linux/rfkill.h
> index 373003ace639..4f7558267541 100644
> --- a/include/linux/rfkill.h
> +++ b/include/linux/rfkill.h
> @@ -147,7 +147,7 @@ void rfkill_destroy(struct rfkill *rfkill);
>   * Prefer to use rfkill_set_hw_state if you don't need any special reason.
>   */
>  bool rfkill_set_hw_state_reason(struct rfkill *rfkill,
> -				bool blocked, unsigned long reason);
> +		bool blocked, enum rfkill_hard_block_reasons reason);

function parameters should align on (

>  /**
>   * rfkill_set_hw_state - Set the internal rfkill hardware block state
>   * @rfkill: pointer to the rfkill class to modify.
> @@ -279,8 +279,7 @@ static inline void rfkill_destroy(struct rfkill *rfkill)
>  }
>  
>  static inline bool rfkill_set_hw_state_reason(struct rfkill *rfkill,
> -					      bool blocked,
> -					      unsigned long reason)
> +		bool blocked, enum rfkill_hard_block_reasons reason)

function parameters should align on (

>  {
>  	return blocked;
>  }
> diff --git a/net/rfkill/core.c b/net/rfkill/core.c
> index 7a5367628c05..f8ed6431b2f5 100644
> --- a/net/rfkill/core.c
> +++ b/net/rfkill/core.c
> @@ -539,18 +539,13 @@ bool rfkill_get_global_sw_state(const enum rfkill_type type)
>  #endif
>  
>  bool rfkill_set_hw_state_reason(struct rfkill *rfkill,
> -				bool blocked, unsigned long reason)
> +		bool blocked, enum rfkill_hard_block_reasons reason)

function parameters should align on (

>  {
>  	unsigned long flags;
>  	bool ret, prev;
>  
>  	BUG_ON(!rfkill);
>  
> -	if (WARN(reason & ~(RFKILL_HARD_BLOCK_SIGNAL |
> -			    RFKILL_HARD_BLOCK_NOT_OWNER),
> -		 "hw_state reason not supported: 0x%lx", reason))
> -		return rfkill_blocked(rfkill);
> -

did you validate that all callers are actually passing a valid enum?
that is something you should describe in your commit since this is a change
beyond just changing the prototype

>  	spin_lock_irqsave(&rfkill->lock, flags);
>  	prev = !!(rfkill->hard_block_reasons & reason);
>  	if (blocked) {
> 
> ---
> base-commit: 338a93cf4a18c2036b567e9f613367f7a52f2511
> change-id: 20240715-rfkill_fix-335afa2e88ca
> 
> Best regards,
Zijun Hu July 27, 2024, 12:23 a.m. UTC | #2
On 2024/7/27 06:51, Jeff Johnson wrote:
> On 7/15/2024 6:39 AM, Zijun Hu wrote:
>> From: Zijun Hu <quic_zijuhu@quicinc.com>
>>
>> Change type of parameter @reason to enum rfkill_hard_block_reasons for
>> API rfkill_set_hw_state_reason() according to its comments.
>>
>> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
>> ---
>>  include/linux/rfkill.h | 5 ++---
>>  net/rfkill/core.c      | 7 +------
>>  2 files changed, 3 insertions(+), 9 deletions(-)
>>
>> diff --git a/include/linux/rfkill.h b/include/linux/rfkill.h
>> index 373003ace639..4f7558267541 100644
>> --- a/include/linux/rfkill.h
>> +++ b/include/linux/rfkill.h
>> @@ -147,7 +147,7 @@ void rfkill_destroy(struct rfkill *rfkill);
>>   * Prefer to use rfkill_set_hw_state if you don't need any special reason.
>>   */
>>  bool rfkill_set_hw_state_reason(struct rfkill *rfkill,
>> -				bool blocked, unsigned long reason);
>> +		bool blocked, enum rfkill_hard_block_reasons reason);
> 
> function parameters should align on (
> 
will correct it for v2
>>  /**
>>   * rfkill_set_hw_state - Set the internal rfkill hardware block state
>>   * @rfkill: pointer to the rfkill class to modify.
>> @@ -279,8 +279,7 @@ static inline void rfkill_destroy(struct rfkill *rfkill)
>>  }
>>  
>>  static inline bool rfkill_set_hw_state_reason(struct rfkill *rfkill,
>> -					      bool blocked,
>> -					      unsigned long reason)
>> +		bool blocked, enum rfkill_hard_block_reasons reason)
> 
> function parameters should align on (
> 

will correct it for v2
>>  {
>>  	return blocked;
>>  }
>> diff --git a/net/rfkill/core.c b/net/rfkill/core.c
>> index 7a5367628c05..f8ed6431b2f5 100644
>> --- a/net/rfkill/core.c
>> +++ b/net/rfkill/core.c
>> @@ -539,18 +539,13 @@ bool rfkill_get_global_sw_state(const enum rfkill_type type)
>>  #endif
>>  
>>  bool rfkill_set_hw_state_reason(struct rfkill *rfkill,
>> -				bool blocked, unsigned long reason)
>> +		bool blocked, enum rfkill_hard_block_reasons reason)
> 
> function parameters should align on (
> 
will correct it for v2
>>  {
>>  	unsigned long flags;
>>  	bool ret, prev;
>>  
>>  	BUG_ON(!rfkill);
>>  
>> -	if (WARN(reason & ~(RFKILL_HARD_BLOCK_SIGNAL |
>> -			    RFKILL_HARD_BLOCK_NOT_OWNER),
>> -		 "hw_state reason not supported: 0x%lx", reason))
>> -		return rfkill_blocked(rfkill);
>> -
> 
> did you validate that all callers are actually passing a valid enum?
> that is something you should describe in your commit since this is a change
> beyond just changing the prototype
> 
yes. actually, ALL callers within kernel tree only use enum for the API.
will add that description within v2.
thanks
>>  	spin_lock_irqsave(&rfkill->lock, flags);
>>  	prev = !!(rfkill->hard_block_reasons & reason);
>>  	if (blocked) {
>>
>> ---
>> base-commit: 338a93cf4a18c2036b567e9f613367f7a52f2511
>> change-id: 20240715-rfkill_fix-335afa2e88ca
>>
>> Best regards,
>
diff mbox series

Patch

diff --git a/include/linux/rfkill.h b/include/linux/rfkill.h
index 373003ace639..4f7558267541 100644
--- a/include/linux/rfkill.h
+++ b/include/linux/rfkill.h
@@ -147,7 +147,7 @@  void rfkill_destroy(struct rfkill *rfkill);
  * Prefer to use rfkill_set_hw_state if you don't need any special reason.
  */
 bool rfkill_set_hw_state_reason(struct rfkill *rfkill,
-				bool blocked, unsigned long reason);
+		bool blocked, enum rfkill_hard_block_reasons reason);
 /**
  * rfkill_set_hw_state - Set the internal rfkill hardware block state
  * @rfkill: pointer to the rfkill class to modify.
@@ -279,8 +279,7 @@  static inline void rfkill_destroy(struct rfkill *rfkill)
 }
 
 static inline bool rfkill_set_hw_state_reason(struct rfkill *rfkill,
-					      bool blocked,
-					      unsigned long reason)
+		bool blocked, enum rfkill_hard_block_reasons reason)
 {
 	return blocked;
 }
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index 7a5367628c05..f8ed6431b2f5 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -539,18 +539,13 @@  bool rfkill_get_global_sw_state(const enum rfkill_type type)
 #endif
 
 bool rfkill_set_hw_state_reason(struct rfkill *rfkill,
-				bool blocked, unsigned long reason)
+		bool blocked, enum rfkill_hard_block_reasons reason)
 {
 	unsigned long flags;
 	bool ret, prev;
 
 	BUG_ON(!rfkill);
 
-	if (WARN(reason & ~(RFKILL_HARD_BLOCK_SIGNAL |
-			    RFKILL_HARD_BLOCK_NOT_OWNER),
-		 "hw_state reason not supported: 0x%lx", reason))
-		return rfkill_blocked(rfkill);
-
 	spin_lock_irqsave(&rfkill->lock, flags);
 	prev = !!(rfkill->hard_block_reasons & reason);
 	if (blocked) {