lkml.org 
[lkml]   [2020]   [May]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/3] tty: n_gsm: Improve debug output
From
Date
On 30. 04. 20, 13:34, Gregory CLEMENT wrote:
> Use appropriate print helpers for debug messages.
>
> Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
> ---
> drivers/tty/n_gsm.c | 18 +++++-------------
> 1 file changed, 5 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
> index d77ed82a4840..4965e39e0223 100644
> --- a/drivers/tty/n_gsm.c
> +++ b/drivers/tty/n_gsm.c
> @@ -459,7 +459,7 @@ static void gsm_print_packet(const char *hdr, int addr, int cr,
> if (!(debug & 1))
> return;
>
> - pr_info("%s %d) %c: ", hdr, addr, "RC"[cr]);
> + pr_debug("%s %d) %c: ", hdr, addr, "RC"[cr]);

Now, you need both debug=1 module parameter *and* fiddling with
dynamic_debug, if enabled. And it is enabled in most distros…

We don't have any unconditional KERN_DEBUG printk helper, unfortunately.

> switch (control & ~PF) {
> case SABM:
> @@ -504,18 +504,10 @@ static void gsm_print_packet(const char *hdr, int addr, int cr,
> else
> pr_cont("(F)");
>
> - if (dlen) {
> - int ct = 0;
> - while (dlen--) {
> - if (ct % 8 == 0) {
> - pr_cont("\n");
> - pr_debug(" ");
> - }
> - pr_cont("%02X ", *data++);
> - ct++;
> - }
> - }
> - pr_cont("\n");
> + if (dlen)

print_hex_dump* handle zero len quite well. No need for the if.

> + print_hex_dump_bytes("", DUMP_PREFIX_NONE, data, dlen);
> +
> + pr_debug("\n");

This is superfluous too. It was intended as the last \n in the previous
code.

thanks,
--
js
suse labs

\
 
 \ /
  Last update: 2020-05-04 08:38    [W:0.072 / U:0.520 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site