OSDN Git Service

drm/amdgpu: Replace kzalloc with kcalloc
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Tue, 15 Jan 2019 05:22:02 +0000 (23:22 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 25 Jan 2019 21:15:35 +0000 (16:15 -0500)
Replace kzalloc() function with its 2-factor argument form, kcalloc().

This patch replaces cases of:

kzalloc(a * b, gfp)

with:
kcalloc(a, b, gfp)

Also, improve the coding style and the use of sizeof during
allocation by changing sizeof(struct dc_surface_update) and
sizeof(struct dc_plane_state) to sizeof(*updates) and
sizeof(*surfaces), correspondingly.

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index feb1b24..d5b3b7a 100644 (file)
@@ -5835,11 +5835,14 @@ dm_determine_update_type_for_commit(struct dc *dc,
        struct dm_crtc_state *new_dm_crtc_state, *old_dm_crtc_state;
        struct dc_stream_status *status = NULL;
 
-       struct dc_surface_update *updates = kzalloc(MAX_SURFACES * sizeof(struct dc_surface_update), GFP_KERNEL);
-       struct dc_plane_state *surface = kzalloc(MAX_SURFACES * sizeof(struct dc_plane_state), GFP_KERNEL);
+       struct dc_surface_update *updates;
+       struct dc_plane_state *surface;
        struct dc_stream_update stream_update;
        enum surface_update_type update_type = UPDATE_TYPE_FAST;
 
+       updates = kcalloc(MAX_SURFACES, sizeof(*updates), GFP_KERNEL);
+       surface = kcalloc(MAX_SURFACES, sizeof(*surface), GFP_KERNEL);
+
        if (!updates || !surface) {
                DRM_ERROR("Plane or surface update failed to allocate");
                /* Set type to FULL to avoid crashing in DC*/