From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Jie Deng <Jie.Deng1@synopsys.com>, netdev@vger.kernel.org
Cc: davem@davemloft.net, Jose.Abreu@synopsys.com
Subject: Re: [PATCH net-next] net: dwc-xlgmac: Get rid of custom hex_dump_to_buffer()
Date: Thu, 21 Dec 2017 14:23:05 +0200 [thread overview]
Message-ID: <1513858985.7000.241.camel@linux.intel.com> (raw)
In-Reply-To: <4289b06ad532868c24d92e5ffa5eeb7934cb3d6f.1513833970.git.jiedeng@synopsys.com>
On Thu, 2017-12-21 at 13:32 +0800, Jie Deng wrote:
> Get rid of custom hex_dump_to_buffer().
>
> The output is slightly changed, i.e. each byte followed by white
> space.
>
> Note, we don't use print_hex_dump() here since the original code uses
> nedev_dbg().
>
Jie, thanks for taking care of update.
David, please, consider this one to be applied.
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Jie Deng <jiedeng@synopsys.com>
> ---
> drivers/net/ethernet/synopsys/dwc-xlgmac-common.c | 24 +++++++-------
> ---------
> 1 file changed, 7 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/net/ethernet/synopsys/dwc-xlgmac-common.c
> b/drivers/net/ethernet/synopsys/dwc-xlgmac-common.c
> index d655a42..eb1c6b0 100644
> --- a/drivers/net/ethernet/synopsys/dwc-xlgmac-common.c
> +++ b/drivers/net/ethernet/synopsys/dwc-xlgmac-common.c
> @@ -333,9 +333,8 @@ void xlgmac_print_pkt(struct net_device *netdev,
> struct sk_buff *skb, bool tx_rx)
> {
> struct ethhdr *eth = (struct ethhdr *)skb->data;
> - unsigned char *buf = skb->data;
> unsigned char buffer[128];
> - unsigned int i, j;
> + unsigned int i;
>
> netdev_dbg(netdev, "\n************** SKB dump
> ****************\n");
>
> @@ -346,22 +345,13 @@ void xlgmac_print_pkt(struct net_device *netdev,
> netdev_dbg(netdev, "Src MAC addr: %pM\n", eth->h_source);
> netdev_dbg(netdev, "Protocol: %#06hx\n", ntohs(eth-
> >h_proto));
>
> - for (i = 0, j = 0; i < skb->len;) {
> - j += snprintf(buffer + j, sizeof(buffer) - j,
> "%02hhx",
> - buf[i++]);
> -
> - if ((i % 32) == 0) {
> - netdev_dbg(netdev, " %#06x: %s\n", i - 32,
> buffer);
> - j = 0;
> - } else if ((i % 16) == 0) {
> - buffer[j++] = ' ';
> - buffer[j++] = ' ';
> - } else if ((i % 4) == 0) {
> - buffer[j++] = ' ';
> - }
> + for (i = 0; i < skb->len; i += 32) {
> + unsigned int len = min(skb->len - i, 32U);
> +
> + hex_dump_to_buffer(&skb->data[i], len, 32, 1,
> + buffer, sizeof(buffer), false);
> + netdev_dbg(netdev, " %#06x: %s\n", i, buffer);
> }
> - if (i % 32)
> - netdev_dbg(netdev, " %#06x: %s\n", i - (i % 32),
> buffer);
>
> netdev_dbg(netdev, "\n************** SKB dump
> ****************\n");
> }
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
next prev parent reply other threads:[~2017-12-21 12:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-21 5:32 [PATCH net-next] net: dwc-xlgmac: Get rid of custom hex_dump_to_buffer() Jie Deng
2017-12-21 12:23 ` Andy Shevchenko [this message]
2017-12-21 20:06 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1513858985.7000.241.camel@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=Jie.Deng1@synopsys.com \
--cc=Jose.Abreu@synopsys.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).