* [PATCH] accel/ivpu: Use struct_size()
@ 2023-05-29 13:28 Christophe JAILLET
2023-06-01 15:58 ` Marco Pagani
0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2023-05-29 13:28 UTC (permalink / raw)
To: Jacek Lawrynowicz, Stanislaw Gruszka, Oded Gabbay
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, dri-devel
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>
---
drivers/accel/ivpu/ivpu_job.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/accel/ivpu/ivpu_job.c b/drivers/accel/ivpu/ivpu_job.c
index 3c6f1e16cf2f..0a09bba8da24 100644
--- a/drivers/accel/ivpu/ivpu_job.c
+++ b/drivers/accel/ivpu/ivpu_job.c
@@ -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_job *job;
- size_t buf_size;
int ret;
ret = ivpu_rpm_get(vdev);
if (ret < 0)
return NULL;
- buf_size = sizeof(*job) + bo_count * sizeof(struct ivpu_bo *);
- job = kzalloc(buf_size, GFP_KERNEL);
+ job = kzalloc(struct_size(job, bos, bo_count), GFP_KERNEL);
if (!job)
goto err_rpm_put;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] accel/ivpu: Use struct_size()
2023-05-29 13:28 [PATCH] accel/ivpu: Use struct_size() Christophe JAILLET
@ 2023-06-01 15:58 ` Marco Pagani
2023-06-08 5:57 ` Stanislaw Gruszka
0 siblings, 1 reply; 3+ messages in thread
From: Marco Pagani @ 2023-06-01 15:58 UTC (permalink / raw)
To: Christophe JAILLET, Jacek Lawrynowicz, Stanislaw Gruszka,
Oded Gabbay
Cc: linux-kernel, kernel-janitors, dri-devel
On 2023-05-29 15:28, Christophe JAILLET wrote:
> 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>
> ---
> drivers/accel/ivpu/ivpu_job.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/accel/ivpu/ivpu_job.c b/drivers/accel/ivpu/ivpu_job.c
> index 3c6f1e16cf2f..0a09bba8da24 100644
> --- a/drivers/accel/ivpu/ivpu_job.c
> +++ b/drivers/accel/ivpu/ivpu_job.c
> @@ -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_job *job;
> - size_t buf_size;
> int ret;
>
> ret = ivpu_rpm_get(vdev);
> if (ret < 0)
> return NULL;
>
> - buf_size = sizeof(*job) + bo_count * sizeof(struct ivpu_bo *);
> - job = kzalloc(buf_size, GFP_KERNEL);
> + job = kzalloc(struct_size(job, bos, bo_count), GFP_KERNEL);
> if (!job)
> goto err_rpm_put;
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] accel/ivpu: Use struct_size()
2023-06-01 15:58 ` Marco Pagani
@ 2023-06-08 5:57 ` Stanislaw Gruszka
0 siblings, 0 replies; 3+ messages in thread
From: Stanislaw Gruszka @ 2023-06-08 5:57 UTC (permalink / raw)
To: Marco Pagani
Cc: Christophe JAILLET, Jacek Lawrynowicz, Oded Gabbay,
kernel-janitors, linux-kernel, dri-devel
On Thu, Jun 01, 2023 at 05:58:48PM +0200, Marco Pagani wrote:
>
> On 2023-05-29 15:28, Christophe JAILLET wrote:
> > 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>
Applied to drm-misc-next
Thanks
Stanislaw
>
> > ---
> > drivers/accel/ivpu/ivpu_job.c | 4 +---
> > 1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/drivers/accel/ivpu/ivpu_job.c b/drivers/accel/ivpu/ivpu_job.c
> > index 3c6f1e16cf2f..0a09bba8da24 100644
> > --- a/drivers/accel/ivpu/ivpu_job.c
> > +++ b/drivers/accel/ivpu/ivpu_job.c
> > @@ -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_job *job;
> > - size_t buf_size;
> > int ret;
> >
> > ret = ivpu_rpm_get(vdev);
> > if (ret < 0)
> > return NULL;
> >
> > - buf_size = sizeof(*job) + bo_count * sizeof(struct ivpu_bo *);
> > - job = kzalloc(buf_size, GFP_KERNEL);
> > + job = kzalloc(struct_size(job, bos, bo_count), GFP_KERNEL);
> > if (!job)
> > goto err_rpm_put;
> >
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-08 5:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-29 13:28 [PATCH] accel/ivpu: Use struct_size() Christophe JAILLET
2023-06-01 15:58 ` Marco Pagani
2023-06-08 5:57 ` Stanislaw Gruszka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox