diff options
author | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-11-23 17:11:46 -0500 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-11-23 17:11:46 -0500 |
commit | badaaa00f2122bab4bc2d46c26d6fad6af50f97c (patch) | |
tree | eacdc34eb8dfca8e0343aeb130141ca5d5941929 | |
parent | c6feeb28aed51831c27c9f42e5c15129b1562a5b (diff) |
Bluetooth: Add user readable debug for state changes
I did this as a part of a testing course at university, but it might be
useful upstream as well.
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
-rw-r--r-- | net/bluetooth/l2cap_core.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index bdbf919f981c..014fdec17113 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -229,8 +229,37 @@ static void l2cap_clear_timer(struct l2cap_chan *chan, struct timer_list *timer) | |||
229 | chan_put(chan); | 229 | chan_put(chan); |
230 | } | 230 | } |
231 | 231 | ||
232 | static char *state_to_string(int state) | ||
233 | { | ||
234 | switch(state) { | ||
235 | case BT_CONNECTED: | ||
236 | return "BT_CONNECTED"; | ||
237 | case BT_OPEN: | ||
238 | return "BT_OPEN"; | ||
239 | case BT_BOUND: | ||
240 | return "BT_BOUND"; | ||
241 | case BT_LISTEN: | ||
242 | return "BT_LISTEN"; | ||
243 | case BT_CONNECT: | ||
244 | return "BT_CONNECT"; | ||
245 | case BT_CONNECT2: | ||
246 | return "BT_CONNECT2"; | ||
247 | case BT_CONFIG: | ||
248 | return "BT_CONFIG"; | ||
249 | case BT_DISCONN: | ||
250 | return "BT_DISCONN"; | ||
251 | case BT_CLOSED: | ||
252 | return "BT_CLOSED"; | ||
253 | } | ||
254 | |||
255 | return "invalid state"; | ||
256 | } | ||
257 | |||
232 | static void l2cap_state_change(struct l2cap_chan *chan, int state) | 258 | static void l2cap_state_change(struct l2cap_chan *chan, int state) |
233 | { | 259 | { |
260 | BT_DBG("%p %s -> %s", chan, state_to_string(chan->state), | ||
261 | state_to_string(state)); | ||
262 | |||
234 | chan->state = state; | 263 | chan->state = state; |
235 | chan->ops->state_change(chan->data, state); | 264 | chan->ops->state_change(chan->data, state); |
236 | } | 265 | } |