ice: devlink: use %*phD to print small buffer
Subsystems (3)
PATCH 1/1 ice: devlink: use %*phD to print small buffer
Use %*phD format to print small buffer as hex string.
--- drivers/net/ethernet/intel/ice/ice_devlink.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/intel/ice/ice_devlink.c +1 -3
@@ -13,9 +13,7 @@ static int ice_info_get_dsn(struct ice_pf *pf, char *buf, size_t len)/* Copy the DSN into an array in Big Endian format */ put_unaligned_be64 (pci_get_dsn (pf->pdev), dsn); -snprintf (buf, len,"%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x" , - dsn[0 ], dsn[1 ], dsn[2 ], dsn[3 ], - dsn[4 ], dsn[5 ], dsn[6 ], dsn[7 ]); +snprintf (buf, len,"%8phD" , dsn);return 0 ; }
Signature · 1 line
2.27.0
Quoted 3 lines · Andy Shevchenko
Use %*phD format to print small buffer as hex string.
Signed-off-by Andy Shevchenko <[email protected]>
Ah nice. I swear I looked for a printk format to do this and didn't find one. But it's been there since 2012.. so I guess I just missed it.
I also tested this on my system to make sure it gives the same output for the serial value, so I guess also:
Thanks!
Quoted 20 lines
--- drivers/net/ethernet/intel/ice/ice_devlink.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/net/ethernet/intel/ice/ice_devlink.c +1
-3@@ -13,9 +13,7 @@ static int ice_info_get_dsn(struct ice_pf *pf, char *buf, size_t len)/* Copy the DSN into an array in Big Endian format */ put_unaligned_be64 (pci_get_dsn (pf->pdev), dsn); -snprintf (buf, len,"%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x" , - dsn[0 ], dsn[1 ], dsn[2 ], dsn[3 ], - dsn[4 ], dsn[5 ], dsn[6 ], dsn[7 ]); +snprintf (buf, len,"%8phD" , dsn);return 0 ; }
Quoted 7 lines · Jacob Keller
Quoted 3 lines · Andy Shevchenko
Use %*phD format to print small buffer as hex string.
Signed-off-by Andy Shevchenko <[email protected]>Ah nice. I swear I looked for a printk format to do this and didn't find one. But it's been there since 2012.. so I guess I just missed it.
commit 31550a16a5d2af859e8a11839e8c6c6c9c92dfa7
Author: Andy Shevchenko <[email protected]> Date: Mon Jul 30 14:40:27 2012 -0700
vsprintf: add support of '%*ph[CDN]'
Maybe it was just a coincidence :-)
Quoted 6 lines
Reviewed-by Jacob Keller <[email protected]>I also tested this on my system to make sure it gives the same output for the serial value, so I guess also:
Tested-by Jacob Keller <[email protected]>
Thanks!
Signature · 2 lines
With Best Regards, Andy Shevchenko
David Miller
maintainerFrom: Andy Shevchenko <[email protected]>
Date: Thu, 30 Jul 2020 19:04:51 +0300
Quoted 3 lines
Use %*phD format to print small buffer as hex string.
Signed-off-by Andy Shevchenko <[email protected]>
I am assuming the Intel folks will integrate this into their tree.
Nguyen, Anthony L
maintainerQuoted 8 lines · David Miller
From: Andy Shevchenko <[email protected]>
Date: Thu, 30 Jul 2020 19:04:51 +0300Quoted 3 lines
Use %*phD format to print small buffer as hex string.
Signed-off-by Andy Shevchenko <[email protected]>I am assuming the Intel folks will integrate this into their tree.
Yes, I'll take it into the Intel tree.