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

spi: Enable tracing of the SPI setup CS selection

It is helpful to see what state of CS signal was during one
or another SPI operation. All the same for SPI setup.

Enable tracing of the SPI setup and CS selection.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Message-Id: <20210526195655.75691-1-andriy.shevchenko@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Andy Shevchenko and committed by
Mark Brown
5cb4e1f3 ab053f48

+61
+4
drivers/spi/spi.c
··· 804 804 (spi->controller->last_cs_mode_high == (spi->mode & SPI_CS_HIGH))) 805 805 return; 806 806 807 + trace_spi_set_cs(spi, activate); 808 + 807 809 spi->controller->last_cs_enable = enable; 808 810 spi->controller->last_cs_mode_high = spi->mode & SPI_CS_HIGH; 809 811 ··· 3442 3440 spi->controller->rt = true; 3443 3441 spi_set_thread_rt(spi->controller); 3444 3442 } 3443 + 3444 + trace_spi_setup(spi, status); 3445 3445 3446 3446 dev_dbg(&spi->dev, "setup mode %lu, %s%s%s%s%u bits/w, %u Hz max --> %d\n", 3447 3447 spi->mode & SPI_MODE_X_MASK,
+57
include/trace/events/spi.h
··· 42 42 43 43 ); 44 44 45 + TRACE_EVENT(spi_setup, 46 + TP_PROTO(struct spi_device *spi, int status), 47 + TP_ARGS(spi, status), 48 + 49 + TP_STRUCT__entry( 50 + __field(int, bus_num) 51 + __field(int, chip_select) 52 + __field(unsigned long, mode) 53 + __field(unsigned int, bits_per_word) 54 + __field(unsigned int, max_speed_hz) 55 + __field(int, status) 56 + ), 57 + 58 + TP_fast_assign( 59 + __entry->bus_num = spi->controller->bus_num; 60 + __entry->chip_select = spi->chip_select; 61 + __entry->mode = spi->mode; 62 + __entry->bits_per_word = spi->bits_per_word; 63 + __entry->max_speed_hz = spi->max_speed_hz; 64 + __entry->status = status; 65 + ), 66 + 67 + TP_printk("spi%d.%d setup mode %lu, %s%s%s%s%u bits/w, %u Hz max --> %d", 68 + __entry->bus_num, __entry->chip_select, 69 + (__entry->mode & SPI_MODE_X_MASK), 70 + (__entry->mode & SPI_CS_HIGH) ? "cs_high, " : "", 71 + (__entry->mode & SPI_LSB_FIRST) ? "lsb, " : "", 72 + (__entry->mode & SPI_3WIRE) ? "3wire, " : "", 73 + (__entry->mode & SPI_LOOP) ? "loopback, " : "", 74 + __entry->bits_per_word, __entry->max_speed_hz, 75 + __entry->status) 76 + ); 77 + 78 + TRACE_EVENT(spi_set_cs, 79 + TP_PROTO(struct spi_device *spi, bool enable), 80 + TP_ARGS(spi, enable), 81 + 82 + TP_STRUCT__entry( 83 + __field(int, bus_num) 84 + __field(int, chip_select) 85 + __field(unsigned long, mode) 86 + __field(bool, enable) 87 + ), 88 + 89 + TP_fast_assign( 90 + __entry->bus_num = spi->controller->bus_num; 91 + __entry->chip_select = spi->chip_select; 92 + __entry->mode = spi->mode; 93 + __entry->enable = enable; 94 + ), 95 + 96 + TP_printk("spi%d.%d %s%s", 97 + __entry->bus_num, __entry->chip_select, 98 + __entry->enable ? "activate" : "deactivate", 99 + (__entry->mode & SPI_CS_HIGH) ? ", cs_high" : "") 100 + ); 101 + 45 102 DECLARE_EVENT_CLASS(spi_message, 46 103 47 104 TP_PROTO(struct spi_message *msg),