Commit e43ace891229607c43d35597cbba77c2e40f48d4

Authored by David Vrabel
1 parent bce83697c5

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>

Showing 3 changed files with 24 additions and 47 deletions Side-by-side Diff

drivers/usb/wusbcore/crypto.c
... ... @@ -51,13 +51,18 @@
51 51 #include <linux/uwb.h>
52 52 #include <linux/usb/wusb.h>
53 53 #include <linux/scatterlist.h>
54   -#include <linux/uwb/debug.h>
55 54  
56 55 static int debug_crypto_verify = 0;
57 56  
58 57 module_param(debug_crypto_verify, int, 0);
59 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 67 * Block of data, as understood by AES-CCM
63 68 *
64 69  
65 70  
66 71  
... ... @@ -396,14 +401,14 @@
396 401 "mismatch between MIC result and WUSB1.0[A2]\n");
397 402 hs_size = sizeof(stv_hsmic_hs) - sizeof(stv_hsmic_hs.MIC);
398 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 405 printk(KERN_ERR "E: CCM Nonce in: (%zu bytes)\n",
401 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 408 printk(KERN_ERR "E: MIC out:\n");
404   - dump_bytes(NULL, mic, sizeof(mic));
  409 + wusb_key_dump(mic, sizeof(mic));
405 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 412 result = -EINVAL;
408 413 } else
409 414 result = 0;
410 415  
411 416  
... ... @@ -471,19 +476,16 @@
471 476 printk(KERN_ERR "E: WUSB key derivation test: "
472 477 "mismatch between key derivation result "
473 478 "and WUSB1.0[A1] Errata 2006/12\n");
474   - printk(KERN_ERR "E: keydvt in: key (%zu bytes)\n",
475   - sizeof(stv_key_a1));
476   - dump_bytes(NULL, stv_key_a1, sizeof(stv_key_a1));
477   - printk(KERN_ERR "E: keydvt in: nonce (%zu bytes)\n",
478   - sizeof(stv_keydvt_n_a1));
479   - dump_bytes(NULL, &stv_keydvt_n_a1, sizeof(stv_keydvt_n_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));
  479 + printk(KERN_ERR "E: keydvt in: key\n");
  480 + wusb_key_dump(stv_key_a1, sizeof(stv_key_a1));
  481 + printk(KERN_ERR "E: keydvt in: nonce\n");
  482 + wusb_key_dump( &stv_keydvt_n_a1, sizeof(stv_keydvt_n_a1));
  483 + printk(KERN_ERR "E: keydvt in: hnonce & dnonce\n");
  484 + wusb_key_dump(&stv_keydvt_in_a1, sizeof(stv_keydvt_in_a1));
483 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 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 489 result = -EINVAL;
488 490 } else
489 491 result = 0;
drivers/usb/wusbcore/wa-nep.c
... ... @@ -51,7 +51,7 @@
51 51 */
52 52 #include <linux/workqueue.h>
53 53 #include <linux/ctype.h>
54   -#include <linux/uwb/debug.h>
  54 +
55 55 #include "wa-hc.h"
56 56 #include "wusbhc.h"
57 57  
... ... @@ -139,13 +139,10 @@
139 139 /* FIXME: unimplemented WA NOTIFs */
140 140 /* fallthru */
141 141 default:
142   - if (printk_ratelimit()) {
143   - dev_err(dev, "HWA: unknown notification 0x%x, "
144   - "%zu bytes; discarding\n",
145   - notif_hdr->bNotifyType,
146   - (size_t)notif_hdr->bLength);
147   - dump_bytes(dev, notif_hdr, 16);
148   - }
  142 + dev_err(dev, "HWA: unknown notification 0x%x, "
  143 + "%zu bytes; discarding\n",
  144 + notif_hdr->bNotifyType,
  145 + (size_t)notif_hdr->bLength);
149 146 break;
150 147 }
151 148 }
152 149  
... ... @@ -160,12 +157,9 @@
160 157 * discard the data, as this should not happen.
161 158 */
162 159 exhausted_buffer:
163   - if (!printk_ratelimit())
164   - goto out;
165 160 dev_warn(dev, "HWA: device sent short notification, "
166 161 "%d bytes missing; discarding %d bytes.\n",
167 162 missing, (int)size);
168   - dump_bytes(dev, itr, size);
169 163 goto out;
170 164 }
171 165  
drivers/uwb/uwb-debug.c
... ... @@ -4,6 +4,7 @@
4 4 *
5 5 * Copyright (C) 2005-2006 Intel Corporation
6 6 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
  7 + * Copyright (C) 2008 Cambridge Silicon Radio Ltd.
7 8 *
8 9 * This program is free software; you can redistribute it and/or
9 10 * modify it under the terms of the GNU General Public License version
... ... @@ -35,26 +36,6 @@
35 36 #include <linux/uwb/debug-cmd.h>
36 37  
37 38 #include "uwb-internal.h"
38   -
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 39  
59 40 /*
60 41 * Debug interface