Skip to content

Commit 31a5c5a

Browse files
dasGringuenbroonie
authored andcommitted
spi: spidev_test: Added verbose output
Signed-off-by: Adrian Remonda <adrianremonda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent b78ce7e commit 31a5c5a

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎Documentation/spi/spidev_test.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ static uint32_t mode;
3535
static uint8_t bits = 8;
3636
static uint32_t speed = 500000;
3737
static uint16_t delay;
38+
static int verbose;
3839

3940
static void hex_dump(const void *src, size_t length, size_t line_size, char *prefix)
4041
{
@@ -104,6 +105,8 @@ static void transfer(int fd)
104105
if (ret < 1)
105106
pabort("can't send spi message");
106107

108+
if (verbose)
109+
hex_dump(tx, ARRAY_SIZE(tx), 32, "TX");
107110
hex_dump(rx, ARRAY_SIZE(rx), 32, "RX");
108111
}
109112

@@ -120,6 +123,7 @@ static void print_usage(const char *prog)
120123
" -L --lsb least significant bit first\n"
121124
" -C --cs-high chip select active high\n"
122125
" -3 --3wire SI/SO signals shared\n"
126+
" -v --verbose Verbose (show tx buffer)\n"
123127
" -N --no-cs no chip select\n"
124128
" -R --ready slave pulls low to pause\n"
125129
" -2 --dual dual transfer\n"
@@ -144,12 +148,13 @@ static void parse_opts(int argc, char *argv[])
144148
{ "no-cs", 0, 0, 'N' },
145149
{ "ready", 0, 0, 'R' },
146150
{ "dual", 0, 0, '2' },
151+
{ "verbose", 0, 0, 'v' },
147152
{ "quad", 0, 0, '4' },
148153
{ NULL, 0, 0, 0 },
149154
};
150155
int c;
151156

152-
c = getopt_long(argc, argv, "D:s:d:b:lHOLC3NR24", lopts, NULL);
157+
c = getopt_long(argc, argv, "D:s:d:b:lHOLC3NR24:v", lopts, NULL);
153158

154159
if (c == -1)
155160
break;
@@ -188,6 +193,9 @@ static void parse_opts(int argc, char *argv[])
188193
case 'N':
189194
mode |= SPI_NO_CS;
190195
break;
196+
case 'v':
197+
verbose = 1;
198+
break;
191199
case 'R':
192200
mode |= SPI_READY;
193201
break;

0 commit comments

Comments
 (0)