diff options
author | Lijun Ou <oulijun@huawei.com> | 2019-05-24 23:29:36 +0800 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2019-05-27 17:31:00 -0300 |
commit | 2a3d923f87303b2d49c6cfb7bf6a25144a1ce265 (patch) | |
tree | afc0ba5f4bd8b816ffbfdea640b941bd88aa2980 /drivers/infiniband/hw/hns/hns_roce_db.c | |
parent | 669cefb654cb69b280e31380f5fc7e3b5755b0cd (diff) | |
download | linux-stable-2a3d923f87303b2d49c6cfb7bf6a25144a1ce265.tar.gz linux-stable-2a3d923f87303b2d49c6cfb7bf6a25144a1ce265.tar.bz2 linux-stable-2a3d923f87303b2d49c6cfb7bf6a25144a1ce265.zip |
RDMA/hns: Replace magic numbers with #defines
This patch makes the code more readable by removing magic numbers.
Signed-off-by: Xi Wang <wangxi11@huawei.com>
Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/infiniband/hw/hns/hns_roce_db.c')
-rw-r--r-- | drivers/infiniband/hw/hns/hns_roce_db.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/infiniband/hw/hns/hns_roce_db.c b/drivers/infiniband/hw/hns/hns_roce_db.c index 0c6c1fe87705..3a040a9390d8 100644 --- a/drivers/infiniband/hw/hns/hns_roce_db.c +++ b/drivers/infiniband/hw/hns/hns_roce_db.c @@ -78,7 +78,8 @@ static struct hns_roce_db_pgdir *hns_roce_alloc_db_pgdir( if (!pgdir) return NULL; - bitmap_fill(pgdir->order1, HNS_ROCE_DB_PER_PAGE / 2); + bitmap_fill(pgdir->order1, + HNS_ROCE_DB_PER_PAGE / HNS_ROCE_DB_TYPE_COUNT); pgdir->bits[0] = pgdir->order0; pgdir->bits[1] = pgdir->order1; pgdir->page = dma_alloc_coherent(dma_device, PAGE_SIZE, @@ -116,7 +117,7 @@ found: db->u.pgdir = pgdir; db->index = i; db->db_record = pgdir->page + db->index; - db->dma = pgdir->db_dma + db->index * 4; + db->dma = pgdir->db_dma + db->index * HNS_ROCE_DB_UNIT_SIZE; db->order = order; return 0; @@ -170,7 +171,8 @@ void hns_roce_free_db(struct hns_roce_dev *hr_dev, struct hns_roce_db *db) i >>= o; set_bit(i, db->u.pgdir->bits[o]); - if (bitmap_full(db->u.pgdir->order1, HNS_ROCE_DB_PER_PAGE / 2)) { + if (bitmap_full(db->u.pgdir->order1, + HNS_ROCE_DB_PER_PAGE / HNS_ROCE_DB_TYPE_COUNT)) { dma_free_coherent(hr_dev->dev, PAGE_SIZE, db->u.pgdir->page, db->u.pgdir->db_dma); list_del(&db->u.pgdir->list); |