lkml.org 
[lkml]   [2022]   [May]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 09/22] qed: replace bitmap_weight() with MANY_BITS()
    Date
    qed_init_qm_get_idx_from_flags() uses bitmap_weight() to check if
    number of bits in pq_flags is greater than 1.

    It's a bad practice to use bitmap API for things like flags, because flags
    are not bitmaps (and it's bloating and potentially not safe - for example
    if flags are not declared as unsigned long).

    In this case, MANY_BITS() fits better than bitmap_weight(), and
    switching to MANY_BITS() silences scripts/coccinelle/api/bitmap.cocci.

    CC: Ariel Elior <aelior@marvell.com>
    CC: David S. Miller <davem@davemloft.net>
    CC: Eric Dumazet <edumazet@google.com>
    CC: Jakub Kicinski <kuba@kernel.org>
    CC: Manish Chopra <manishc@marvell.com>
    CC: Paolo Abeni <pabeni@redhat.com>
    CC: netdev@vger.kernel.org
    CC: linux-kernel@vger.kernel.org
    Signed-off-by: Yury Norov <yury.norov@gmail.com>
    ---
    drivers/net/ethernet/qlogic/qed/qed_dev.c | 3 +--
    1 file changed, 1 insertion(+), 2 deletions(-)

    diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c b/drivers/net/ethernet/qlogic/qed/qed_dev.c
    index 672480c9d195..fbe69e538f53 100644
    --- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
    +++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
    @@ -1702,8 +1702,7 @@ static u16 *qed_init_qm_get_idx_from_flags(struct qed_hwfn *p_hwfn,
    struct qed_qm_info *qm_info = &p_hwfn->qm_info;

    /* Can't have multiple flags set here */
    - if (bitmap_weight(&pq_flags,
    - sizeof(pq_flags) * BITS_PER_BYTE) > 1) {
    + if (MANY_BITS(pq_flags)) {
    DP_ERR(p_hwfn, "requested multiple pq flags 0x%lx\n", pq_flags);
    goto err;
    }
    --
    2.32.0
    \
     
     \ /
      Last update: 2022-05-10 17:56    [W:2.670 / U:0.044 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site