diff options
author | David Vrabel <david.vrabel@csr.com> | 2008-12-22 13:27:17 -0500 |
---|---|---|
committer | David Vrabel <david.vrabel@csr.com> | 2008-12-22 13:27:17 -0500 |
commit | e43ace891229607c43d35597cbba77c2e40f48d4 (patch) | |
tree | ce5fb73947a1d7fb5a6bbb8ac9d82f3e20c6a316 | |
parent | bce83697c5fe84a7a5d38c96fbbe43b4bc028c3e (diff) |
uwb: use print_hex_dump()
Use print_hex_dump() instead of the home-grown dump_bytes().
Signed-off-by: David Vrabel <david.vrabel@csr.com>
-rw-r--r-- | drivers/usb/wusbcore/crypto.c | 34 | ||||
-rw-r--r-- | drivers/usb/wusbcore/wa-nep.c | 16 | ||||
-rw-r--r-- | drivers/uwb/uwb-debug.c | 21 |
3 files changed, 24 insertions, 47 deletions
diff --git a/drivers/usb/wusbcore/crypto.c b/drivers/usb/wusbcore/crypto.c index 9d9128ac8c8e..9ec7fd5da489 100644 --- a/drivers/usb/wusbcore/crypto.c +++ b/drivers/usb/wusbcore/crypto.c | |||
@@ -51,13 +51,18 @@ | |||
51 | #include <linux/uwb.h> | 51 | #include <linux/uwb.h> |
52 | #include <linux/usb/wusb.h> | 52 | #include <linux/usb/wusb.h> |
53 | #include <linux/scatterlist.h> | 53 | #include <linux/scatterlist.h> |
54 | #include <linux/uwb/debug.h> | ||
55 | 54 | ||
56 | static int debug_crypto_verify = 0; | 55 | static int debug_crypto_verify = 0; |
57 | 56 | ||
58 | module_param(debug_crypto_verify, int, 0); | 57 | module_param(debug_crypto_verify, int, 0); |
59 | MODULE_PARM_DESC(debug_crypto_verify, "verify the key generation algorithms"); | 58 | MODULE_PARM_DESC(debug_crypto_verify, "verify the key generation algorithms"); |
60 | 59 | ||
60 | static void wusb_key_dump(const void *buf, size_t len) | ||
61 | { | ||
62 | print_hex_dump(KERN_ERR, " ", DUMP_PREFIX_OFFSET, 16, 1, | ||
63 | buf, len, 0); | ||
64 | } | ||
65 | |||
61 | /* | 66 | /* |
62 | * Block of data, as understood by AES-CCM | 67 | * Block of data, as understood by AES-CCM |
63 | * | 68 | * |
@@ -396,14 +401,14 @@ static int wusb_oob_mic_verify(void) | |||
396 | "mismatch between MIC result and WUSB1.0[A2]\n"); | 401 | "mismatch between MIC result and WUSB1.0[A2]\n"); |
397 | hs_size = sizeof(stv_hsmic_hs) - sizeof(stv_hsmic_hs.MIC); | 402 | hs_size = sizeof(stv_hsmic_hs) - sizeof(stv_hsmic_hs.MIC); |
398 | printk(KERN_ERR "E: Handshake2 in: (%zu bytes)\n", hs_size); | 403 | printk(KERN_ERR "E: Handshake2 in: (%zu bytes)\n", hs_size); |
399 | dump_bytes(NULL, &stv_hsmic_hs, hs_size); | 404 | wusb_key_dump(&stv_hsmic_hs, hs_size); |
400 | printk(KERN_ERR "E: CCM Nonce in: (%zu bytes)\n", | 405 | printk(KERN_ERR "E: CCM Nonce in: (%zu bytes)\n", |
401 | sizeof(stv_hsmic_n)); | 406 | sizeof(stv_hsmic_n)); |
402 | dump_bytes(NULL, &stv_hsmic_n, sizeof(stv_hsmic_n)); | 407 | wusb_key_dump(&stv_hsmic_n, sizeof(stv_hsmic_n)); |
403 | printk(KERN_ERR "E: MIC out:\n"); | 408 | printk(KERN_ERR "E: MIC out:\n"); |
404 | dump_bytes(NULL, mic, sizeof(mic)); | 409 | wusb_key_dump(mic, sizeof(mic)); |
405 | printk(KERN_ERR "E: MIC out (from WUSB1.0[A.2]):\n"); | 410 | printk(KERN_ERR "E: MIC out (from WUSB1.0[A.2]):\n"); |
406 | dump_bytes(NULL, stv_hsmic_hs.MIC, sizeof(stv_hsmic_hs.MIC)); | 411 | wusb_key_dump(stv_hsmic_hs.MIC, sizeof(stv_hsmic_hs.MIC)); |
407 | result = -EINVAL; | 412 | result = -EINVAL; |
408 | } else | 413 | } else |
409 | result = 0; | 414 | result = 0; |
@@ -471,19 +476,16 @@ static int wusb_key_derive_verify(void) | |||
471 | printk(KERN_ERR "E: WUSB key derivation test: " | 476 | printk(KERN_ERR "E: WUSB key derivation test: " |
472 | "mismatch between key derivation result " | 477 | "mismatch between key derivation result " |
473 | "and WUSB1.0[A1] Errata 2006/12\n"); | 478 | "and WUSB1.0[A1] Errata 2006/12\n"); |
474 | printk(KERN_ERR "E: keydvt in: key (%zu bytes)\n", | 479 | printk(KERN_ERR "E: keydvt in: key\n"); |
475 | sizeof(stv_key_a1)); | 480 | wusb_key_dump(stv_key_a1, sizeof(stv_key_a1)); |
476 | dump_bytes(NULL, stv_key_a1, sizeof(stv_key_a1)); | 481 | printk(KERN_ERR "E: keydvt in: nonce\n"); |
477 | printk(KERN_ERR "E: keydvt in: nonce (%zu bytes)\n", | 482 | wusb_key_dump( &stv_keydvt_n_a1, sizeof(stv_keydvt_n_a1)); |
478 | sizeof(stv_keydvt_n_a1)); | 483 | printk(KERN_ERR "E: keydvt in: hnonce & dnonce\n"); |
479 | dump_bytes(NULL, &stv_keydvt_n_a1, sizeof(stv_keydvt_n_a1)); | 484 | wusb_key_dump(&stv_keydvt_in_a1, sizeof(stv_keydvt_in_a1)); |
480 | printk(KERN_ERR "E: keydvt in: hnonce & dnonce (%zu bytes)\n", | ||
481 | sizeof(stv_keydvt_in_a1)); | ||
482 | dump_bytes(NULL, &stv_keydvt_in_a1, sizeof(stv_keydvt_in_a1)); | ||
483 | printk(KERN_ERR "E: keydvt out: KCK\n"); | 485 | printk(KERN_ERR "E: keydvt out: KCK\n"); |
484 | dump_bytes(NULL, &keydvt_out.kck, sizeof(keydvt_out.kck)); | 486 | wusb_key_dump(&keydvt_out.kck, sizeof(keydvt_out.kck)); |
485 | printk(KERN_ERR "E: keydvt out: PTK\n"); | 487 | printk(KERN_ERR "E: keydvt out: PTK\n"); |
486 | dump_bytes(NULL, &keydvt_out.ptk, sizeof(keydvt_out.ptk)); | 488 | wusb_key_dump(&keydvt_out.ptk, sizeof(keydvt_out.ptk)); |
487 | result = -EINVAL; | 489 | result = -EINVAL; |
488 | } else | 490 | } else |
489 | result = 0; | 491 | result = 0; |
diff --git a/drivers/usb/wusbcore/wa-nep.c b/drivers/usb/wusbcore/wa-nep.c index 3f542990c73f..17d2626038be 100644 --- a/drivers/usb/wusbcore/wa-nep.c +++ b/drivers/usb/wusbcore/wa-nep.c | |||
@@ -51,7 +51,7 @@ | |||
51 | */ | 51 | */ |
52 | #include <linux/workqueue.h> | 52 | #include <linux/workqueue.h> |
53 | #include <linux/ctype.h> | 53 | #include <linux/ctype.h> |
54 | #include <linux/uwb/debug.h> | 54 | |
55 | #include "wa-hc.h" | 55 | #include "wa-hc.h" |
56 | #include "wusbhc.h" | 56 | #include "wusbhc.h" |
57 | 57 | ||
@@ -139,13 +139,10 @@ static void wa_notif_dispatch(struct work_struct *ws) | |||
139 | /* FIXME: unimplemented WA NOTIFs */ | 139 | /* FIXME: unimplemented WA NOTIFs */ |
140 | /* fallthru */ | 140 | /* fallthru */ |
141 | default: | 141 | default: |
142 | if (printk_ratelimit()) { | 142 | dev_err(dev, "HWA: unknown notification 0x%x, " |
143 | dev_err(dev, "HWA: unknown notification 0x%x, " | 143 | "%zu bytes; discarding\n", |
144 | "%zu bytes; discarding\n", | 144 | notif_hdr->bNotifyType, |
145 | notif_hdr->bNotifyType, | 145 | (size_t)notif_hdr->bLength); |
146 | (size_t)notif_hdr->bLength); | ||
147 | dump_bytes(dev, notif_hdr, 16); | ||
148 | } | ||
149 | break; | 146 | break; |
150 | } | 147 | } |
151 | } | 148 | } |
@@ -160,12 +157,9 @@ out: | |||
160 | * discard the data, as this should not happen. | 157 | * discard the data, as this should not happen. |
161 | */ | 158 | */ |
162 | exhausted_buffer: | 159 | exhausted_buffer: |
163 | if (!printk_ratelimit()) | ||
164 | goto out; | ||
165 | dev_warn(dev, "HWA: device sent short notification, " | 160 | dev_warn(dev, "HWA: device sent short notification, " |
166 | "%d bytes missing; discarding %d bytes.\n", | 161 | "%d bytes missing; discarding %d bytes.\n", |
167 | missing, (int)size); | 162 | missing, (int)size); |
168 | dump_bytes(dev, itr, size); | ||
169 | goto out; | 163 | goto out; |
170 | } | 164 | } |
171 | 165 | ||
diff --git a/drivers/uwb/uwb-debug.c b/drivers/uwb/uwb-debug.c index 89b2e6a7214c..4a42993700c1 100644 --- a/drivers/uwb/uwb-debug.c +++ b/drivers/uwb/uwb-debug.c | |||
@@ -4,6 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (C) 2005-2006 Intel Corporation | 5 | * Copyright (C) 2005-2006 Intel Corporation |
6 | * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> | 6 | * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> |
7 | * Copyright (C) 2008 Cambridge Silicon Radio Ltd. | ||
7 | * | 8 | * |
8 | * This program is free software; you can redistribute it and/or | 9 | * This program is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU General Public License version | 10 | * modify it under the terms of the GNU General Public License version |
@@ -36,26 +37,6 @@ | |||
36 | 37 | ||
37 | #include "uwb-internal.h" | 38 | #include "uwb-internal.h" |
38 | 39 | ||
39 | void dump_bytes(struct device *dev, const void *_buf, size_t rsize) | ||
40 | { | ||
41 | const char *buf = _buf; | ||
42 | char line[32]; | ||
43 | size_t offset = 0; | ||
44 | int cnt, cnt2; | ||
45 | for (cnt = 0; cnt < rsize; cnt += 8) { | ||
46 | size_t rtop = rsize - cnt < 8 ? rsize - cnt : 8; | ||
47 | for (offset = cnt2 = 0; cnt2 < rtop; cnt2++) { | ||
48 | offset += scnprintf(line + offset, sizeof(line) - offset, | ||
49 | "%02x ", buf[cnt + cnt2] & 0xff); | ||
50 | } | ||
51 | if (dev) | ||
52 | dev_info(dev, "%s\n", line); | ||
53 | else | ||
54 | printk(KERN_INFO "%s\n", line); | ||
55 | } | ||
56 | } | ||
57 | EXPORT_SYMBOL_GPL(dump_bytes); | ||
58 | |||
59 | /* | 40 | /* |
60 | * Debug interface | 41 | * Debug interface |
61 | * | 42 | * |