treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / tools / lib / traceevent / plugins / plugin_mac80211.c
blob884303c26b5cd1b7318fedfbb56221df0dacd8a3
1 /*
2 * Copyright (C) 2009 Johannes Berg <johannes@sipsolutions.net>
4 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation;
8 * version 2.1 of the License (not later!)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, see <http://www.gnu.org/licenses>
18 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
24 #include "event-parse.h"
25 #include "trace-seq.h"
27 #define INDENT 65
29 static void print_string(struct trace_seq *s, struct tep_event *event,
30 const char *name, const void *data)
32 struct tep_format_field *f = tep_find_field(event, name);
33 int offset;
34 int length;
36 if (!f) {
37 trace_seq_printf(s, "NOTFOUND:%s", name);
38 return;
41 offset = f->offset;
42 length = f->size;
44 if (!strncmp(f->type, "__data_loc", 10)) {
45 unsigned long long v;
46 if (tep_read_number_field(f, data, &v)) {
47 trace_seq_printf(s, "invalid_data_loc");
48 return;
50 offset = v & 0xffff;
51 length = v >> 16;
54 trace_seq_printf(s, "%.*s", length, (char *)data + offset);
57 #define SF(fn) tep_print_num_field(s, fn ":%d", event, fn, record, 0)
58 #define SFX(fn) tep_print_num_field(s, fn ":%#x", event, fn, record, 0)
59 #define SP() trace_seq_putc(s, ' ')
61 static int drv_bss_info_changed(struct trace_seq *s,
62 struct tep_record *record,
63 struct tep_event *event, void *context)
65 void *data = record->data;
67 print_string(s, event, "wiphy_name", data);
68 trace_seq_printf(s, " vif:");
69 print_string(s, event, "vif_name", data);
70 tep_print_num_field(s, "(%d)", event, "vif_type", record, 1);
72 trace_seq_printf(s, "\n%*s", INDENT, "");
73 SF("assoc"); SP();
74 SF("aid"); SP();
75 SF("cts"); SP();
76 SF("shortpre"); SP();
77 SF("shortslot"); SP();
78 SF("dtimper"); SP();
79 trace_seq_printf(s, "\n%*s", INDENT, "");
80 SF("bcnint"); SP();
81 SFX("assoc_cap"); SP();
82 SFX("basic_rates"); SP();
83 SF("enable_beacon");
84 trace_seq_printf(s, "\n%*s", INDENT, "");
85 SF("ht_operation_mode");
87 return 0;
90 int TEP_PLUGIN_LOADER(struct tep_handle *tep)
92 tep_register_event_handler(tep, -1, "mac80211",
93 "drv_bss_info_changed",
94 drv_bss_info_changed, NULL);
95 return 0;
98 void TEP_PLUGIN_UNLOADER(struct tep_handle *tep)
100 tep_unregister_event_handler(tep, -1, "mac80211",
101 "drv_bss_info_changed",
102 drv_bss_info_changed, NULL);