diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2015-04-01 15:52:13 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2015-04-02 01:47:40 -0400 |
commit | 64dd374eac154f747623b256c59ecaf5affba724 (patch) | |
tree | fda701a6de51eaf59f5433d85173bb0543cbc40c | |
parent | 6de50f9fdb60a8d4c1cd94556106200ab1592e2d (diff) |
Bluetooth: Export SMP selftest result in debugfs
When SMP selftest is enabled, then besides printing the result into the
kernel message buffer, also create a debugfs file that allows retrieving
the same information.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r-- | net/bluetooth/smp.c | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 1910c5806974..1ab3dc9c8f99 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
@@ -3549,6 +3549,21 @@ static int __init test_h6(struct crypto_hash *tfm_cmac) | |||
3549 | return 0; | 3549 | return 0; |
3550 | } | 3550 | } |
3551 | 3551 | ||
3552 | static char test_smp_buffer[32]; | ||
3553 | |||
3554 | static ssize_t test_smp_read(struct file *file, char __user *user_buf, | ||
3555 | size_t count, loff_t *ppos) | ||
3556 | { | ||
3557 | return simple_read_from_buffer(user_buf, count, ppos, test_smp_buffer, | ||
3558 | strlen(test_smp_buffer)); | ||
3559 | } | ||
3560 | |||
3561 | static const struct file_operations test_smp_fops = { | ||
3562 | .open = simple_open, | ||
3563 | .read = test_smp_read, | ||
3564 | .llseek = default_llseek, | ||
3565 | }; | ||
3566 | |||
3552 | static int __init run_selftests(struct crypto_blkcipher *tfm_aes, | 3567 | static int __init run_selftests(struct crypto_blkcipher *tfm_aes, |
3553 | struct crypto_hash *tfm_cmac) | 3568 | struct crypto_hash *tfm_cmac) |
3554 | { | 3569 | { |
@@ -3561,49 +3576,49 @@ static int __init run_selftests(struct crypto_blkcipher *tfm_aes, | |||
3561 | err = test_ah(tfm_aes); | 3576 | err = test_ah(tfm_aes); |
3562 | if (err) { | 3577 | if (err) { |
3563 | BT_ERR("smp_ah test failed"); | 3578 | BT_ERR("smp_ah test failed"); |
3564 | return err; | 3579 | goto done; |
3565 | } | 3580 | } |
3566 | 3581 | ||
3567 | err = test_c1(tfm_aes); | 3582 | err = test_c1(tfm_aes); |
3568 | if (err) { | 3583 | if (err) { |
3569 | BT_ERR("smp_c1 test failed"); | 3584 | BT_ERR("smp_c1 test failed"); |
3570 | return err; | 3585 | goto done; |
3571 | } | 3586 | } |
3572 | 3587 | ||
3573 | err = test_s1(tfm_aes); | 3588 | err = test_s1(tfm_aes); |
3574 | if (err) { | 3589 | if (err) { |
3575 | BT_ERR("smp_s1 test failed"); | 3590 | BT_ERR("smp_s1 test failed"); |
3576 | return err; | 3591 | goto done; |
3577 | } | 3592 | } |
3578 | 3593 | ||
3579 | err = test_f4(tfm_cmac); | 3594 | err = test_f4(tfm_cmac); |
3580 | if (err) { | 3595 | if (err) { |
3581 | BT_ERR("smp_f4 test failed"); | 3596 | BT_ERR("smp_f4 test failed"); |
3582 | return err; | 3597 | goto done; |
3583 | } | 3598 | } |
3584 | 3599 | ||
3585 | err = test_f5(tfm_cmac); | 3600 | err = test_f5(tfm_cmac); |
3586 | if (err) { | 3601 | if (err) { |
3587 | BT_ERR("smp_f5 test failed"); | 3602 | BT_ERR("smp_f5 test failed"); |
3588 | return err; | 3603 | goto done; |
3589 | } | 3604 | } |
3590 | 3605 | ||
3591 | err = test_f6(tfm_cmac); | 3606 | err = test_f6(tfm_cmac); |
3592 | if (err) { | 3607 | if (err) { |
3593 | BT_ERR("smp_f6 test failed"); | 3608 | BT_ERR("smp_f6 test failed"); |
3594 | return err; | 3609 | goto done; |
3595 | } | 3610 | } |
3596 | 3611 | ||
3597 | err = test_g2(tfm_cmac); | 3612 | err = test_g2(tfm_cmac); |
3598 | if (err) { | 3613 | if (err) { |
3599 | BT_ERR("smp_g2 test failed"); | 3614 | BT_ERR("smp_g2 test failed"); |
3600 | return err; | 3615 | goto done; |
3601 | } | 3616 | } |
3602 | 3617 | ||
3603 | err = test_h6(tfm_cmac); | 3618 | err = test_h6(tfm_cmac); |
3604 | if (err) { | 3619 | if (err) { |
3605 | BT_ERR("smp_h6 test failed"); | 3620 | BT_ERR("smp_h6 test failed"); |
3606 | return err; | 3621 | goto done; |
3607 | } | 3622 | } |
3608 | 3623 | ||
3609 | rettime = ktime_get(); | 3624 | rettime = ktime_get(); |
@@ -3612,7 +3627,17 @@ static int __init run_selftests(struct crypto_blkcipher *tfm_aes, | |||
3612 | 3627 | ||
3613 | BT_INFO("SMP test passed in %llu usecs", duration); | 3628 | BT_INFO("SMP test passed in %llu usecs", duration); |
3614 | 3629 | ||
3615 | return 0; | 3630 | done: |
3631 | if (!err) | ||
3632 | snprintf(test_smp_buffer, sizeof(test_smp_buffer), | ||
3633 | "PASS (%llu usecs)\n", duration); | ||
3634 | else | ||
3635 | snprintf(test_smp_buffer, sizeof(test_smp_buffer), "FAIL\n"); | ||
3636 | |||
3637 | debugfs_create_file("selftest_smp", 0444, bt_debugfs, NULL, | ||
3638 | &test_smp_fops); | ||
3639 | |||
3640 | return err; | ||
3616 | } | 3641 | } |
3617 | 3642 | ||
3618 | int __init bt_selftest_smp(void) | 3643 | int __init bt_selftest_smp(void) |