mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
	Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
Cc: gregkh@linuxfoundation.org, realwakka@gmail.com,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: pi433: remove need to recompile code to debug fifo content
Date: Mon, 07 Feb 2022 02:15:47 -0800	[thread overview]
Message-ID: <a630d8381cee0f543e0d77614052e1d04ab162a5.camel@perches.com> (raw)
In-Reply-To: <20220207100601.GF1951@kadam>

On Mon, 2022-02-07 at 13:06 +0300, Dan Carpenter wrote:
> On Mon, Feb 07, 2022 at 05:45:12PM +1300, Paulo Miguel Almeida wrote:
> > Debugging content present in the FIFO register is tricky as when we read
> > the FIFO register that changes the content of fifo struct which reduces
> > number of possible ways of debugging it. Rf69 uC has the possibility of
> > triggering certain IRQs depending on how many items are in the FIFO
> > queue, so being able to know what's in there is an important way to
> > troubleshoot certain problems.
> > 
> > This patch removes the requirement of having to compile pi433 driver
> > with DEBUG_FIFO_ACCESS set and let that be driven by printk verbositity
> > level and/or dynamic debug config instead.
> > 
> > Signed-off-by: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
> > ---
> > Meta-comments:
> > 
> > #1
> > In my mind, I didn't like the idea of having to change the code and then 
> > echo "module pi433 +p" > <debugfs>/dynamic_debug/control to only then
> > be able to read stuff being sent/retrieved from fifo. It felt somewhat
> > redundant at a certain level. On the other hand, I understand that
> > removing the conditional compilation will force a for-loop to iterate
> > for no real reason most of the time (max 66 iterations)... so I made a 
> > trade-off and in case anyone disagrees with that, just let me know and I
> > will be happy to change to a different approach.
> > 
> 
> This is fine.  It's useful information to you.  It's makes the code
> nicer by removing ifdefs.  It's not going to show up in benchmarking.
> 
> > #2
> > In the past, it's been pointed out to me during code review that I tend
> > to add code comments which could be omitted. In this case, the for-loop
> > seemed a bit odd without explaining why it's in there. Let me know if
> > you think I should keep/remove it.
> 
> Remove.  Everyone knows what dev_dbg() does and the "read from fifo"
> vs "written from[sic] fifo" is built into the function name.
> 
> >  int rf69_read_fifo(struct spi_device *spi, u8 *buffer, unsigned int size)
> >  {
[]
> > @@ -851,10 +844,9 @@ int rf69_read_fifo(struct spi_device *spi, u8 *buffer, unsigned int size)
> >  
> >  	retval = spi_sync_transfer(spi, &transfer, 1);
> >  
> > -#ifdef DEBUG_FIFO_ACCESS
> > +	/* print content read from fifo for debugging purposes */
> >  	for (i = 0; i < size; i++)
> >  		dev_dbg(&spi->dev, "%d - 0x%x\n", i, local_buffer[i + 1]);
> > -#endif

If you use

	print_hex_dump_debug

perhaps the DEBUG_FIFO_ACCESS could be removed.



  reply	other threads:[~2022-02-07 10:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-07  4:45 Paulo Miguel Almeida
2022-02-07 10:06 ` Dan Carpenter
2022-02-07 10:15   ` Joe Perches [this message]
2022-02-08  3:54     ` Paulo Miguel Almeida
2022-02-08  3:56   ` Paulo Miguel Almeida

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=a630d8381cee0f543e0d77614052e1d04ab162a5.camel@perches.com \
    --to=joe@perches.com \
    --cc=dan.carpenter@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=paulo.miguel.almeida.rodenas@gmail.com \
    --cc=realwakka@gmail.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

all inboxes | Powered by JetHome®