From nobody Sun Apr 19 07:22:03 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87C13C43334 for ; Mon, 4 Jul 2022 20:23:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229641AbiGDUX0 (ORCPT ); Mon, 4 Jul 2022 16:23:26 -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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Steve Wahl --- 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); =20 - 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) =20 dev_info(xpnet, "registering network device %s\n", XPNET_DEVICE_NAME); =20 - xpnet_broadcast_partitions =3D kcalloc(BITS_TO_LONGS(xp_max_npartitions), - sizeof(long), - GFP_KERNEL); + xpnet_broadcast_partitions =3D bitmap_zalloc(xp_max_npartitions, + GFP_KERNEL); if (xpnet_broadcast_partitions =3D=3D NULL) return -ENOMEM; =20 @@ -535,7 +534,7 @@ xpnet_init(void) xpnet_device =3D alloc_netdev(0, XPNET_DEVICE_NAME, NET_NAME_UNKNOWN, ether_setup); if (xpnet_device =3D=3D NULL) { - kfree(xpnet_broadcast_partitions); + bitmap_free(xpnet_broadcast_partitions); return -ENOMEM; } =20 @@ -574,7 +573,7 @@ xpnet_init(void) result =3D register_netdev(xpnet_device); if (result !=3D 0) { free_netdev(xpnet_device); - kfree(xpnet_broadcast_partitions); + bitmap_free(xpnet_broadcast_partitions); } =20 return result; @@ -590,7 +589,7 @@ xpnet_exit(void) =20 unregister_netdev(xpnet_device); free_netdev(xpnet_device); - kfree(xpnet_broadcast_partitions); + bitmap_free(xpnet_broadcast_partitions); } =20 module_exit(xpnet_exit); --=20 2.34.1