[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1595229523-14103-1-git-send-email-yekai13@huawei.com>
Date: Mon, 20 Jul 2020 15:18:43 +0800
From: Kai Ye <yekai13@...wei.com>
To: <linux-accelerators@...ts.ozlabs.org>,
<linux-kernel@...r.kernel.org>, <linuxarm@...wei.com>,
<zhangfei.gao@...aro.org>
CC: Kai Ye <yekai13@...wei.com>
Subject: [PATCH] uacce: fix some coding styles
1. add some parameter check.
2. delete some redundant code.
3. modify the module author information.
Signed-off-by: Kai Ye <yekai13@...wei.com>
Reviewed-by: Zhou Wang <wangzhou1@...ilicon.com>
---
drivers/misc/uacce/uacce.c | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/drivers/misc/uacce/uacce.c b/drivers/misc/uacce/uacce.c
index 107028e..2e1af58 100644
--- a/drivers/misc/uacce/uacce.c
+++ b/drivers/misc/uacce/uacce.c
@@ -63,8 +63,12 @@ static long uacce_fops_unl_ioctl(struct file *filep,
unsigned int cmd, unsigned long arg)
{
struct uacce_queue *q = filep->private_data;
- struct uacce_device *uacce = q->uacce;
+ struct uacce_device *uacce;
+
+ if (WARN_ON(!q))
+ return -EINVAL;
+ uacce = q->uacce;
switch (cmd) {
case UACCE_CMD_START_Q:
return uacce_start_queue(q);
@@ -206,11 +210,16 @@ static const struct vm_operations_struct uacce_vm_ops = {
static int uacce_fops_mmap(struct file *filep, struct vm_area_struct *vma)
{
struct uacce_queue *q = filep->private_data;
- struct uacce_device *uacce = q->uacce;
- struct uacce_qfile_region *qfr;
enum uacce_qfrt type = UACCE_MAX_REGION;
+ struct uacce_qfile_region *qfr;
+ struct uacce_device *uacce;
int ret = 0;
+ if (WARN_ON(!q))
+ return -EINVAL;
+
+ uacce = q->uacce;
+
if (vma->vm_pgoff < UACCE_MAX_REGION)
type = vma->vm_pgoff;
else
@@ -239,17 +248,6 @@ static int uacce_fops_mmap(struct file *filep, struct vm_area_struct *vma)
switch (type) {
case UACCE_QFRT_MMIO:
- if (!uacce->ops->mmap) {
- ret = -EINVAL;
- goto out_with_lock;
- }
-
- ret = uacce->ops->mmap(q, vma, qfr);
- if (ret)
- goto out_with_lock;
-
- break;
-
case UACCE_QFRT_DUS:
if (!uacce->ops->mmap) {
ret = -EINVAL;
@@ -541,5 +539,5 @@ subsys_initcall(uacce_init);
module_exit(uacce_exit);
MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Hisilicon Tech. Co., Ltd.");
+MODULE_AUTHOR("HiSilicon Tech. Co., Ltd.");
MODULE_DESCRIPTION("Accelerator interface for Userland applications");
--
2.8.1
Powered by blists - more mailing lists