Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: hisilicon - allow smaller reads in debugfs

Originally this code rejected any read less than 256 bytes. There
is no need for this artificial limit. We should just use the normal
helper functions to read a string from the kernel.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Dan Carpenter and committed by
Herbert Xu
7f94adf2 58e5b015

+6 -27
+6 -27
drivers/crypto/hisilicon/qm.c
··· 1064 1064 char buf[QM_DBG_READ_LEN]; 1065 1065 int len; 1066 1066 1067 - if (*pos) 1068 - return 0; 1067 + len = scnprintf(buf, QM_DBG_READ_LEN, "%s\n", 1068 + "Please echo help to cmd to get help information"); 1069 1069 1070 - if (count < QM_DBG_READ_LEN) 1071 - return -ENOSPC; 1072 - 1073 - len = snprintf(buf, QM_DBG_READ_LEN, "%s\n", 1074 - "Please echo help to cmd to get help information"); 1075 - 1076 - if (copy_to_user(buffer, buf, len)) 1077 - return -EFAULT; 1078 - 1079 - return (*pos = len); 1070 + return simple_read_from_buffer(buffer, count, pos, buf, len); 1080 1071 } 1081 1072 1082 1073 static void *qm_ctx_alloc(struct hisi_qm *qm, size_t ctx_size, ··· 2682 2691 { 2683 2692 struct hisi_qm *qm = filp->private_data; 2684 2693 char buf[QM_DBG_READ_LEN]; 2685 - int val, cp_len, len; 2686 - 2687 - if (*pos) 2688 - return 0; 2689 - 2690 - if (count < QM_DBG_READ_LEN) 2691 - return -ENOSPC; 2694 + int val, len; 2692 2695 2693 2696 val = atomic_read(&qm->status.flags); 2694 - len = snprintf(buf, QM_DBG_READ_LEN, "%s\n", qm_s[val]); 2695 - if (!len) 2696 - return -EFAULT; 2697 + len = scnprintf(buf, QM_DBG_READ_LEN, "%s\n", qm_s[val]); 2697 2698 2698 - cp_len = copy_to_user(buffer, buf, len); 2699 - if (cp_len) 2700 - return -EFAULT; 2701 - 2702 - return (*pos = len); 2699 + return simple_read_from_buffer(buffer, count, pos, buf, len); 2703 2700 } 2704 2701 2705 2702 static const struct file_operations qm_status_fops = {