Commit 7f94adf2 authored by Dan Carpenter's avatar Dan Carpenter Committed by Herbert Xu

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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 58e5b015
...@@ -1064,19 +1064,10 @@ static ssize_t qm_cmd_read(struct file *filp, char __user *buffer, ...@@ -1064,19 +1064,10 @@ static ssize_t qm_cmd_read(struct file *filp, char __user *buffer,
char buf[QM_DBG_READ_LEN]; char buf[QM_DBG_READ_LEN];
int len; int len;
if (*pos) len = scnprintf(buf, QM_DBG_READ_LEN, "%s\n",
return 0; "Please echo help to cmd to get help information");
if (count < QM_DBG_READ_LEN)
return -ENOSPC;
len = snprintf(buf, QM_DBG_READ_LEN, "%s\n", return simple_read_from_buffer(buffer, count, pos, buf, len);
"Please echo help to cmd to get help information");
if (copy_to_user(buffer, buf, len))
return -EFAULT;
return (*pos = len);
} }
static void *qm_ctx_alloc(struct hisi_qm *qm, size_t ctx_size, static void *qm_ctx_alloc(struct hisi_qm *qm, size_t ctx_size,
...@@ -2691,24 +2682,12 @@ static ssize_t qm_status_read(struct file *filp, char __user *buffer, ...@@ -2691,24 +2682,12 @@ static ssize_t qm_status_read(struct file *filp, char __user *buffer,
{ {
struct hisi_qm *qm = filp->private_data; struct hisi_qm *qm = filp->private_data;
char buf[QM_DBG_READ_LEN]; char buf[QM_DBG_READ_LEN];
int val, cp_len, len; int val, len;
if (*pos)
return 0;
if (count < QM_DBG_READ_LEN)
return -ENOSPC;
val = atomic_read(&qm->status.flags); val = atomic_read(&qm->status.flags);
len = snprintf(buf, QM_DBG_READ_LEN, "%s\n", qm_s[val]); len = scnprintf(buf, QM_DBG_READ_LEN, "%s\n", qm_s[val]);
if (!len)
return -EFAULT;
cp_len = copy_to_user(buffer, buf, len);
if (cp_len)
return -EFAULT;
return (*pos = len); return simple_read_from_buffer(buffer, count, pos, buf, len);
} }
static const struct file_operations qm_status_fops = { static const struct file_operations qm_status_fops = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment