diff mbox series

IB/mlx5: Fix sparse warnings in to_mlx5_access_flags()

Message ID 20190131003051.98427-1-bvanassche@acm.org (mailing list archive)
State Mainlined
Commit bf3b4f066d992718b1f86f21249d6781fdc8340d
Delegated to: Jason Gunthorpe
Headers show
Series IB/mlx5: Fix sparse warnings in to_mlx5_access_flags() | expand

Commit Message

Bart Van Assche Jan. 31, 2019, 12:30 a.m. UTC
Avoid that sparse reports the following for the mlx5 driver:

drivers/infiniband/hw/mlx5/qp.c:2671:34: warning: invalid assignment: |=
drivers/infiniband/hw/mlx5/qp.c:2671:34:    left side has type restricted __be32
drivers/infiniband/hw/mlx5/qp.c:2671:34:    right side has type int
drivers/infiniband/hw/mlx5/qp.c:2679:34: warning: invalid assignment: |=
drivers/infiniband/hw/mlx5/qp.c:2679:34:    left side has type restricted __be32
drivers/infiniband/hw/mlx5/qp.c:2679:34:    right side has type int
drivers/infiniband/hw/mlx5/qp.c:2680:34: warning: invalid assignment: |=
drivers/infiniband/hw/mlx5/qp.c:2680:34:    left side has type restricted __be32
drivers/infiniband/hw/mlx5/qp.c:2680:34:    right side has type int
drivers/infiniband/hw/mlx5/qp.c:2684:34: warning: invalid assignment: |=
drivers/infiniband/hw/mlx5/qp.c:2684:34:    left side has type restricted __be32
drivers/infiniband/hw/mlx5/qp.c:2684:34:    right side has type int
drivers/infiniband/hw/mlx5/qp.c:2686:28: warning: cast from restricted __be32
drivers/infiniband/hw/mlx5/qp.c:2686:28: warning: incorrect type in argument 1 (different base types)
drivers/infiniband/hw/mlx5/qp.c:2686:28:    expected unsigned int [usertype] val
drivers/infiniband/hw/mlx5/qp.c:2686:28:    got restricted __be32 [usertype]
drivers/infiniband/hw/mlx5/qp.c:2686:28: warning: cast from restricted __be32
drivers/infiniband/hw/mlx5/qp.c:2686:28: warning: cast from restricted __be32
drivers/infiniband/hw/mlx5/qp.c:2686:28: warning: cast from restricted __be32
drivers/infiniband/hw/mlx5/qp.c:2686:28: warning: cast from restricted __be32

This patch does not change any functionality.

Cc: Yonatan Cohen <yonatanc@mellanox.com>
Cc: Guy Levi <guyle@mellanox.com>
Cc: Leon Romanovsky <leonro@mellanox.com>
Fixes: a60109dc9a95 ("IB/mlx5: Add support for extended atomic operations") # v4.20
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/infiniband/hw/mlx5/qp.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Leon Romanovsky Feb. 5, 2019, 5:52 p.m. UTC | #1
On Wed, Jan 30, 2019 at 04:30:51PM -0800, Bart Van Assche wrote:
> Avoid that sparse reports the following for the mlx5 driver:
>
> drivers/infiniband/hw/mlx5/qp.c:2671:34: warning: invalid assignment: |=
> drivers/infiniband/hw/mlx5/qp.c:2671:34:    left side has type restricted __be32
> drivers/infiniband/hw/mlx5/qp.c:2671:34:    right side has type int
> drivers/infiniband/hw/mlx5/qp.c:2679:34: warning: invalid assignment: |=
> drivers/infiniband/hw/mlx5/qp.c:2679:34:    left side has type restricted __be32
> drivers/infiniband/hw/mlx5/qp.c:2679:34:    right side has type int
> drivers/infiniband/hw/mlx5/qp.c:2680:34: warning: invalid assignment: |=
> drivers/infiniband/hw/mlx5/qp.c:2680:34:    left side has type restricted __be32
> drivers/infiniband/hw/mlx5/qp.c:2680:34:    right side has type int
> drivers/infiniband/hw/mlx5/qp.c:2684:34: warning: invalid assignment: |=
> drivers/infiniband/hw/mlx5/qp.c:2684:34:    left side has type restricted __be32
> drivers/infiniband/hw/mlx5/qp.c:2684:34:    right side has type int
> drivers/infiniband/hw/mlx5/qp.c:2686:28: warning: cast from restricted __be32
> drivers/infiniband/hw/mlx5/qp.c:2686:28: warning: incorrect type in argument 1 (different base types)
> drivers/infiniband/hw/mlx5/qp.c:2686:28:    expected unsigned int [usertype] val
> drivers/infiniband/hw/mlx5/qp.c:2686:28:    got restricted __be32 [usertype]
> drivers/infiniband/hw/mlx5/qp.c:2686:28: warning: cast from restricted __be32
> drivers/infiniband/hw/mlx5/qp.c:2686:28: warning: cast from restricted __be32
> drivers/infiniband/hw/mlx5/qp.c:2686:28: warning: cast from restricted __be32
> drivers/infiniband/hw/mlx5/qp.c:2686:28: warning: cast from restricted __be32
>
> This patch does not change any functionality.
>
> Cc: Yonatan Cohen <yonatanc@mellanox.com>
> Cc: Guy Levi <guyle@mellanox.com>
> Cc: Leon Romanovsky <leonro@mellanox.com>
> Fixes: a60109dc9a95 ("IB/mlx5: Add support for extended atomic operations") # v4.20
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/infiniband/hw/mlx5/qp.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>

