Commit 7fc775ff authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Rafael J. Wysocki
Browse files

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: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 9e1ff307
Loading
Loading
Loading
Loading
+3 −5
Original line number Original line Diff line number Diff line
@@ -705,10 +705,8 @@ static enum cpuhp_state hp_state;
static int __init powerclamp_init(void)
static int __init powerclamp_init(void)
{
{
	int retval;
	int retval;
	int bitmap_size;


	bitmap_size = BITS_TO_LONGS(num_possible_cpus()) * sizeof(long);
	cpu_clamping_mask = bitmap_zalloc(num_possible_cpus(), GFP_KERNEL);
	cpu_clamping_mask = kzalloc(bitmap_size, GFP_KERNEL);
	if (!cpu_clamping_mask)
	if (!cpu_clamping_mask)
		return -ENOMEM;
		return -ENOMEM;


@@ -753,7 +751,7 @@ static int __init powerclamp_init(void)
exit_unregister:
exit_unregister:
	cpuhp_remove_state_nocalls(hp_state);
	cpuhp_remove_state_nocalls(hp_state);
exit_free:
exit_free:
	kfree(cpu_clamping_mask);
	bitmap_free(cpu_clamping_mask);
	return retval;
	return retval;
}
}
module_init(powerclamp_init);
module_init(powerclamp_init);
@@ -764,7 +762,7 @@ static void __exit powerclamp_exit(void)
	cpuhp_remove_state_nocalls(hp_state);
	cpuhp_remove_state_nocalls(hp_state);
	free_percpu(worker_data);
	free_percpu(worker_data);
	thermal_cooling_device_unregister(cooling_dev);
	thermal_cooling_device_unregister(cooling_dev);
	kfree(cpu_clamping_mask);
	bitmap_free(cpu_clamping_mask);


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