Maybe merge this into the commit that introduces the functionality.

Am 13.11.20 um 16:29 schrieb Maxime Ripard:
Some fields that we're going to add cannot be just copied over to the
new state, and thus kmemdup is a bit unnecessary. Let's move to kzalloc
instead, and clean it up in the process.

Signed-off-by: Maxime Ripard <max...@cerno.tech>
---
  drivers/gpu/drm/vc4/vc4_kms.c | 8 +++++---
  1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c
index d6712924681e..3d0065df10f9 100644
--- a/drivers/gpu/drm/vc4/vc4_kms.c
+++ b/drivers/gpu/drm/vc4/vc4_kms.c
@@ -695,23 +695,25 @@ static int vc4_load_tracker_obj_init(struct vc4_dev *vc4)
  static struct drm_private_state *
  vc4_hvs_channels_duplicate_state(struct drm_private_obj *obj)
  {
+       struct vc4_hvs_state *old_state = to_vc4_hvs_state(obj->state);
        struct vc4_hvs_state *state;
- state = kmemdup(obj->state, sizeof(*state), GFP_KERNEL);
+       state = kzalloc(sizeof(*state), GFP_KERNEL);
        if (!state)
                return NULL;
__drm_atomic_helper_private_obj_duplicate_state(obj, &state->base); + state->unassigned_channels = old_state->unassigned_channels;
+
        return &state->base;
  }
static void vc4_hvs_channels_destroy_state(struct drm_private_obj *obj,
                                           struct drm_private_state *state)
  {
-       struct vc4_hvs_state *hvs_state;
+       struct vc4_hvs_state *hvs_state = to_vc4_hvs_state(state);
- hvs_state = to_vc4_hvs_state(state);
        kfree(hvs_state);
  }

--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer

Attachment: OpenPGP_0x680DC11D530B7A23.asc
Description: application/pgp-keys

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to