Commit 64c59166 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Greg Kroah-Hartman

sgi-xp: Use the bitmap API to allocate bitmaps

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.
Reviewed-by: default avatarSteve Wahl <steve.wahl@hpe.com>
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/ef49726d60f6a531428609f60a2398b6c3d9a26e.1656966181.git.christophe.jaillet@wanadoo.frSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1045a067
...@@ -285,7 +285,7 @@ xpnet_connection_activity(enum xp_retval reason, short partid, int channel, ...@@ -285,7 +285,7 @@ xpnet_connection_activity(enum xp_retval reason, short partid, int channel,
__clear_bit(partid, xpnet_broadcast_partitions); __clear_bit(partid, xpnet_broadcast_partitions);
spin_unlock_bh(&xpnet_broadcast_lock); spin_unlock_bh(&xpnet_broadcast_lock);
if (bitmap_empty((unsigned long *)xpnet_broadcast_partitions, if (bitmap_empty(xpnet_broadcast_partitions,
xp_max_npartitions)) { xp_max_npartitions)) {
netif_carrier_off(xpnet_device); netif_carrier_off(xpnet_device);
} }
...@@ -522,9 +522,8 @@ xpnet_init(void) ...@@ -522,9 +522,8 @@ xpnet_init(void)
dev_info(xpnet, "registering network device %s\n", XPNET_DEVICE_NAME); dev_info(xpnet, "registering network device %s\n", XPNET_DEVICE_NAME);
xpnet_broadcast_partitions = kcalloc(BITS_TO_LONGS(xp_max_npartitions), xpnet_broadcast_partitions = bitmap_zalloc(xp_max_npartitions,
sizeof(long), GFP_KERNEL);
GFP_KERNEL);
if (xpnet_broadcast_partitions == NULL) if (xpnet_broadcast_partitions == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -535,7 +534,7 @@ xpnet_init(void) ...@@ -535,7 +534,7 @@ xpnet_init(void)
xpnet_device = alloc_netdev(0, XPNET_DEVICE_NAME, NET_NAME_UNKNOWN, xpnet_device = alloc_netdev(0, XPNET_DEVICE_NAME, NET_NAME_UNKNOWN,
ether_setup); ether_setup);
if (xpnet_device == NULL) { if (xpnet_device == NULL) {
kfree(xpnet_broadcast_partitions); bitmap_free(xpnet_broadcast_partitions);
return -ENOMEM; return -ENOMEM;
} }
...@@ -574,7 +573,7 @@ xpnet_init(void) ...@@ -574,7 +573,7 @@ xpnet_init(void)
result = register_netdev(xpnet_device); result = register_netdev(xpnet_device);
if (result != 0) { if (result != 0) {
free_netdev(xpnet_device); free_netdev(xpnet_device);
kfree(xpnet_broadcast_partitions); bitmap_free(xpnet_broadcast_partitions);
} }
return result; return result;
...@@ -590,7 +589,7 @@ xpnet_exit(void) ...@@ -590,7 +589,7 @@ xpnet_exit(void)
unregister_netdev(xpnet_device); unregister_netdev(xpnet_device);
free_netdev(xpnet_device); free_netdev(xpnet_device);
kfree(xpnet_broadcast_partitions); bitmap_free(xpnet_broadcast_partitions);
} }
module_exit(xpnet_exit); module_exit(xpnet_exit);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment