提交 db5e79ef 编写于 作者: Y youshengzui 提交者: Yang Yingliang

net: hns3: Rectification of driver code review

driver inclusion
category: bugfix
bugzilla: NA
CVE: NA

-----------------------------

This patch is used to fix the Plastic overflow error,
and remove redundant code
Signed-off-by: Nyoushengzui <youshengzui@huawei.com>
Reviewed-by: NWeiwei Deng <dengweiwei@huawei.com>
Reviewed-by: NZhaohui Zhong <zhongzhaohui@huawei.com>
Reviewed-by: NJunxin Chen <chenjunxin1@huawei.com>
Reviewed-by: NZhong Zhaohui <zhongzhaohui@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 7ac2b7a9
......@@ -386,37 +386,14 @@ static int hns3_cae_k_open(struct inode *pnode, struct file *pfile)
static ssize_t hns3_cae_k_read(struct file *pfile, char __user *ubuf,
size_t size, loff_t *ppos)
{
pr_info("%s read *ppos:%lld size = %d\n", __func__, *ppos, (int)size);
pr_info("%s read *ppos:%lld size = %lu\n", __func__, *ppos, size);
return 0;
}
static ssize_t hns3_cae_k_write(struct file *pfile, const char __user *ubuf,
size_t size, loff_t *ppos)
{
pr_info("%s write *ppos:%lld size = %d\n", __func__, *ppos, (int)size);
return 0;
}
static int hns3_cae_k_mmap(struct file *filp, struct vm_area_struct *vma)
{
phys_addr_t offset = (phys_addr_t)vma->vm_pgoff << PAGE_SHIFT;
size_t size = vma->vm_end - vma->vm_start;
int ret;
vma->vm_flags |= VM_IO;
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
if (offset + (phys_addr_t)size - 1 < offset)
return -EINVAL;
if (offset >> PAGE_SHIFT != vma->vm_pgoff)
return -EINVAL;
ret = remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
size, vma->vm_page_prot);
if (ret)
return -EIO;
pr_info("%s write *ppos:%lld size = %lu\n", __func__, *ppos, size);
return 0;
}
......@@ -426,7 +403,6 @@ static const struct file_operations fifo_operations = {
.read = hns3_cae_k_read,
.write = hns3_cae_k_write,
.unlocked_ioctl = hns3_cae_k_unlocked_ioctl,
.mmap = hns3_cae_k_mmap,
};
static int if_hns3_cae_exist(void)
......
......@@ -26,10 +26,9 @@ int hns3_read_promisc_mode_cfg(const struct hns3_nic_priv *nic_dev,
vport = hns3_cae_get_vport(nic_dev->ae_handle);
hdev = vport->back;
req = (struct hclge_promisc_cfg_cmd *)desc.data;
req->vf_id = vport->vport_id;
hns3_cae_cmd_setup_basic_desc(&desc, HCLGE_OPC_CFG_PROMISC_MODE, true);
req->vf_id = vport->vport_id;
ret = hns3_cae_cmd_send(hdev, &desc, 1);
req = (struct hclge_promisc_cfg_cmd *)desc.data;
if (ret) {
dev_err(&hdev->pdev->dev,
"Get promisc mode fail, ret is %d.\n", ret);
......@@ -62,11 +61,10 @@ int hns3_set_promisc_mode_cfg(const struct hns3_nic_priv *nic_dev,
vport = hns3_cae_get_vport(nic_dev->ae_handle);
hdev = vport->back;
req = (struct hclge_promisc_cfg_cmd *)desc.data;
req->vf_id = vport->vport_id;
mode_param = (struct promisc_mode_param *)buf_in;
hns3_cae_cmd_setup_basic_desc(&desc, HCLGE_OPC_CFG_PROMISC_MODE, true);
req->vf_id = vport->vport_id;
ret = hns3_cae_cmd_send(hdev, &desc, 1);
req = (struct hclge_promisc_cfg_cmd *)desc.data;
if (ret) {
dev_err(&hdev->pdev->dev,
"Get promisc mode fail, ret is %d.\n", ret);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册