Re: [PATCH] staging: pi433: add rf69_dbg_hex function

From: Paulo Miguel Almeida
Date: Fri Feb 11 2022 - 14:39:38 EST


On Fri, Feb 11, 2022 at 09:14:40AM +0100, Greg KH wrote:
>
> This is a lot of additional complexity for almost no real benefit.
>

you're right. I will no longer pursue this approach.

> > - /* 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]);
>
> What is wrong with this simple line?
>

to be honest, I think that 1 register per line isn't the easiest way to
read them. Given that print_hex_dump_debug existed and had this
horizontal-style priting format, I thought that it would be a better
way of visualizing the fifo data.

the only problems with print_hex_dump_debug was the absense of device
name and string format... so I saw a couple of drivers implementing
alternative hex_dump-like functions and thought that pi433 would benefit
from similar approach.

> > - /* print content written from fifo for debugging purposes */
> > - for (i = 0; i < size; i++)
> > - dev_dbg(&spi->dev, "0x%x\n", buffer[i]);

if we are keeping this format, I may need to add the register idx to
dev_dbg:
dev_dbg(&spi->dev, "%d - 0x%x\n", i, buffer[i]);

> Again, the original is fine here, why make this so complex?

[thinking out loud/brainstorm]

I do agree that, for just a single driver, having a method like that
seemed unnecessary but do you think it would be a good idea having
something like dev_dbg_hex_dump or similar?

print_hex_dump_debug has the following limitation:

1) lacks string format
2) doesn't honor dynamic debug flags (other then 'p')
3) doesn't print device driver name and device name

> > + rf69_dbg_hex(spi, local_buffer + 1, size, "%s - ", __func__);
>
> Also, you are using local_buffer here, not buffer, why?
>

That was a mistake, good catch.

> I think the original is just fine, no need to polish something as tiny
> as a hex dump for debugging only.
>
> thanks,
>
> greg k-h

thanks for taking the time to review the patch, I won't pursue this
approach anymore.

thanks,

Paulo Almeida