Netdev Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v1] ice: devlink: use %*phD to print small buffer
@ 2020-07-30 16:04 Andy Shevchenko
  2020-07-30 21:20 ` Jacob Keller
  2020-07-31 23:49 ` David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Andy Shevchenko @ 2020-07-30 16:04 UTC (permalink / raw)
  To: Jeff Kirsher, intel-wired-lan, David S. Miller, Jakub Kicinski,
	netdev, Jacob Keller
  Cc: Andy Shevchenko

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

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;
 }
-- 
2.27.0


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

* Re: [PATCH v1] ice: devlink: use %*phD to print small buffer
  2020-07-30 16:04 [PATCH v1] ice: devlink: use %*phD to print small buffer Andy Shevchenko
@ 2020-07-30 21:20 ` Jacob Keller
  2020-07-31  7:49   ` Andy Shevchenko
  2020-07-31 23:49 ` David Miller
  1 sibling, 1 reply; 5+ messages in thread
From: Jacob Keller @ 2020-07-30 21:20 UTC (permalink / raw)
  To: Andy Shevchenko, Jeff Kirsher, intel-wired-lan, David S. Miller,
	Jakub Kicinski, netdev



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;
>  }
> 

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

* Re: [PATCH v1] ice: devlink: use %*phD to print small buffer
  2020-07-30 21:20 ` Jacob Keller
@ 2020-07-31  7:49   ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2020-07-31  7:49 UTC (permalink / raw)
  To: Jacob Keller
  Cc: Jeff Kirsher, intel-wired-lan, David S. Miller, Jakub Kicinski, netdev

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!

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v1] ice: devlink: use %*phD to print small buffer
  2020-07-30 16:04 [PATCH v1] ice: devlink: use %*phD to print small buffer Andy Shevchenko
  2020-07-30 21:20 ` Jacob Keller
@ 2020-07-31 23:49 ` David Miller
  2020-08-01  0:07   ` [Intel-wired-lan] " Nguyen, Anthony L
  1 sibling, 1 reply; 5+ messages in thread
From: David Miller @ 2020-07-31 23:49 UTC (permalink / raw)
  To: andriy.shevchenko
  Cc: jeffrey.t.kirsher, intel-wired-lan, kuba, netdev, jacob.e.keller

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.

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

* Re: [Intel-wired-lan] [PATCH v1] ice: devlink: use %*phD to print small buffer
  2020-07-31 23:49 ` David Miller
@ 2020-08-01  0:07   ` Nguyen, Anthony L
  0 siblings, 0 replies; 5+ messages in thread
From: Nguyen, Anthony L @ 2020-08-01  0:07 UTC (permalink / raw)
  To: davem, andriy.shevchenko; +Cc: kuba, netdev, intel-wired-lan

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.

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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-30 16:04 [PATCH v1] ice: devlink: use %*phD to print small buffer Andy Shevchenko
2020-07-30 21:20 ` Jacob Keller
2020-07-31  7:49   ` Andy Shevchenko
2020-07-31 23:49 ` David Miller
2020-08-01  0:07   ` [Intel-wired-lan] " Nguyen, Anthony L

Netdev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netdev/0 netdev/git/0.git
	git clone --mirror https://lore.kernel.org/netdev/1 netdev/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netdev netdev/ https://lore.kernel.org/netdev \
		netdev@vger.kernel.org
	public-inbox-index netdev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netdev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git