diff mbox series

[rdma-next] IB/mlx5: Simplify WQE count power of two check

Message ID 1549460735-14335-1-git-send-email-galpress@amazon.com (mailing list archive)
State Mainlined
Commit af8b38ed0b9d34db940a52418e7849904336ace5
Delegated to: Jason Gunthorpe
Headers show
Series [rdma-next] IB/mlx5: Simplify WQE count power of two check | expand

Commit Message

Gal Pressman Feb. 6, 2019, 1:45 p.m. UTC
Use is_power_of_2() instead of hard coding it in the driver.
While at it, fix the meaningless error print.

Signed-off-by: Gal Pressman <galpress@amazon.com>
---
 drivers/infiniband/hw/mlx5/qp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Leon Romanovsky Feb. 6, 2019, 5:03 p.m. UTC | #1
On Wed, Feb 06, 2019 at 03:45:35PM +0200, Gal Pressman wrote:
> Use is_power_of_2() instead of hard coding it in the driver.
> While at it, fix the meaningless error print.
>
> Signed-off-by: Gal Pressman <galpress@amazon.com>
> ---
>  drivers/infiniband/hw/mlx5/qp.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>

Thanks Gal,
Acked-by: Leon Romanovsky <leonro@mellanox.com>
Jason Gunthorpe Feb. 7, 2019, 8:15 p.m. UTC | #2
On Wed, Feb 06, 2019 at 03:45:35PM +0200, Gal Pressman wrote:
> Use is_power_of_2() instead of hard coding it in the driver.
> While at it, fix the meaningless error print.
> 
> Signed-off-by: Gal Pressman <galpress@amazon.com>
> Acked-by: Leon Romanovsky <leonro@mellanox.com>
> ---
>  drivers/infiniband/hw/mlx5/qp.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

applied to for-next thanks

Jason
 
> diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
> index 529e76f67cb6..c419c331a960 100644
> --- a/drivers/infiniband/hw/mlx5/qp.c
> +++ b/drivers/infiniband/hw/mlx5/qp.c
> @@ -435,9 +435,9 @@ static int set_user_buf_size(struct mlx5_ib_dev *dev,
>  		return -EINVAL;
>  	}
>  
> -	if (ucmd->sq_wqe_count && ((1 << ilog2(ucmd->sq_wqe_count)) != ucmd->sq_wqe_count)) {
> -		mlx5_ib_warn(dev, "sq_wqe_count %d, sq_wqe_count %d\n",
> -			     ucmd->sq_wqe_count, ucmd->sq_wqe_count);
> +	if (ucmd->sq_wqe_count && !is_power_of_2(ucmd->sq_wqe_count)) {
> +		mlx5_ib_warn(dev, "sq_wqe_count %d is not a power of two\n",
> +			     ucmd->sq_wqe_count);
>  		return -EINVAL;
>  	}
>
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 529e76f67cb6..c419c331a960 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -435,9 +435,9 @@  static int set_user_buf_size(struct mlx5_ib_dev *dev,
 		return -EINVAL;
 	}
 
-	if (ucmd->sq_wqe_count && ((1 << ilog2(ucmd->sq_wqe_count)) != ucmd->sq_wqe_count)) {
-		mlx5_ib_warn(dev, "sq_wqe_count %d, sq_wqe_count %d\n",
-			     ucmd->sq_wqe_count, ucmd->sq_wqe_count);
+	if (ucmd->sq_wqe_count && !is_power_of_2(ucmd->sq_wqe_count)) {
+		mlx5_ib_warn(dev, "sq_wqe_count %d is not a power of two\n",
+			     ucmd->sq_wqe_count);
 		return -EINVAL;
 	}