Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3160423rwd; Mon, 29 May 2023 06:35:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7aHFmjx3ZBWgb6bXT0NCRgZHHtNY3/eWGZjVCzZ/BfmRfVOD3LZAwxD6rnvJgxCf9dLAQm X-Received: by 2002:a17:90a:5417:b0:255:a8fb:a72a with SMTP id z23-20020a17090a541700b00255a8fba72amr11500107pjh.32.1685367349999; Mon, 29 May 2023 06:35:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685367349; cv=none; d=google.com; s=arc-20160816; b=pMVJ2gKqL41dab+enDS8BkBZyH9F3nvM85tMF7PMdtEuqpEBit4Do41Ck6oBSqozTe fMNxVB7i2IxThzLWdW+8vRk2kvTW2eBrOjiLsGCfNyiBphwex9dEBKTnIvpIUyd6wl7G l3f4bwV4uOaIUrNL2mMKUZik/INzzoY/9Ffd85t+ysYtqMZ4isvdY8WmzZhOl+ExnLJb TtjiBhBHpAkY5s0wQInMw6PGnsVPDe5+OCc6f+2NndTawDnmuPbM7wS7+b64O4b0bCoX QPuDu2hyZd1+5D5NTdrchwP2m7p/tQLaX6ann5voWu+o6GBhBEkj/r+Cd2Bjz+rbQmQ7 cZNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=8jgS5F8T526jeYM/4dx15aEEqAiDrCFfIRkSTI7woqQ=; b=0qZ2ZJ54nhDT81/EAxpLyswhaGZw54SYLZO+icbLwF16HEvkK2Ud1T1v15+E8JQLcf rCU7bKwcfjvKZDK9wie8L/7bHAY/G5jaWrkgUbaBsNybXzbbrnrPymVh/x3T592cyg9D Einb/3k9htFHbgN5xLbhE6wax9psT7L0xvZ8tR3KwdZ0pzKUBd7v821Rh5z93pDNAwpv Z8g4Fl9SSYsel+m0XqbXwRvijRNWWXMvvS+QBfJq6oAuSewaxxDjWA3EVPVqaTq0xsDf I8GDEzMQPc6D9iQCRrAHnJJ1HTO1Q6lFhFsFr0zLTc/jrHxQeQT/5e1tyNkgC5EMRL00 zxIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=B1CYNAU5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m5-20020a633f05000000b0053f3e6ec82bsi7927611pga.774.2023.05.29.06.35.35; Mon, 29 May 2023 06:35:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=B1CYNAU5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229796AbjE2N2P (ORCPT + 99 others); Mon, 29 May 2023 09:28:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229812AbjE2N2M (ORCPT ); Mon, 29 May 2023 09:28:12 -0400 Received: from smtp.smtpout.orange.fr (smtp-25.smtpout.orange.fr [80.12.242.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7981D9 for ; Mon, 29 May 2023 06:28:09 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id 3curqP39nbOsk3curqbTYb; Mon, 29 May 2023 15:28:07 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1685366887; bh=8jgS5F8T526jeYM/4dx15aEEqAiDrCFfIRkSTI7woqQ=; h=From:To:Cc:Subject:Date; b=B1CYNAU5uH+zmapITZq52yzJm53tatvYvMoVN94JNW5oCzjeueGEMalpu1Bo+SQfb Y3kQLtegL41jHSu1+SQh9c7l4c949VyIPcCo+AOO/ayW6f33RmhiWBMBk4tSP8ViPM 6ySkrEY3GBWekUIBp9+I67G6KwVC4WB8dRvocF6dKizbtpjjctbnlIq6fe09ijEoFI VYmhDpdU64IivgTJbognPSyAQBWqQjbGXkbD7OyAGhOh/J6zoLG2FEyGwGDmLaF3wm DTcVDAxIM4uLtzJeEnBU1LYwenDgu2AGtvVCBryFVg5RczCdduOArwj0b3Qrkr+IIb l66aNe9gB5F2w== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 29 May 2023 15:28:07 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Jacek Lawrynowicz , Stanislaw Gruszka , Oded Gabbay Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , dri-devel@lists.freedesktop.org Subject: [PATCH] accel/ivpu: Use struct_size() Date: Mon, 29 May 2023 15:28:04 +0200 Message-Id: <0ae53be873c27c9a8740c4fe6d8e7cd1b1224994.1685366864.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use struct_size() instead of hand-writing it. It is less verbose, more robust and more informative. Signed-off-by: Christophe JAILLET --- 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