IB/mlx5: Simplify WQE count power of two check
authorGal Pressman <galpress@amazon.com>
Wed, 6 Feb 2019 13:45:35 +0000 (15:45 +0200)
committerJason Gunthorpe <jgg@mellanox.com>
Thu, 7 Feb 2019 20:14:55 +0000 (13:14 -0700)
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>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/hw/mlx5/qp.c

index 664d5c6..4f2bc10 100644 (file)
@@ -533,9 +533,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;
        }