diff mbox series

[net-next,2/3] octeontx2-af: Use u64_to_ether_addr() to convert ethernet address

Message ID 20230808114504.4036008-3-lizetao1@huawei.com (mailing list archive)
State Accepted
Commit e62c7adfd4acc394c448870ba63d4315e7a662f6
Delegated to: Netdev Maintainers
Headers show
Series Remove redundant functions and use generic functions | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
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: 9 this patch: 9
netdev/cc_maintainers success CCed 11 of 11 maintainers
netdev/build_clang success Errors and warnings before: 1353 this patch: 1353
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: 1353 this patch: 1353
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 17 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

lizetao Aug. 8, 2023, 11:45 a.m. UTC
Use u64_to_ether_addr() to convert a u64 value to an Ethernet MAC address,
instead of directly calculating, as this is exactly what this
function does.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
 drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Geethasowjanya Akula Aug. 9, 2023, 3:30 a.m. UTC | #1
> -----Original Message-----
> From: Li Zetao <lizetao1@huawei.com>
> Sent: Tuesday, August 8, 2023 5:15 PM
> To: Sunil Kovvuri Goutham <sgoutham@marvell.com>; Linu Cherian
> <lcherian@marvell.com>; Geethasowjanya Akula <gakula@marvell.com>;
> Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Hariprasad Kelam
> <hkelam@marvell.com>; Subbaraya Sundeep Bhatta
> <sbhatta@marvell.com>; davem@davemloft.net; edumazet@google.com;
> kuba@kernel.org; pabeni@redhat.com
> Cc: lizetao1@huawei.com; netdev@vger.kernel.org
> Subject: [EXT] [PATCH net-next 2/3] octeontx2-af: Use u64_to_ether_addr()
> to convert ethernet address
> 
> External Email
> 
> ----------------------------------------------------------------------
> Use u64_to_ether_addr() to convert a u64 value to an Ethernet MAC
> address, instead of directly calculating, as this is exactly what this function
> does.
> 
> Signed-off-by: Li Zetao <lizetao1@huawei.com>
> ---
>  drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
> b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
> index 095b2cc4a699..b3f766b970ca 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
> @@ -686,7 +686,7 @@ int rvu_mbox_handler_cgx_mac_addr_get(struct rvu
> *rvu,  {
>  	int pf = rvu_get_pf(req->hdr.pcifunc);
>  	u8 cgx_id, lmac_id;
> -	int rc = 0, i;
> +	int rc = 0;
>  	u64 cfg;
> 
>  	if (!is_cgx_config_permitted(rvu, req->hdr.pcifunc)) @@ -697,8
> +697,7 @@ int rvu_mbox_handler_cgx_mac_addr_get(struct rvu *rvu,
>  	rsp->hdr.rc = rc;
>  	cfg = cgx_lmac_addr_get(cgx_id, lmac_id);
>  	/* copy 48 bit mac address to req->mac_addr */
> -	for (i = 0; i < ETH_ALEN; i++)
> -		rsp->mac_addr[i] = cfg >> (ETH_ALEN - 1 - i) * 8;
> +	u64_to_ether_addr(cfg, rsp->mac_addr);
>  	return 0;
>  }
> 
> --
> 2.34.1
Ack.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
index 095b2cc4a699..b3f766b970ca 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
@@ -686,7 +686,7 @@  int rvu_mbox_handler_cgx_mac_addr_get(struct rvu *rvu,
 {
 	int pf = rvu_get_pf(req->hdr.pcifunc);
 	u8 cgx_id, lmac_id;
-	int rc = 0, i;
+	int rc = 0;
 	u64 cfg;
 
 	if (!is_cgx_config_permitted(rvu, req->hdr.pcifunc))
@@ -697,8 +697,7 @@  int rvu_mbox_handler_cgx_mac_addr_get(struct rvu *rvu,
 	rsp->hdr.rc = rc;
 	cfg = cgx_lmac_addr_get(cgx_id, lmac_id);
 	/* copy 48 bit mac address to req->mac_addr */
-	for (i = 0; i < ETH_ALEN; i++)
-		rsp->mac_addr[i] = cfg >> (ETH_ALEN - 1 - i) * 8;
+	u64_to_ether_addr(cfg, rsp->mac_addr);
 	return 0;
 }