aboutsummaryrefslogtreecommitdiffstats
path: root/tools/firewire/nosy-dump.c
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2010-07-22 05:58:05 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2010-07-27 05:04:12 -0400
commitddbfe74958ec21c3d58d5a46dd6f4048bc7969a4 (patch)
tree23ecb495ef85e439ea3b8b9b5b3b8277fe976085 /tools/firewire/nosy-dump.c
parent83ef7c75939f45f8da46976cdca4db0727276a2d (diff)
tools/firewire: nosy-dump: remove unused code
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'tools/firewire/nosy-dump.c')
-rw-r--r--tools/firewire/nosy-dump.c105
1 files changed, 49 insertions, 56 deletions
diff --git a/tools/firewire/nosy-dump.c b/tools/firewire/nosy-dump.c
index 5241cb402d6b..f93b776370b6 100644
--- a/tools/firewire/nosy-dump.c
+++ b/tools/firewire/nosy-dump.c
@@ -903,11 +903,12 @@ set_input_mode(void)
903 903
904int main(int argc, const char *argv[]) 904int main(int argc, const char *argv[])
905{ 905{
906 uint32_t buf[128 * 1024];
907 uint32_t filter;
908 int length, retval, view;
906 int fd = -1; 909 int fd = -1;
907 FILE *output = NULL, *input = NULL; 910 FILE *output = NULL, *input = NULL;
908 poptContext con; 911 poptContext con;
909 int retval;
910 int view;
911 char c; 912 char c;
912 struct pollfd pollfds[2]; 913 struct pollfd pollfds[2];
913 914
@@ -961,70 +962,62 @@ int main(int argc, const char *argv[])
961 962
962 setvbuf(stdout, NULL, _IOLBF, BUFSIZ); 963 setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
963 964
964 if (1) { 965 filter = ~0;
965 uint32_t buf[128 * 1024]; 966 if (!option_iso)
966 uint32_t filter; 967 filter &= ~(1 << TCODE_STREAM_DATA);
967 int length; 968 if (!option_cycle_start)
969 filter &= ~(1 << TCODE_CYCLE_START);
970 if (view == VIEW_STATS)
971 filter = ~(1 << TCODE_CYCLE_START);
968 972
969 filter = ~0; 973 ioctl(fd, NOSY_IOC_FILTER, filter);
970 if (!option_iso)
971 filter &= ~(1 << TCODE_STREAM_DATA);
972 if (!option_cycle_start)
973 filter &= ~(1 << TCODE_CYCLE_START);
974 if (view == VIEW_STATS)
975 filter = ~(1 << TCODE_CYCLE_START);
976 974
977 ioctl(fd, NOSY_IOC_FILTER, filter); 975 ioctl(fd, NOSY_IOC_START);
978 976
979 ioctl(fd, NOSY_IOC_START); 977 pollfds[0].fd = fd;
978 pollfds[0].events = POLLIN;
979 pollfds[1].fd = STDIN_FILENO;
980 pollfds[1].events = POLLIN;
980 981
981 pollfds[0].fd = fd; 982 while (run) {
982 pollfds[0].events = POLLIN; 983 if (input != NULL) {
983 pollfds[1].fd = STDIN_FILENO; 984 if (fread(&length, sizeof length, 1, input) != 1)
984 pollfds[1].events = POLLIN; 985 return 0;
985 986 fread(buf, 1, length, input);
986 while (run) { 987 } else {
987 if (input != NULL) { 988 poll(pollfds, 2, -1);
988 if (fread(&length, sizeof length, 1, input) != 1) 989 if (pollfds[1].revents) {
990 read(STDIN_FILENO, &c, sizeof c);
991 switch (c) {
992 case 'q':
993 if (output != NULL)
994 fclose(output);
989 return 0; 995 return 0;
990 fread(buf, 1, length, input);
991 } else {
992 poll(pollfds, 2, -1);
993 if (pollfds[1].revents) {
994 read(STDIN_FILENO, &c, sizeof c);
995 switch (c) {
996 case 'q':
997 if (output != NULL)
998 fclose(output);
999 return 0;
1000 }
1001 } 996 }
1002
1003 if (pollfds[0].revents)
1004 length = read(fd, buf, sizeof buf);
1005 else
1006 continue;
1007 } 997 }
1008 998
1009 if (output != NULL) { 999 if (pollfds[0].revents)
1010 fwrite(&length, sizeof length, 1, output); 1000 length = read(fd, buf, sizeof buf);
1011 fwrite(buf, 1, length, output); 1001 else
1012 } 1002 continue;
1003 }
1013 1004
1014 switch (view) { 1005 if (output != NULL) {
1015 case VIEW_TRANSACTION: 1006 fwrite(&length, sizeof length, 1, output);
1016 handle_packet(buf, length); 1007 fwrite(buf, 1, length, output);
1017 break; 1008 }
1018 case VIEW_PACKET: 1009
1019 print_packet(buf, length); 1010 switch (view) {
1020 break; 1011 case VIEW_TRANSACTION:
1021 case VIEW_STATS: 1012 handle_packet(buf, length);
1022 print_stats(buf, length); 1013 break;
1023 break; 1014 case VIEW_PACKET:
1024 } 1015 print_packet(buf, length);
1016 break;
1017 case VIEW_STATS:
1018 print_stats(buf, length);
1019 break;
1025 } 1020 }
1026 } else {
1027 poptPrintUsage(con, stdout, 0);
1028 } 1021 }
1029 1022
1030 if (output != NULL) 1023 if (output != NULL)