linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: qlogic: qlcnic: simplify if-if to if-else
@ 2022-04-14  3:11 Yihao Han
  2022-04-15  5:48 ` Benjamin Poirier
  0 siblings, 1 reply; 3+ messages in thread
From: Yihao Han @ 2022-04-14  3:11 UTC (permalink / raw)
  To: Shahed Shaikh, Manish Chopra, GR-Linux-NIC-Dev, David S. Miller,
	Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
  Cc: kernel, Yihao Han

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(-)

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: qlogic: qlcnic: simplify if-if to if-else
  2022-04-14  3:11 [PATCH] net: qlogic: qlcnic: simplify if-if to if-else Yihao Han
@ 2022-04-15  5:48 ` Benjamin Poirier
  2022-04-15  6:17   ` Yihao Han
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Poirier @ 2022-04-15  5:48 UTC (permalink / raw)
  To: Yihao Han
  Cc: Shahed Shaikh, Manish Chopra, GR-Linux-NIC-Dev, David S. Miller,
	Jakub Kicinski, Paolo Abeni, netdev, linux-kernel, kernel

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
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: qlogic: qlcnic: simplify if-if to if-else
  2022-04-15  5:48 ` Benjamin Poirier
@ 2022-04-15  6:17   ` Yihao Han
  0 siblings, 0 replies; 3+ messages in thread
From: Yihao Han @ 2022-04-15  6:17 UTC (permalink / raw)
  To: Benjamin Poirier
  Cc: Shahed Shaikh, Manish Chopra, GR-Linux-NIC-Dev, David S. Miller,
	Jakub Kicinski, Paolo Abeni, netdev, linux-kernel, kernel



在 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-15  6:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-14  3:11 [PATCH] net: qlogic: qlcnic: simplify if-if to if-else Yihao Han
2022-04-15  5:48 ` Benjamin Poirier
2022-04-15  6:17   ` Yihao Han

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).