#include #include #include #include #include #include #include #include #include #include static int verbose; static void do_read(int fd, int len) { unsigned char buf[32], *bp; int status; /* read at least 2 bytes, no more than 32 */ if (len < 2) len = 2; else if (len > sizeof(buf)) len = sizeof(buf); memset(buf, 0, sizeof buf); status = read(fd, buf, len); if (status < 0) { perror("read"); return; } if (status != len) { fprintf(stderr, "short read\n"); return; } printf("read(%2d, %2d): %02x %02x,", len, status, buf[0], buf[1]); status -= 2; bp = buf + 2; while (status-- > 0) printf(" %02x", *bp++); printf("\n"); } static void do_msg(int fd, int len) { struct spi_ioc_transfer xfer[2]; unsigned char buf[32], *bp; int status; memset(xfer, 0, sizeof xfer); memset(buf, 0, sizeof buf); if (len > sizeof buf) len = sizeof buf; buf[0] = 0xaa; xfer[0].tx_buf = (unsigned long)buf; xfer[0].len = 1; xfer[1].rx_buf = (unsigned long) buf; xfer[1].len = len; status = ioctl(fd, SPI_IOC_MESSAGE(2), xfer); if (status < 0) { perror("SPI_IOC_MESSAGE"); return; } printf("response(%2d, %2d): ", len, status); for (bp = buf; len; len--) printf(" %02x", *bp++); printf("\n"); } static void dumpstat(const char *name, int fd) { __u8 lsb, bits; __u32 mode, speed; if (ioctl(fd, SPI_IOC_RD_MODE32, &mode) < 0) { perror("SPI rd_mode"); return; } if (ioctl(fd, SPI_IOC_RD_LSB_FIRST, &lsb) < 0) { perror("SPI rd_lsb_fist"); return; } if (ioctl(fd, SPI_IOC_RD_BITS_PER_WORD, &bits) < 0) { perror("SPI bits_per_word"); return; } if (ioctl(fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed) < 0) { perror("SPI max_speed_hz"); return; } printf("%s: spi mode 0x%x, %d bits %sper word, %d Hz max\n", name, mode, bits, lsb ? "(lsb first) " : "", speed); } int main(int argc, char **argv) { int c; int readcount = 0; int msglen = 0; int fd; const char *name; while ((c = getopt(argc, argv, "hm:r:v")) != EOF) { switch (c) { case 'm': msglen = atoi(optarg); if (msglen < 0) goto usage; continue; case 'r': readcount = atoi(optarg); if (readcount < 0) goto usage; continue; case 'v': verbose++; continue; case 'h': case '?': usage: fprintf(stderr, "usage: %s [-h] [-m N] [-r N] /dev/spidevB.D\n", argv[0]); return 1; } } if ((optind + 1) != argc) goto usage; name = argv[optind]; fd = open(name, O_RDWR); if (fd < 0) { perror("open"); return 1; } dumpstat(name, fd); if (msglen) do_msg(fd, msglen); if (readcount) do_read(fd, readcount); close(fd); return 0; } ools?id=3bf003335ba356aac5a43e28640159d4ae8a2a60'>tools/testing
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2017-01-10 15:02:16 +0100
committerDavid S. Miller <davem@davemloft.net>2017-01-10 21:00:59 -0500
commit3bf003335ba356aac5a43e28640159d4ae8a2a60 (patch)
treec06604c5d38eff0b5327305436e997155c5e82e5 /tools/testing
parenta5ef01aaac245d37edf113d65b0c146e96d841d1 (diff)
bpf: Make unnecessarily global functions static
Make the functions __local_list_pop_free(), __local_list_pop_pending(), bpf_common_lru_populate() and bpf_percpu_lru_populate() static as they are not used outide of bpf_lru_list.c This fixes the following GCC warnings when building with 'W=1': kernel/bpf/bpf_lru_list.c:363:22: warning: no previous prototype for ‘__local_list_pop_free’ [-Wmissing-prototypes] kernel/bpf/bpf_lru_list.c:376:22: warning: no previous prototype for ‘__local_list_pop_pending’ [-Wmissing-prototypes] kernel/bpf/bpf_lru_list.c:560:6: warning: no previous prototype for ‘bpf_common_lru_populate’ [-Wmissing-prototypes] kernel/bpf/bpf_lru_list.c:577:6: warning: no previous prototype for ‘bpf_percpu_lru_populate’ [-Wmissing-prototypes] Cc: Martin KaFai Lau <kafai@fb.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Acked-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Martin KaFai Lau <kafai@fb.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/testing')