diff mbox series

net: qlogic: qlcnic: simplify if-if to if-else

Message ID 20220414031111.76862-1-hanyihao@vivo.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: qlogic: qlcnic: simplify if-if to if-else | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yihao Han April 14, 2022, 3:11 a.m. UTC
Replace `if (!pause->autoneg)` with `else` for simplification
and add curly brackets according to the kernel coding style:

"Do not unnecessarily use braces where a single statement will do."

...

"This does not apply if only one branch of a conditional statement is
a single statement; in the latter case use braces in both branches"

Please refer to:
https://www.kernel.org/doc/html/v5.17-rc8/process/coding-style.html

Signed-off-by: Yihao Han <hanyihao@vivo.com>
---
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Benjamin Poirier April 15, 2022, 5:48 a.m. UTC | #1
On 2022-04-13 20:11 -0700, Yihao Han wrote:
> Replace `if (!pause->autoneg)` with `else` for simplification
> and add curly brackets according to the kernel coding style:
> 
> "Do not unnecessarily use braces where a single statement will do."
> 
> ...
> 
> "This does not apply if only one branch of a conditional statement is
> a single statement; in the latter case use braces in both branches"
> 
> Please refer to:
> https://www.kernel.org/doc/html/v5.17-rc8/process/coding-style.html

Seems the part of the log about curly brackets doesn't correspond with
the actual changes.

> 
> Signed-off-by: Yihao Han <hanyihao@vivo.com>
> ---
>  drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
> index bd0607680329..e3842eaf1532 100644
> --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
> +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
> @@ -3752,7 +3752,7 @@ int qlcnic_83xx_set_pauseparam(struct qlcnic_adapter *adapter,
>  	if (ahw->port_type == QLCNIC_GBE) {
>  		if (pause->autoneg)
>  			ahw->port_config |= QLC_83XX_ENABLE_AUTONEG;
> -		if (!pause->autoneg)
> +		else
>  			ahw->port_config &= ~QLC_83XX_ENABLE_AUTONEG;
>  	} else if ((ahw->port_type == QLCNIC_XGBE) && (pause->autoneg)) {
>  		return -EOPNOTSUPP;
> -- 
> 2.17.1
>
Yihao Han April 15, 2022, 6:17 a.m. UTC | #2
在 2022/4/15 13:48, Benjamin Poirier 写道:
> On 2022-04-13 20:11 -0700, Yihao Han wrote:
>> Replace `if (!pause->autoneg)` with `else` for simplification
>> and add curly brackets according to the kernel coding style:
>>
>> "Do not unnecessarily use braces where a single statement will do."
>>
>> ...
>>
>> "This does not apply if only one branch of a conditional statement is
>> a single statement; in the latter case use braces in both branches"
>>
>> Please refer to:
>> https://www.kernel.org/doc/html/v5.17-rc8/process/coding-style.html
> 
> Seems the part of the log about curly brackets doesn't correspond with
> the actual changes.
> 
>>
>> Signed-off-by: Yihao Han <hanyihao@vivo.com>
>> ---
>>   drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
>> index bd0607680329..e3842eaf1532 100644
>> --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
>> +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
>> @@ -3752,7 +3752,7 @@ int qlcnic_83xx_set_pauseparam(struct qlcnic_adapter *adapter,
>>   	if (ahw->port_type == QLCNIC_GBE) {
>>   		if (pause->autoneg)
>>   			ahw->port_config |= QLC_83XX_ENABLE_AUTONEG;
>> -		if (!pause->autoneg)
>> +		else
>>   			ahw->port_config &= ~QLC_83XX_ENABLE_AUTONEG;
>>   	} else if ((ahw->port_type == QLCNIC_XGBE) && (pause->autoneg)) {
>>   		return -EOPNOTSUPP;
>> -- 
>> 2.17.1
>>
Sorry that I made a mistake. I will send a v2 patch about this.
Thanks for your review.

regards,
Yihao
diff mbox series

Patch

diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
index bd0607680329..e3842eaf1532 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
@@ -3752,7 +3752,7 @@  int qlcnic_83xx_set_pauseparam(struct qlcnic_adapter *adapter,
 	if (ahw->port_type == QLCNIC_GBE) {
 		if (pause->autoneg)
 			ahw->port_config |= QLC_83XX_ENABLE_AUTONEG;
-		if (!pause->autoneg)
+		else
 			ahw->port_config &= ~QLC_83XX_ENABLE_AUTONEG;
 	} else if ((ahw->port_type == QLCNIC_XGBE) && (pause->autoneg)) {
 		return -EOPNOTSUPP;