linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] bnxt_en: combine 'else if' and 'else' into single branche
@ 2018-07-25 11:14 YueHaibing
  2018-07-26 14:54 ` Vasundhara Volam
  2018-07-27 15:02 ` Michael Chan
  0 siblings, 2 replies; 4+ messages in thread
From: YueHaibing @ 2018-07-25 11:14 UTC (permalink / raw)
  To: davem, michael.chan; +Cc: linux-kernel, netdev, vasundhara-v.volam, YueHaibing

The else-if branch and else branch set mac_ok to true similarly,
so combine the two into single else branch.

Aslo add comments to explain the two conditions, which
from Michael Chan and Vasundhara Volam.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
index a649108..f560845 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
@@ -956,9 +956,13 @@ static int bnxt_vf_validate_set_mac(struct bnxt *bp, struct bnxt_vf_info *vf)
 	} else if (is_valid_ether_addr(vf->vf_mac_addr)) {
 		if (ether_addr_equal((const u8 *)req->l2_addr, vf->vf_mac_addr))
 			mac_ok = true;
-	} else if (bp->hwrm_spec_code < 0x10202) {
-		mac_ok = true;
 	} else {
+		/* There are two cases:
+		 * 1.If firmware spec < 0x10202,VF MAC address is not forwarded
+		 *   to the PF and so it doesn't have to match
+		 * 2.Allow VF to modify it's own MAC when PF has not assigned a
+		 *   valid MAC address and firmware spec >= 0x10202
+		 */
 		mac_ok = true;
 	}
 	if (mac_ok)
-- 
2.7.0



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

* Re: [PATCH net-next] bnxt_en: combine 'else if' and 'else' into single branche
  2018-07-25 11:14 [PATCH net-next] bnxt_en: combine 'else if' and 'else' into single branche YueHaibing
@ 2018-07-26 14:54 ` Vasundhara Volam
  2018-07-27  5:45   ` Vasundhara Volam
  2018-07-27 15:02 ` Michael Chan
  1 sibling, 1 reply; 4+ messages in thread
From: Vasundhara Volam @ 2018-07-26 14:54 UTC (permalink / raw)
  To: YueHaibing; +Cc: David Miller, michael.chan, open list, Netdev

On Wed, Jul 25, 2018 at 4:44 PM, YueHaibing <yuehaibing@huawei.com> wrote:
>
> The else-if branch and else branch set mac_ok to true similarly,
> so combine the two into single else branch.
>
> Aslo add comments to explain the two conditions, which
> from Michael Chan and Vasundhara Volam.
>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>  drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
> index a649108..f560845 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
> @@ -956,9 +956,13 @@ static int bnxt_vf_validate_set_mac(struct bnxt *bp, struct bnxt_vf_info *vf)
>         } else if (is_valid_ether_addr(vf->vf_mac_addr)) {
>                 if (ether_addr_equal((const u8 *)req->l2_addr, vf->vf_mac_addr))
>                         mac_ok = true;
> -       } else if (bp->hwrm_spec_code < 0x10202) {
> -               mac_ok = true;
>         } else {
> +               /* There are two cases:
> +                * 1.If firmware spec < 0x10202,VF MAC address is not forwarded
> +                *   to the PF and so it doesn't have to match
> +                * 2.Allow VF to modify it's own MAC when PF has not assigned a
> +                *   valid MAC address and firmware spec >= 0x10202
> +                */
No, this is not correct either. You are not covering both conditions.
else part with cover if (!is_valid_ether_addr(vf->vf_mac_addr))
before.
>                 mac_ok = true;
>         }
>         if (mac_ok)
> --
> 2.7.0
>
>

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

* Re: [PATCH net-next] bnxt_en: combine 'else if' and 'else' into single branche
  2018-07-26 14:54 ` Vasundhara Volam
@ 2018-07-27  5:45   ` Vasundhara Volam
  0 siblings, 0 replies; 4+ messages in thread
From: Vasundhara Volam @ 2018-07-27  5:45 UTC (permalink / raw)
  To: YueHaibing; +Cc: David Miller, michael.chan, open list, Netdev

On Thu, Jul 26, 2018 at 8:24 PM, Vasundhara Volam
<vasundhara-v.volam@broadcom.com> wrote:
> On Wed, Jul 25, 2018 at 4:44 PM, YueHaibing <yuehaibing@huawei.com> wrote:
>>
>> The else-if branch and else branch set mac_ok to true similarly,
>> so combine the two into single else branch.
>>
>> Aslo add comments to explain the two conditions, which
>> from Michael Chan and Vasundhara Volam.
>>
>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>> ---
>>  drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 8 ++++++--
>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
>> index a649108..f560845 100644
>> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
>> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
>> @@ -956,9 +956,13 @@ static int bnxt_vf_validate_set_mac(struct bnxt *bp, struct bnxt_vf_info *vf)
>>         } else if (is_valid_ether_addr(vf->vf_mac_addr)) {
>>                 if (ether_addr_equal((const u8 *)req->l2_addr, vf->vf_mac_addr))
>>                         mac_ok = true;
>> -       } else if (bp->hwrm_spec_code < 0x10202) {
>> -               mac_ok = true;
>>         } else {
>> +               /* There are two cases:
>> +                * 1.If firmware spec < 0x10202,VF MAC address is not forwarded
>> +                *   to the PF and so it doesn't have to match
>> +                * 2.Allow VF to modify it's own MAC when PF has not assigned a
>> +                *   valid MAC address and firmware spec >= 0x10202
>> +                */
> No, this is not correct either. You are not covering both conditions.
> else part with cover if (!is_valid_ether_addr(vf->vf_mac_addr))
> before.
My apologies, I was thinking one more condition was required.
Patch seems fine.
>>                 mac_ok = true;
>>         }
>>         if (mac_ok)
>> --
>> 2.7.0
>>
>>

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

* Re: [PATCH net-next] bnxt_en: combine 'else if' and 'else' into single branche
  2018-07-25 11:14 [PATCH net-next] bnxt_en: combine 'else if' and 'else' into single branche YueHaibing
  2018-07-26 14:54 ` Vasundhara Volam
@ 2018-07-27 15:02 ` Michael Chan
  1 sibling, 0 replies; 4+ messages in thread
From: Michael Chan @ 2018-07-27 15:02 UTC (permalink / raw)
  To: YueHaibing; +Cc: David Miller, open list, Netdev, Vasundhara Volam

On Wed, Jul 25, 2018 at 4:14 AM, YueHaibing <yuehaibing@huawei.com> wrote:
> The else-if branch and else branch set mac_ok to true similarly,
> so combine the two into single else branch.
>
> Aslo add comments to explain the two conditions, which
> from Michael Chan and Vasundhara Volam.
>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Acked-by: Michael Chan <michael.chan@broadcom.com>

Thanks.

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

end of thread, other threads:[~2018-07-27 15:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-25 11:14 [PATCH net-next] bnxt_en: combine 'else if' and 'else' into single branche YueHaibing
2018-07-26 14:54 ` Vasundhara Volam
2018-07-27  5:45   ` Vasundhara Volam
2018-07-27 15:02 ` Michael Chan

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