[PATCH] drm/vc4: Use the bitmap API to allocate bitmaps

Christophe JAILLET christophe.jaillet at wanadoo.fr
Fri Jul 8 19:37:25 UTC 2022


Use bitmap_zalloc()/bitmap_free() instead of hand-writing them.

It is less verbose and it improves the semantic.

Signed-off-by: Christophe JAILLET <christophe.jaillet at wanadoo.fr>
---
 drivers/gpu/drm/vc4/vc4_validate_shaders.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_validate_shaders.c b/drivers/gpu/drm/vc4/vc4_validate_shaders.c
index e315aeb5fef5..d074d2014be4 100644
--- a/drivers/gpu/drm/vc4/vc4_validate_shaders.c
+++ b/drivers/gpu/drm/vc4/vc4_validate_shaders.c
@@ -795,9 +795,8 @@ vc4_validate_shader(struct drm_gem_cma_object *shader_obj)
 
 	reset_validation_state(&validation_state);
 
-	validation_state.branch_targets =
-		kcalloc(BITS_TO_LONGS(validation_state.max_ip),
-			sizeof(unsigned long), GFP_KERNEL);
+	validation_state.branch_targets = bitmap_zalloc(validation_state.max_ip,
+							GFP_KERNEL);
 	if (!validation_state.branch_targets)
 		goto fail;
 
@@ -939,12 +938,12 @@ vc4_validate_shader(struct drm_gem_cma_object *shader_obj)
 		(validated_shader->uniforms_size +
 		 4 * validated_shader->num_texture_samples);
 
-	kfree(validation_state.branch_targets);
+	bitmap_free(validation_state.branch_targets);
 
 	return validated_shader;
 
 fail:
-	kfree(validation_state.branch_targets);
+	bitmap_free(validation_state.branch_targets);
 	if (validated_shader) {
 		kfree(validated_shader->uniform_addr_offsets);
 		kfree(validated_shader->texture_samples);
-- 
2.34.1



More information about the dri-devel mailing list