RDMA/hns: Fix non-standard error codes

It is better to return a linux error code than define a private constant.

Link: https://lore.kernel.org/r/1572952082-6681-9-git-send-email-liweihang@hisilicon.com
Signed-off-by: Yixian Liu <liuyixian@huawei.com>
Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com>
Signed-off-by: Weihang Li <liweihang@hisilicon.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:
Yixian Liu 2019-11-05 19:08:01 +08:00 committed by Jason Gunthorpe
parent 301cc7eb2c
commit 1ceb0b11a8
5 changed files with 14 additions and 13 deletions

View File

@ -55,7 +55,7 @@ int hns_roce_bitmap_alloc(struct hns_roce_bitmap *bitmap, unsigned long *obj)
bitmap->last = 0; bitmap->last = 0;
*obj |= bitmap->top; *obj |= bitmap->top;
} else { } else {
ret = -1; ret = -EINVAL;
} }
spin_unlock(&bitmap->lock); spin_unlock(&bitmap->lock);
@ -100,7 +100,7 @@ int hns_roce_bitmap_alloc_range(struct hns_roce_bitmap *bitmap, int cnt,
} }
*obj |= bitmap->top; *obj |= bitmap->top;
} else { } else {
ret = -1; ret = -EINVAL;
} }
spin_unlock(&bitmap->lock); spin_unlock(&bitmap->lock);

View File

@ -116,9 +116,9 @@ static int hns_roce_cq_alloc(struct hns_roce_dev *hr_dev, int nent,
hr_cq->vector = vector; hr_cq->vector = vector;
ret = hns_roce_bitmap_alloc(&cq_table->bitmap, &hr_cq->cqn); ret = hns_roce_bitmap_alloc(&cq_table->bitmap, &hr_cq->cqn);
if (ret == -1) { if (ret) {
dev_err(dev, "CQ alloc.Failed to alloc index.\n"); dev_err(dev, "CQ alloc.Failed to alloc index.\n");
return -ENOMEM; return ret;
} }
/* Get CQC memory HEM(Hardware Entry Memory) table */ /* Get CQC memory HEM(Hardware Entry Memory) table */

View File

@ -83,7 +83,7 @@ static int hns_roce_buddy_alloc(struct hns_roce_buddy *buddy, int order,
} }
} }
spin_unlock(&buddy->lock); spin_unlock(&buddy->lock);
return -1; return -EINVAL;
found: found:
clear_bit(*seg, buddy->bits[o]); clear_bit(*seg, buddy->bits[o]);
@ -206,13 +206,14 @@ static int hns_roce_alloc_mtt_range(struct hns_roce_dev *hr_dev, int order,
} }
ret = hns_roce_buddy_alloc(buddy, order, seg); ret = hns_roce_buddy_alloc(buddy, order, seg);
if (ret == -1) if (ret)
return -1; return ret;
if (hns_roce_table_get_range(hr_dev, table, *seg, ret = hns_roce_table_get_range(hr_dev, table, *seg,
*seg + (1 << order) - 1)) { *seg + (1 << order) - 1);
if (ret) {
hns_roce_buddy_free(buddy, *seg, order); hns_roce_buddy_free(buddy, *seg, order);
return -1; return ret;
} }
return 0; return 0;
@ -578,7 +579,7 @@ static int hns_roce_mr_alloc(struct hns_roce_dev *hr_dev, u32 pd, u64 iova,
/* Allocate a key for mr from mr_table */ /* Allocate a key for mr from mr_table */
ret = hns_roce_bitmap_alloc(&hr_dev->mr_table.mtpt_bitmap, &index); ret = hns_roce_bitmap_alloc(&hr_dev->mr_table.mtpt_bitmap, &index);
if (ret == -1) if (ret)
return -ENOMEM; return -ENOMEM;
mr->iova = iova; /* MR va starting addr */ mr->iova = iova; /* MR va starting addr */

View File

@ -96,7 +96,7 @@ int hns_roce_uar_alloc(struct hns_roce_dev *hr_dev, struct hns_roce_uar *uar)
/* Using bitmap to manager UAR index */ /* Using bitmap to manager UAR index */
ret = hns_roce_bitmap_alloc(&hr_dev->uar_table.bitmap, &uar->logic_idx); ret = hns_roce_bitmap_alloc(&hr_dev->uar_table.bitmap, &uar->logic_idx);
if (ret == -1) if (ret)
return -ENOMEM; return -ENOMEM;
if (uar->logic_idx > 0 && hr_dev->caps.phy_num_uars > 1) if (uar->logic_idx > 0 && hr_dev->caps.phy_num_uars > 1)

View File

@ -111,7 +111,7 @@ static int hns_roce_srq_alloc(struct hns_roce_dev *hr_dev, u32 pdn, u32 cqn,
} }
ret = hns_roce_bitmap_alloc(&srq_table->bitmap, &srq->srqn); ret = hns_roce_bitmap_alloc(&srq_table->bitmap, &srq->srqn);
if (ret == -1) { if (ret) {
dev_err(hr_dev->dev, "SRQ alloc.Failed to alloc index.\n"); dev_err(hr_dev->dev, "SRQ alloc.Failed to alloc index.\n");
return -ENOMEM; return -ENOMEM;
} }