diff mbox series

[rdma-next] RDMA/hns: Fix usage of bitmap allocation functions return values

Message ID 20180809190047.6642-1-pressmangal@gmail.com (mailing list archive)
State Accepted
Delegated to: Jason Gunthorpe
Headers show
Series [rdma-next] RDMA/hns: Fix usage of bitmap allocation functions return values | expand

Commit Message

Gal Pressman Aug. 9, 2018, 7 p.m. UTC
hns bitmap allocation functions return 0 on success and -1 on failure.
Callers of these functions wrongly used their return value as an errno, fix
that by making a proper conversion.

Fixes: a598c6f4c5a8 ("IB/hns: Simplify function of pd alloc and qp alloc")
Signed-off-by: Gal Pressman <pressmangal@gmail.com>
---
 drivers/infiniband/hw/hns/hns_roce_pd.c | 2 +-
 drivers/infiniband/hw/hns/hns_roce_qp.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Jason Gunthorpe Aug. 13, 2018, 5:18 p.m. UTC | #1
On Thu, Aug 09, 2018 at 10:00:47PM +0300, Gal Pressman wrote:
> hns bitmap allocation functions return 0 on success and -1 on failure.
> Callers of these functions wrongly used their return value as an errno, fix
> that by making a proper conversion.
> 
> Fixes: a598c6f4c5a8 ("IB/hns: Simplify function of pd alloc and qp alloc")
> Signed-off-by: Gal Pressman <pressmangal@gmail.com>
> ---
>  drivers/infiniband/hw/hns/hns_roce_pd.c | 2 +-
>  drivers/infiniband/hw/hns/hns_roce_qp.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

This looks fine to me.. hns team, can you ack it?

Thanks,
Jason


> diff --git a/drivers/infiniband/hw/hns/hns_roce_pd.c b/drivers/infiniband/hw/hns/hns_roce_pd.c
> index b9f2c871ff9a..e11c149da04d 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_pd.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_pd.c
> @@ -37,7 +37,7 @@
>  
>  static int hns_roce_pd_alloc(struct hns_roce_dev *hr_dev, unsigned long *pdn)
>  {
> -	return hns_roce_bitmap_alloc(&hr_dev->pd_bitmap, pdn);
> +	return hns_roce_bitmap_alloc(&hr_dev->pd_bitmap, pdn) ? -ENOMEM : 0;
>  }
>  
>  static void hns_roce_pd_free(struct hns_roce_dev *hr_dev, unsigned long pdn)
> diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c
> index c1dbddcd58c9..60837edbcffd 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_qp.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_qp.c
> @@ -115,7 +115,7 @@ static int hns_roce_reserve_range_qp(struct hns_roce_dev *hr_dev, int cnt,
>  {
>  	struct hns_roce_qp_table *qp_table = &hr_dev->qp_table;
>  
> -	return hns_roce_bitmap_alloc_range(&qp_table->bitmap, cnt, align, base);
> +	return hns_roce_bitmap_alloc_range(&qp_table->bitmap, cnt, align, base) ? -ENOMEM : 0;
>  }
>  
>  enum hns_roce_qp_state to_hns_roce_state(enum ib_qp_state state)
> -- 
> 2.14.4
>
Lijun Ou Aug. 15, 2018, 6:07 a.m. UTC | #2
在 2018/8/10 3:00, Gal Pressman 写道:
> hns bitmap allocation functions return 0 on success and -1 on failure.
> Callers of these functions wrongly used their return value as an errno, fix
> that by making a proper conversion.
> 
> Fixes: a598c6f4c5a8 ("IB/hns: Simplify function of pd alloc and qp alloc")
> Signed-off-by: Gal Pressman <pressmangal@gmail.com>
> ---
>  drivers/infiniband/hw/hns/hns_roce_pd.c | 2 +-
>  drivers/infiniband/hw/hns/hns_roce_qp.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/hns/hns_roce_pd.c b/drivers/infiniband/hw/hns/hns_roce_pd.c
> index b9f2c871ff9a..e11c149da04d 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_pd.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_pd.c
> @@ -37,7 +37,7 @@
>  
>  static int hns_roce_pd_alloc(struct hns_roce_dev *hr_dev, unsigned long *pdn)
>  {
> -	return hns_roce_bitmap_alloc(&hr_dev->pd_bitmap, pdn);
> +	return hns_roce_bitmap_alloc(&hr_dev->pd_bitmap, pdn) ? -ENOMEM : 0;
>  }
>  
>  static void hns_roce_pd_free(struct hns_roce_dev *hr_dev, unsigned long pdn)
> diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c
> index c1dbddcd58c9..60837edbcffd 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_qp.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_qp.c
> @@ -115,7 +115,7 @@ static int hns_roce_reserve_range_qp(struct hns_roce_dev *hr_dev, int cnt,
>  {
>  	struct hns_roce_qp_table *qp_table = &hr_dev->qp_table;
>  
> -	return hns_roce_bitmap_alloc_range(&qp_table->bitmap, cnt, align, base);
> +	return hns_roce_bitmap_alloc_range(&qp_table->bitmap, cnt, align, base) ? -ENOMEM : 0;
>  }
>  
>  enum hns_roce_qp_state to_hns_roce_state(enum ib_qp_state state)
> 
Ack-by:Lijun Ou <oulijun@huawei.com>
Jason Gunthorpe Aug. 15, 2018, 9:09 p.m. UTC | #3
On Thu, Aug 09, 2018 at 10:00:47PM +0300, Gal Pressman wrote:
> hns bitmap allocation functions return 0 on success and -1 on failure.
> Callers of these functions wrongly used their return value as an errno, fix
> that by making a proper conversion.
> 
> Fixes: a598c6f4c5a8 ("IB/hns: Simplify function of pd alloc and qp alloc")
> Signed-off-by: Gal Pressman <pressmangal@gmail.com>
> ---
>  drivers/infiniband/hw/hns/hns_roce_pd.c | 2 +-
>  drivers/infiniband/hw/hns/hns_roce_qp.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

Applied to for-next

Thanks,
Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/hns/hns_roce_pd.c b/drivers/infiniband/hw/hns/hns_roce_pd.c
index b9f2c871ff9a..e11c149da04d 100644
--- a/drivers/infiniband/hw/hns/hns_roce_pd.c
+++ b/drivers/infiniband/hw/hns/hns_roce_pd.c
@@ -37,7 +37,7 @@ 
 
 static int hns_roce_pd_alloc(struct hns_roce_dev *hr_dev, unsigned long *pdn)
 {
-	return hns_roce_bitmap_alloc(&hr_dev->pd_bitmap, pdn);
+	return hns_roce_bitmap_alloc(&hr_dev->pd_bitmap, pdn) ? -ENOMEM : 0;
 }
 
 static void hns_roce_pd_free(struct hns_roce_dev *hr_dev, unsigned long pdn)
diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c
index c1dbddcd58c9..60837edbcffd 100644
--- a/drivers/infiniband/hw/hns/hns_roce_qp.c
+++ b/drivers/infiniband/hw/hns/hns_roce_qp.c
@@ -115,7 +115,7 @@  static int hns_roce_reserve_range_qp(struct hns_roce_dev *hr_dev, int cnt,
 {
 	struct hns_roce_qp_table *qp_table = &hr_dev->qp_table;
 
-	return hns_roce_bitmap_alloc_range(&qp_table->bitmap, cnt, align, base);
+	return hns_roce_bitmap_alloc_range(&qp_table->bitmap, cnt, align, base) ? -ENOMEM : 0;
 }
 
 enum hns_roce_qp_state to_hns_roce_state(enum ib_qp_state state)