Skip to content

Commit 272bba1

Browse files
Ruan Jinjierleon
authored andcommitted
RDMA: Remove unnecessary ternary operators
There are a little ternary operators, the true or false judgment of which is unnecessary in C language semantics. Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com> Link: https://lore.kernel.org/r/20230731085118.394443-1-ruanjinjie@huawei.com Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent f0ff2a2 commit 272bba1

File tree

9 files changed

+18
-22
lines changed

9 files changed

+18
-22
lines changed

drivers/infiniband/core/netlink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static bool is_nl_msg_valid(unsigned int type, unsigned int op)
7575
if (type >= RDMA_NL_NUM_CLIENTS)
7676
return false;
7777

78-
return (op < max_num_ops[type]) ? true : false;
78+
return op < max_num_ops[type];
7979
}
8080

8181
static const struct rdma_nl_cbs *

drivers/infiniband/hw/bnxt_re/ib_verbs.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,8 +1336,7 @@ static int bnxt_re_init_qp_attr(struct bnxt_re_qp *qp, struct bnxt_re_pd *pd,
13361336
qplqp->pd = &pd->qplib_pd;
13371337
qplqp->qp_handle = (u64)qplqp;
13381338
qplqp->max_inline_data = init_attr->cap.max_inline_data;
1339-
qplqp->sig_type = ((init_attr->sq_sig_type == IB_SIGNAL_ALL_WR) ?
1340-
true : false);
1339+
qplqp->sig_type = init_attr->sq_sig_type == IB_SIGNAL_ALL_WR;
13411340
qptype = bnxt_re_init_qp_type(rdev, init_attr);
13421341
if (qptype < 0) {
13431342
rc = qptype;
@@ -2261,7 +2260,7 @@ static int bnxt_re_build_qp1_send_v2(struct bnxt_re_qp *qp,
22612260
}
22622261

22632262
is_eth = true;
2264-
is_vlan = (vlan_id && (vlan_id < 0x1000)) ? true : false;
2263+
is_vlan = vlan_id && (vlan_id < 0x1000);
22652264

22662265
ib_ud_header_init(payload_size, !is_eth, is_eth, is_vlan, is_grh,
22672266
ip_version, is_udp, 0, &qp->qp1_hdr);

drivers/infiniband/hw/bnxt_re/main.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,8 @@ int bnxt_re_hwrm_qcaps(struct bnxt_re_dev *rdev)
433433
cctx->modes.db_push = le32_to_cpu(resp.flags) & FUNC_QCAPS_RESP_FLAGS_WCB_PUSH_MODE;
434434

435435
cctx->modes.dbr_pacing =
436-
le32_to_cpu(resp.flags_ext2) & FUNC_QCAPS_RESP_FLAGS_EXT2_DBR_PACING_EXT_SUPPORTED ?
437-
true : false;
436+
le32_to_cpu(resp.flags_ext2) &
437+
FUNC_QCAPS_RESP_FLAGS_EXT2_DBR_PACING_EXT_SUPPORTED;
438438
return 0;
439439
}
440440

@@ -1333,8 +1333,7 @@ static int bnxt_re_setup_qos(struct bnxt_re_dev *rdev)
13331333
*/
13341334
if ((prio_map == 0 && rdev->qplib_res.prio) ||
13351335
(prio_map != 0 && !rdev->qplib_res.prio)) {
1336-
rdev->qplib_res.prio = prio_map ? true : false;
1337-
1336+
rdev->qplib_res.prio = prio_map;
13381337
bnxt_re_update_gid(rdev);
13391338
}
13401339

drivers/infiniband/hw/bnxt_re/qplib_fp.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,8 +1373,7 @@ int bnxt_qplib_query_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
13731373
qp->state = sb->en_sqd_async_notify_state &
13741374
CREQ_QUERY_QP_RESP_SB_STATE_MASK;
13751375
qp->en_sqd_async_notify = sb->en_sqd_async_notify_state &
1376-
CREQ_QUERY_QP_RESP_SB_EN_SQD_ASYNC_NOTIFY ?
1377-
true : false;
1376+
CREQ_QUERY_QP_RESP_SB_EN_SQD_ASYNC_NOTIFY;
13781377
qp->access = sb->access;
13791378
qp->pkey_index = le16_to_cpu(sb->pkey);
13801379
qp->qkey = le32_to_cpu(sb->qkey);

drivers/infiniband/hw/hns/hns_roce_hem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ bool hns_roce_check_whether_mhop(struct hns_roce_dev *hr_dev, u32 type)
7878
return false;
7979
}
8080

81-
return hop_num ? true : false;
81+
return hop_num;
8282
}
8383

