Skip to content

Commit 7fc775f

Browse files
tititiou36rafaeljw
authored andcommitted
thermal: intel_powerclamp: Use bitmap_zalloc/bitmap_free when applicable
'cpu_clamping_mask' is a bitmap. So use 'bitmap_zalloc()' and 'bitmap_free()' to simplify code, improve the semantic of the code and avoid some open-coded arithmetic in allocator arguments. Signed-off-by: Christophe JAILLET <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 9e1ff30 commit 7fc775f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

drivers/thermal/intel/intel_powerclamp.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -705,10 +705,8 @@ static enum cpuhp_state hp_state;
705705
static int __init powerclamp_init(void)
706706
{
707707
int retval;
708-
int bitmap_size;
709708

710-
bitmap_size = BITS_TO_LONGS(num_possible_cpus()) * sizeof(long);
711-
cpu_clamping_mask = kzalloc(bitmap_size, GFP_KERNEL);
709+
cpu_clamping_mask = bitmap_zalloc(num_possible_cpus(), GFP_KERNEL);
712710
if (!cpu_clamping_mask)
713711
return -ENOMEM;
714712

@@ -753,7 +751,7 @@ static int __init powerclamp_init(void)
753751
exit_unregister:
754752
cpuhp_remove_state_nocalls(hp_state);
755753
exit_free:
756-
kfree(cpu_clamping_mask);
754+
bitmap_free(cpu_clamping_mask);
757755
return retval;
758756
}
759757
module_init(powerclamp_init);
@@ -764,7 +762,7 @@ static void __exit powerclamp_exit(void)
764762
cpuhp_remove_state_nocalls(hp_state);
765763
free_percpu(worker_data);
766764
thermal_cooling_device_unregister(cooling_dev);
767-
kfree(cpu_clamping_mask);
765+
bitmap_free(cpu_clamping_mask);
768766

769767
cancel_delayed_work_sync(&poll_pkg_cstate_work);
770768
debugfs_remove_recursive(debug_dir);

0 commit comments

Comments
 (0)