From patchwork Mon May 29 13:28:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 100268 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1516024vqr; Mon, 29 May 2023 06:32:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5sMYBiGmI/Ch+cyrLo/Lyn2/Xio4DDAQdyHHQLxIWyIypgYghTpgPs5kI9dyfWnGWwl4X6 X-Received: by 2002:a17:903:32c3:b0:1af:cbb1:845 with SMTP id i3-20020a17090332c300b001afcbb10845mr12247351plr.16.1685367148378; Mon, 29 May 2023 06:32:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685367148; cv=none; d=google.com; s=arc-20160816; b=m624G/smWTiANvPsTwMja4s4K5AxwCyLgFAvGpmLV7HLKpYktnWmtkwfvKrR5Lba36 jCzpWnl6SPqrJvflhcXEtG2Hoi1n2UGO3+vDR13jm4l70scg616DJxqRajpTZQTAfv1k QdTFb+HTEPfYqKAmDZlk9dRkz2gmiMyLw4uZEiEpbLU27tXgydtOGXurzYcTvZm/Becj fyfd84wMo0mX9efRdT6JYqXlTvjXdKhdnpswjZ2zU7xzW+nMKsHf/vWGHeD3UXqI7Cz8 x1ehwKFZu4CalMcoNpw0sSzIrkg3CIRVCydAeH4P7dLeWpWNJo5dpuW+wRwBXALC+sEo dC9g== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t1-20020a170902b20100b001adc74c482asi7301324plr.151.2023.05.29.06.32.16; Mon, 29 May 2023 06:32:28 -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 S229816AbjE2N2P (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767235542867229307?= X-GMAIL-MSGID: =?utf-8?q?1767235542867229307?= Use struct_size() instead of hand-writing it. It is less verbose, more robust and more informative. Signed-off-by: Christophe JAILLET Reviewed-by: Marco Pagani --- 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;