8484
static bool hns_roce_check_hem_null(struct hns_roce_hem **hem, u64 hem_idx,

drivers/infiniband/hw/irdma/uk.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ int irdma_uk_rdma_write(struct irdma_qp_uk *qp, struct irdma_post_sq_info *info,
282282
bool read_fence = false;
283283
u16 quanta;
284284

285-
info->push_wqe = qp->push_db ? true : false;
285+
info->push_wqe = qp->push_db;
286286

287287
op_info = &info->op.rdma_write;
288288
if (op_info->num_lo_sges > qp->max_sq_frag_cnt)
@@ -383,7 +383,7 @@ int irdma_uk_rdma_read(struct irdma_qp_uk *qp, struct irdma_post_sq_info *info,
383383
u16 quanta;
384384
u64 hdr;
385385

386-
info->push_wqe = qp->push_db ? true : false;
386+
info->push_wqe = qp->push_db;
387387

388388
op_info = &info->op.rdma_read;
389389
if (qp->max_sq_frag_cnt < op_info->num_lo_sges)
@@ -468,7 +468,7 @@ int irdma_uk_send(struct irdma_qp_uk *qp, struct irdma_post_sq_info *info,
468468
bool read_fence = false;
469469
u16 quanta;
470470

471-
info->push_wqe = qp->push_db ? true : false;
471+
info->push_wqe = qp->push_db;
472472

473473
op_info = &info->op.send;
474474
if (qp->max_sq_frag_cnt < op_info->num_sges)
@@ -720,7 +720,7 @@ int irdma_uk_inline_rdma_write(struct irdma_qp_uk *qp,
720720
u32 i, total_size = 0;
721721
u16 quanta;
722722

723-
info->push_wqe = qp->push_db ? true : false;
723+
info->push_wqe = qp->push_db;
724724
op_info = &info->op.rdma_write;
725725

726726
if (unlikely(qp->max_sq_frag_cnt < op_info->num_lo_sges))
@@ -794,7 +794,7 @@ int irdma_uk_inline_send(struct irdma_qp_uk *qp,
794794
u32 i, total_size = 0;
795795
u16 quanta;
796796

797-
info->push_wqe = qp->push_db ? true : false;
797+
info->push_wqe = qp->push_db;
798798
op_info = &info->op.send;
799799

800800
if (unlikely(qp->max_sq_frag_cnt < op_info->num_sges))
@@ -872,7 +872,7 @@ int irdma_uk_stag_local_invalidate(struct irdma_qp_uk *qp,
872872
bool local_fence = false;
873873
struct ib_sge sge = {};
874874

875-
info->push_wqe = qp->push_db ? true : false;
875+
info->push_wqe = qp->push_db;
876876
op_info = &info->op.inv_local_stag;
877877
local_fence = info->local_fence;
878878

drivers/infiniband/hw/irdma/verbs.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ static int irdma_create_qp(struct ib_qp *ibqp,
10041004
refcount_set(&iwqp->refcnt, 1);
10051005
spin_lock_init(&iwqp->lock);
10061006
spin_lock_init(&iwqp->sc_qp.pfpdu.lock);
1007-
iwqp->sig_all = (init_attr->sq_sig_type == IB_SIGNAL_ALL_WR) ? 1 : 0;
1007+
iwqp->sig_all = init_attr->sq_sig_type == IB_SIGNAL_ALL_WR;
10081008
rf->qp_table[qp_num] = iwqp;
10091009

10101010
if (rdma_protocol_roce(&iwdev->ibdev, 1)) {
@@ -3547,8 +3547,7 @@ static void irdma_process_cqe(struct ib_wc *entry,
35473547
set_ib_wc_op_sq(cq_poll_info, entry);
35483548
} else {
35493549
set_ib_wc_op_rq(cq_poll_info, entry,
3550-
qp->qp_uk.qp_caps & IRDMA_SEND_WITH_IMM ?
3551-
true : false);
3550+
qp->qp_uk.qp_caps & IRDMA_SEND_WITH_IMM);
35523551
if (qp->qp_uk.qp_type != IRDMA_QP_TYPE_ROCE_UD &&
35533552
cq_poll_info->stag_invalid_set) {
35543553
entry->ex.invalidate_rkey = cq_poll_info->inv_stag;

drivers/infiniband/hw/ocrdma/ocrdma_verbs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ static void ocrdma_set_qp_init_params(struct ocrdma_qp *qp,
12771277
qp->sq.max_sges = attrs->cap.max_send_sge;
12781278
qp->rq.max_sges = attrs->cap.max_recv_sge;
12791279
qp->state = OCRDMA_QPS_RST;
1280-
qp->signaled = (attrs->sq_sig_type == IB_SIGNAL_ALL_WR) ? true : false;
1280+
qp->signaled = attrs->sq_sig_type == IB_SIGNAL_ALL_WR;
12811281
}
12821282

12831283
static void ocrdma_store_gsi_qp_cq(struct ocrdma_dev *dev,

drivers/infiniband/hw/qedr/verbs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ static void qedr_set_common_qp_params(struct qedr_dev *dev,
13581358

13591359
qp->prev_wqe_size = 0;
13601360

1361-
qp->signaled = (attrs->sq_sig_type == IB_SIGNAL_ALL_WR) ? true : false;
1361+
qp->signaled = attrs->sq_sig_type == IB_SIGNAL_ALL_WR;
13621362
qp->dev = dev;
13631363
if (qedr_qp_has_sq(qp)) {
13641364
qedr_reset_qp_hwq_info(&qp->sq);

0 commit comments

Comments
 (0)