Thanks, Bart

Acked-by: Leon Romanovsky <leonro@mellanox.com>
Jason Gunthorpe Feb. 5, 2019, 10:26 p.m. UTC | #2
On Wed, Jan 30, 2019 at 04:30:51PM -0800, Bart Van Assche wrote:
> Avoid that sparse reports the following for the mlx5 driver:
> 
> drivers/infiniband/hw/mlx5/qp.c:2671:34: warning: invalid assignment: |=
> drivers/infiniband/hw/mlx5/qp.c:2671:34:    left side has type restricted __be32
> drivers/infiniband/hw/mlx5/qp.c:2671:34:    right side has type int
> drivers/infiniband/hw/mlx5/qp.c:2679:34: warning: invalid assignment: |=
> drivers/infiniband/hw/mlx5/qp.c:2679:34:    left side has type restricted __be32
> drivers/infiniband/hw/mlx5/qp.c:2679:34:    right side has type int
> drivers/infiniband/hw/mlx5/qp.c:2680:34: warning: invalid assignment: |=
> drivers/infiniband/hw/mlx5/qp.c:2680:34:    left side has type restricted __be32
> drivers/infiniband/hw/mlx5/qp.c:2680:34:    right side has type int
> drivers/infiniband/hw/mlx5/qp.c:2684:34: warning: invalid assignment: |=
> drivers/infiniband/hw/mlx5/qp.c:2684:34:    left side has type restricted __be32
> drivers/infiniband/hw/mlx5/qp.c:2684:34:    right side has type int
> drivers/infiniband/hw/mlx5/qp.c:2686:28: warning: cast from restricted __be32
> drivers/infiniband/hw/mlx5/qp.c:2686:28: warning: incorrect type in argument 1 (different base types)
> drivers/infiniband/hw/mlx5/qp.c:2686:28:    expected unsigned int [usertype] val
> drivers/infiniband/hw/mlx5/qp.c:2686:28:    got restricted __be32 [usertype]
> drivers/infiniband/hw/mlx5/qp.c:2686:28: warning: cast from restricted __be32
> drivers/infiniband/hw/mlx5/qp.c:2686:28: warning: cast from restricted __be32
> drivers/infiniband/hw/mlx5/qp.c:2686:28: warning: cast from restricted __be32
> drivers/infiniband/hw/mlx5/qp.c:2686:28: warning: cast from restricted __be32
> 
> This patch does not change any functionality.
> 
> Cc: Yonatan Cohen <yonatanc@mellanox.com>
> Cc: Guy Levi <guyle@mellanox.com>
> Cc: Leon Romanovsky <leonro@mellanox.com>
> Fixes: a60109dc9a95 ("IB/mlx5: Add support for extended atomic operations") # v4.20
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/infiniband/hw/mlx5/qp.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)

applied to for-next

Thanks,
Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 529e76f67cb6..ca6c40e98607 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -2647,10 +2647,10 @@  int mlx5_ib_destroy_qp(struct ib_qp *qp)
 
 static int to_mlx5_access_flags(struct mlx5_ib_qp *qp,
 				const struct ib_qp_attr *attr,
-				int attr_mask, __be32 *hw_access_flags)
+				int attr_mask, __be32 *hw_access_flags_be)
 {
 	u8 dest_rd_atomic;
-	u32 access_flags;
+	u32 access_flags, hw_access_flags = 0;
 
 	struct mlx5_ib_dev *dev = to_mdev(qp->ibqp.device);
 
@@ -2668,7 +2668,7 @@  static int to_mlx5_access_flags(struct mlx5_ib_qp *qp,
 		access_flags &= IB_ACCESS_REMOTE_WRITE;
 
 	if (access_flags & IB_ACCESS_REMOTE_READ)
-		*hw_access_flags |= MLX5_QP_BIT_RRE;
+		hw_access_flags |= MLX5_QP_BIT_RRE;
 	if (access_flags & IB_ACCESS_REMOTE_ATOMIC) {
 		int atomic_mode;
 
@@ -2676,14 +2676,14 @@  static int to_mlx5_access_flags(struct mlx5_ib_qp *qp,
 		if (atomic_mode < 0)
 			return -EOPNOTSUPP;
 
-		*hw_access_flags |= MLX5_QP_BIT_RAE;
-		*hw_access_flags |= atomic_mode << MLX5_ATOMIC_MODE_OFFSET;
+		hw_access_flags |= MLX5_QP_BIT_RAE;
+		hw_access_flags |= atomic_mode << MLX5_ATOMIC_MODE_OFFSET;
 	}
 
 	if (access_flags & IB_ACCESS_REMOTE_WRITE)
-		*hw_access_flags |= MLX5_QP_BIT_RWE;
+		hw_access_flags |= MLX5_QP_BIT_RWE;
 
-	*hw_access_flags = cpu_to_be32(*hw_access_flags);
+	*hw_access_flags_be = cpu_to_be32(hw_access_flags);
 
 	return 0;
 }
@@ -3384,7 +3384,7 @@  static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
 	}
 
 	if (attr_mask & (IB_QP_ACCESS_FLAGS | IB_QP_MAX_DEST_RD_ATOMIC)) {
-		__be32 access_flags = 0;
+		__be32 access_flags;
 
 		err = to_mlx5_access_flags(qp, attr, attr_mask, &access_flags);
 		if (err)