accel/ivpu: Use struct_size()

Use struct_size() instead of hand-writing it. It is less verbose, more
robust and more informative.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Marco Pagani <marpagan@redhat.com>
Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/0ae53be873c27c9a8740c4fe6d8e7cd1b1224994.1685366864.git.christophe.jaillet@wanadoo.fr
This commit is contained in:
Christophe JAILLET 2023-05-29 15:28:04 +02:00 committed by Stanislaw Gruszka
parent 1ebc9f0365
commit 9230d5dcb2

View File

@ -289,15 +289,13 @@ ivpu_create_job(struct ivpu_file_priv *file_priv, u32 engine_idx, u32 bo_count)
{ {
struct ivpu_device *vdev = file_priv->vdev; struct ivpu_device *vdev = file_priv->vdev;
struct ivpu_job *job; struct ivpu_job *job;
size_t buf_size;
int ret; int ret;
ret = ivpu_rpm_get(vdev); ret = ivpu_rpm_get(vdev);
if (ret < 0) if (ret < 0)
return NULL; return NULL;
buf_size = sizeof(*job) + bo_count * sizeof(struct ivpu_bo *); job = kzalloc(struct_size(job, bos, bo_count), GFP_KERNEL);
job = kzalloc(buf_size, GFP_KERNEL);
if (!job) if (!job)
goto err_rpm_put; goto err_rpm_put;