Linux wireless drivers development
 help / color / mirror / Atom feed
From: Vladimir Kondratiev <vkondrat@qti.qualcomm.com>
To: Joe Perches <joe@perches.com>
Cc: "John W . Linville" <linville@tuxdriver.com>,
	Johannes Berg <johannes@sipsolutions.net>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-wireless@vger.kernel.org,
	"Luis R . Rodriguez" <rodrigue@qca.qualcomm.com>,
	Jason Baron <jbaron@redhat.com>,
	Jim Cromie <jim.cromie@gmail.com>,
	Greg KH <gregkh@linuxfoundation.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] dynamic_debug: introduce debug_hex_dump()
Date: Sun, 18 Nov 2012 15:51:26 +0200	[thread overview]
Message-ID: <1367870.EsNpLZfRqp@lx-vladimir> (raw)
In-Reply-To: <3304277.iqgq3GH3Yo@lx-vladimir>

On Sunday, November 18, 2012 11:47:58 AM Vladimir Kondratiev wrote:
> On Wednesday, November 14, 2012 07:27:47 PM Vladimir Kondratiev wrote:
> > +#define dynamic_hex_dump(prefix_str, prefix_type, rowsize,     \
> > +                        groupsize, buf, len, ascii)            \
> > +do {                                                           \
> > +       DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, prefix_str);  \
> > +       if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT))  \
> > +               print_hex_dump(KERN_DEBUG, prefix_str,          \
> > +                              prefix_type, rowsize, groupsize, \
> > +                              buf, len, ascii);                \
> > +} while (0)
> 
> There is some problem with the code above. There are existing drivers
> that use print_hex_dump_bytes() with the prefix_str built dynamically,
> like this (see drivers/tty/ipwireless/hardware.c:362)
> 
> static void dump_data_bytes(const char *type, const unsigned char *data,
> 			    unsigned length)
> {
> 	char prefix[56];
> 
> 	sprintf(prefix, IPWIRELESS_PCCARD_NAME ": %s %s ",
> 			type, data_type(data, length));
> 	print_hex_dump_bytes(prefix, 0, (void *)data,
> 			length < DUMP_MAX_BYTES ? length : DUMP_MAX_BYTES);
> }
> 
> In this case, prefix_str is not constant, and this solution will not
> work.
> 
> I see 2 drivers that use dynamic prefix:
> 
> - mentioned above drivers/tty/ipwireless/hardware.c
> - drivers/isdn/hardware/mISDN/
> 
> I see several options:
> 
> 1) require prefix_str to be constant. Patch code mentioned. For example,
> code above may reads:
> 
> static void dump_data_bytes(const char *type, const unsigned char *data,
> 			    unsigned length)
> {
> 	pr_debug(IPWIRELESS_PCCARD_NAME ": %s %s\n",
> 			type, data_type(data, length));
> 	print_hex_dump_bytes(IPWIRELESS_PCCARD_NAME, 0, (void *)data,
> 			length < DUMP_MAX_BYTES ? length : DUMP_MAX_BYTES);
> }
> 
> 2) introduce fixed format string in DEFINE_DYNAMIC_DEBUG_METADATA, like
> 
> DEFINE_DYNAMIC_DEBUG_METADATA((descriptor, "hexdump");
> 
> 3) remove print_hex_dump_bytes from this patch
> 
> I think 1) is the best, opinions?
> 
> Thanks, Vladimir

In case of option 1), patches follows. Note there is change in the initial patch as well (I forgot to exclude print_hex_dump_bytes() from compilation in hexdump.c. Please, comment.



  parent reply	other threads:[~2012-11-18 13:53 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-14 12:17 [RFC] debug_hex_dump() Vladimir Kondratiev
2012-11-14 12:17 ` [RFC] dynamic_debug: introduce debug_hex_dump() Vladimir Kondratiev
2012-11-14 13:41   ` Joe Perches
2012-11-14 16:18     ` Vladimir Kondratiev
2012-11-14 17:08       ` Joe Perches
2012-11-14 17:27         ` Vladimir Kondratiev
     [not found]           ` <3304277.iqgq3GH3Yo@lx-vladimir>
2012-11-18 13:51             ` Vladimir Kondratiev [this message]
2012-11-18 13:55               ` [PATCH 2/2] dynamic_debug: use constant format in print_hex_dump_bytes() Vladimir Kondratiev
2012-11-18 13:57               ` [PATCH 1/2] dynamic_debug: dynamic hex dump Vladimir Kondratiev
2012-11-18 14:38             ` [RFC] dynamic_debug: introduce debug_hex_dump() Joe Perches
2012-11-18 15:43               ` Vladimir Kondratiev
2012-11-18 17:01                 ` Vladimir Kondratiev
2012-11-18 18:35                   ` Joe Perches
2012-11-20 16:08                     ` Jason Baron
2012-12-04  9:28                       ` Vladimir Kondratiev
2012-12-11 19:36                         ` Luis R. Rodriguez
2012-12-11 20:08                           ` Jason Baron
2012-12-11 20:12                             ` Greg KH
2012-12-11 20:24                               ` Joe Perches
2012-12-11 22:55                                 ` Luis R. Rodriguez
2012-12-12  9:12                                   ` Vladimir Kondratiev
2012-12-12 15:41                                     ` Luis R. Rodriguez

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=1367870.EsNpLZfRqp@lx-vladimir \
    --to=vkondrat@qti.qualcomm.com \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jbaron@redhat.com \
    --cc=jim.cromie@gmail.com \
    --cc=joe@perches.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=rodrigue@qca.qualcomm.com \
    /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