Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: pi433: remove need to recompile code to debug fifo content

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>
Link: https://lore.kernel.org/r/YgCj2P59AbFFmnbA@mail.google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Paulo Miguel Almeida and committed by
Greg Kroah-Hartman
a2882e5e 1b6a6147

+2 -13
+2 -13
drivers/staging/pi433/rf69.c
··· 6 6 * Marcus Wolf <linux@wolf-entwicklungen.de> 7 7 */ 8 8 9 - /* enable prosa debug info */ 10 - #undef DEBUG 11 - /* enable print of values on fifo access */ 12 - #undef DEBUG_FIFO_ACCESS 13 - 14 9 #include <linux/types.h> 15 10 #include <linux/spi/spi.h> 16 11 ··· 824 829 825 830 int rf69_read_fifo(struct spi_device *spi, u8 *buffer, unsigned int size) 826 831 { 827 - #ifdef DEBUG_FIFO_ACCESS 828 832 int i; 829 - #endif 830 833 struct spi_transfer transfer; 831 834 u8 local_buffer[FIFO_SIZE + 1]; 832 835 int retval; ··· 844 851 845 852 retval = spi_sync_transfer(spi, &transfer, 1); 846 853 847 - #ifdef DEBUG_FIFO_ACCESS 854 + /* print content read from fifo for debugging purposes */ 848 855 for (i = 0; i < size; i++) 849 856 dev_dbg(&spi->dev, "%d - 0x%x\n", i, local_buffer[i + 1]); 850 - #endif 851 857 852 858 memcpy(buffer, &local_buffer[1], size); 853 859 ··· 855 863 856 864 int rf69_write_fifo(struct spi_device *spi, u8 *buffer, unsigned int size) 857 865 { 858 - #ifdef DEBUG_FIFO_ACCESS 859 866 int i; 860 - #endif 861 867 u8 local_buffer[FIFO_SIZE + 1]; 862 868 863 869 if (size > FIFO_SIZE) { ··· 867 877 local_buffer[0] = REG_FIFO | WRITE_BIT; 868 878 memcpy(&local_buffer[1], buffer, size); 869 879 870 - #ifdef DEBUG_FIFO_ACCESS 880 + /* print content written from fifo for debugging purposes */ 871 881 for (i = 0; i < size; i++) 872 882 dev_dbg(&spi->dev, "0x%x\n", buffer[i]); 873 - #endif 874 883 875 884 return spi_write(spi, local_buffer, size + 1); 876 885 }