Message ID | 20200730160451.40810-1-andriy.shevchenko@linux.intel.com |
---|---|
State | Accepted |
Delegated to: | Anthony Nguyen |
Headers | show |
Series | [v1] ice: devlink: use %*phD to print small buffer | expand |
On 7/30/2020 9:04 AM, Andy Shevchenko wrote: > Use %*phD format to print small buffer as hex string. > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> 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. Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> 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 <jacob.e.keller@intel.com> Thanks! > --- > drivers/net/ethernet/intel/ice/ice_devlink.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/net/ethernet/intel/ice/ice_devlink.c b/drivers/net/ethernet/intel/ice/ice_devlink.c > index dbbd8b6f9d1a..a9105ad5b983 100644 > --- a/drivers/net/ethernet/intel/ice/ice_devlink.c > +++ b/drivers/net/ethernet/intel/ice/ice_devlink.c > @@ -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; > } >
On Thu, Jul 30, 2020 at 02:20:46PM -0700, Jacob Keller wrote: > On 7/30/2020 9:04 AM, Andy Shevchenko wrote: > > Use %*phD format to print small buffer as hex string. > > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > 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 <andriy.shevchenko@linux.intel.com> Date: Mon Jul 30 14:40:27 2012 -0700 vsprintf: add support of '%*ph[CDN]' Maybe it was just a coincidence :-) > Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> > > 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 <jacob.e.keller@intel.com> Thanks!
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Date: Thu, 30 Jul 2020 19:04:51 +0300 > Use %*phD format to print small buffer as hex string. > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> I am assuming the Intel folks will integrate this into their tree.
On Fri, 2020-07-31 at 16:49 -0700, David Miller wrote: > From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > Date: Thu, 30 Jul 2020 19:04:51 +0300 > > > Use %*phD format to print small buffer as hex string. > > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > I am assuming the Intel folks will integrate this into their tree. Yes, I'll take it into the Intel tree.
diff --git a/drivers/net/ethernet/intel/ice/ice_devlink.c b/drivers/net/ethernet/intel/ice/ice_devlink.c index dbbd8b6f9d1a..a9105ad5b983 100644 --- a/drivers/net/ethernet/intel/ice/ice_devlink.c +++ b/drivers/net/ethernet/intel/ice/ice_devlink.c @@ -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; }
Use %*phD format to print small buffer as hex string. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/net/ethernet/intel/ice/ice_devlink.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)