Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp496289imw; Mon, 4 Jul 2022 13:31:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vntmayva8adAj8ZbnVxMRw+390kGypwxoazl5NUVq9QCStFRpcUQhAiRdKD+soVcAmEohc X-Received: by 2002:a05:6402:238b:b0:43a:16bf:2a65 with SMTP id j11-20020a056402238b00b0043a16bf2a65mr15148708eda.244.1656966671648; Mon, 04 Jul 2022 13:31:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656966671; cv=none; d=google.com; s=arc-20160816; b=E3KckGlRrKEcbPnqg2PLNRTqauhxN1H6ftq7MdVPDWqDUQDar6SDPeQfKsuw/hNf6x I3lF1/ScMb6+UHKUqLtHcrL9pAhJMsRaJDkN2CwtBsuuGE5f7Zn2vaUIStfkdodUFSLL VrlCLcXPBcGjGew0LREFUuxjfBJt49GLsmjWhjF86+ZVs1ox6s0fWSAnbVt52+6iz7hm HzFho/yHqqACgUZDeYNZ0xjR0UMvt5uQO1CAeq4G7i62B/anFPvTru8328vStPLiSQFz Dfv6/YGBuohZuCVa0Cs36z+itz8MV200HY/qKQNtxJFDKgXep/EWMwE2P6YGNbOQucto UzSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=k09WgPA2Lzlpv5vmRi3mN4jO/YuaqHEHojugQetoERc=; b=fPp5g+UM2Ly0iVTaNwEyVF9abi1p9+AnRR7Bp8fXSGaT6Pp1xYAxuqGKQUeAV/PF5W gmkNjMRBfE2UwYZ2roxTFwsCqoS56t4hQevvvvE6hF1WtrV3yxIsnD5v/JMDUshkZyVK 5FCQHt/a7XfVEfd6HvOjkrI785NK9lv4bINtlatjpH+gVjw+nsxufT+hzdBC4sjhki8e ynAndI2V0f54jAXFO+VGYVY93vuCGngYWdPxpQnnjT9SqpRSKpo51uQZk3EoUhvcIu9G qmpUBcZbA26qguQ8oGZSt/+HJlc2lllcvK9PafxcfdRWJ5DdBczM5fkJ6QVaoY5K7v9T dPxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q24-20020aa7d458000000b004359dd18afcsi12759481edr.20.2022.07.04.13.30.47; Mon, 04 Jul 2022 13:31:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231184AbiGDUXZ (ORCPT + 99 others); Mon, 4 Jul 2022 16:23:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229944AbiGDUXW (ORCPT ); Mon, 4 Jul 2022 16:23:22 -0400 Received: from smtp.smtpout.orange.fr (smtp03.smtpout.orange.fr [80.12.242.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7348926A for ; Mon, 4 Jul 2022 13:23:21 -0700 (PDT) Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id 8SbGooXMG4Ltq8SbGotLem; Mon, 04 Jul 2022 22:23:19 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Mon, 04 Jul 2022 22:23:19 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: Robin Holt , Steve Wahl , Mike Travis , Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] sgi-xp: Use the bitmap API to allocate bitmaps Date: Mon, 4 Jul 2022 22:23:17 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use bitmap_zalloc()/bitmap_free() instead of hand-writing them. It is less verbose and it improves the semantic. While at it, remove a useless cast in a bitmap_empty() call. Signed-off-by: Christophe JAILLET --- drivers/misc/sgi-xp/xpnet.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/misc/sgi-xp/xpnet.c b/drivers/misc/sgi-xp/xpnet.c index 50644f83e78c..2396ba3b03bd 100644 --- a/drivers/misc/sgi-xp/xpnet.c +++ b/drivers/misc/sgi-xp/xpnet.c @@ -285,7 +285,7 @@ xpnet_connection_activity(enum xp_retval reason, short partid, int channel, __clear_bit(partid, xpnet_broadcast_partitions); spin_unlock_bh(&xpnet_broadcast_lock); - if (bitmap_empty((unsigned long *)xpnet_broadcast_partitions, + if (bitmap_empty(xpnet_broadcast_partitions, xp_max_npartitions)) { netif_carrier_off(xpnet_device); } @@ -522,9 +522,8 @@ xpnet_init(void) dev_info(xpnet, "registering network device %s\n", XPNET_DEVICE_NAME); - xpnet_broadcast_partitions = kcalloc(BITS_TO_LONGS(xp_max_npartitions), - sizeof(long), - GFP_KERNEL); + xpnet_broadcast_partitions = bitmap_zalloc(xp_max_npartitions, + GFP_KERNEL); if (xpnet_broadcast_partitions == NULL) return -ENOMEM; @@ -535,7 +534,7 @@ xpnet_init(void) xpnet_device = alloc_netdev(0, XPNET_DEVICE_NAME, NET_NAME_UNKNOWN, ether_setup); if (xpnet_device == NULL) { - kfree(xpnet_broadcast_partitions); + bitmap_free(xpnet_broadcast_partitions); return -ENOMEM; } @@ -574,7 +573,7 @@ xpnet_init(void) result = register_netdev(xpnet_device); if (result != 0) { free_netdev(xpnet_device); - kfree(xpnet_broadcast_partitions); + bitmap_free(xpnet_broadcast_partitions); } return result; @@ -590,7 +589,7 @@ xpnet_exit(void) unregister_netdev(xpnet_device); free_netdev(xpnet_device); - kfree(xpnet_broadcast_partitions); + bitmap_free(xpnet_broadcast_partitions); } module_exit(xpnet_exit); -- 2.34.1