From patchwork Sat Jul 22 15:58:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 124347 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp911385vqg; Sat, 22 Jul 2023 10:29:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlHPJMmykeNBfLzeu/3qL3eOD/Aw7HqpWTDiWHeXrkGAzhsW+ueDSeVKm/efXSqh9ip4Uy7f X-Received: by 2002:a17:906:1c5:b0:993:db29:d27d with SMTP id 5-20020a17090601c500b00993db29d27dmr4978666ejj.34.1690046983569; Sat, 22 Jul 2023 10:29:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690046983; cv=none; d=google.com; s=arc-20160816; b=iaS/D4QpYfHRdYG0QzRR6C4fjNy5aqPHNDTYUSbHupmyykgTKn45naTFNt28RayJ1/ FFZeEcELxaL5GBB5HlLjiBOSURnUwEpIQ9o25PTMVkmdTzDU1xTE6jp4rt01l0403uTd fxH0sBK3ZSp+PskA0eJya0kmDadi5Z9kJTCHRcjGmrajeDo8iAWzVHPyd5MeDVkCSlxc jW25mpDrz/Qax7OGNQJaqgnxl8O69/ef6dv/cfeXsf9ZmayWxY8iCM6aLPEC12YD+SHQ IyCyF3lzYFhNvfM7fwHMLEmKrGU2+dbdD428bEp7Vay830Ib3S9vKFWp5+FGJ5zP2XWJ 7MKg== 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=7h7BXIi417HcJ7IVXgwp14lvQ+AKlv7jQenrpvVP09g=; fh=i8G5BnjWFRJqvad7pNlv/p/EJT8IahK5x7u38tUQkdw=; b=EnLEHDuR3v6AYRuCvZDjpg8uPe17U42hxyYpm9ab5YWfB8rGyScWfuoFLk3+xwaZWT 7lwUt3Wlkl464I4L942IGF2jSWXRjljihGlTg0tK0oYuiBWOTmE9i4DAvxyd4jTKnKIi VpZqh3qAOcIIyPv7wxjoR6tbHPr3E3VaKrVbmxX5qzJ7eNtl/c8LRPU10bpY1vNZb/kY vcqg5wtdxx0aRMT+nOcML/bZ5UTBdBiX+UdbP/C5q/X0f6Tkoxqv8NY0GUlpuGQvOVhE LrbU7Ph4Gwkk2O0Ljr8GSpC7gHs4AbNdDERVRNz/b1s6oVAnb0yf4p9w+UKP8bfN+90G qqGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=Inif3SLu; 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 u10-20020a170906b10a00b00992fef51a60si3470020ejy.525.2023.07.22.10.29.20; Sat, 22 Jul 2023 10:29:43 -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=Inif3SLu; 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 S230049AbjGVP66 (ORCPT + 99 others); Sat, 22 Jul 2023 11:58:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbjGVP6z (ORCPT ); Sat, 22 Jul 2023 11:58:55 -0400 Received: from smtp.smtpout.orange.fr (smtp-18.smtpout.orange.fr [80.12.242.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3151A2727 for ; Sat, 22 Jul 2023 08:58:51 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id NF0FqBMdqoFSdNF0FqaSjc; Sat, 22 Jul 2023 17:58:44 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1690041524; bh=7h7BXIi417HcJ7IVXgwp14lvQ+AKlv7jQenrpvVP09g=; h=From:To:Cc:Subject:Date; b=Inif3SLu+aoCjx+IQwQ8bAKNRAckAT1iVU7BanPLRxUxwWZsLpC7aoyXtMKoH/Vwy cq/2OA/xgdpvLghZeidgSATaYfAj0zWhzd8R+HwoQx62WW2l08Z8W0Z4AHXwDnAA8z 7JhBU77Eb3GkIHabjaIdYnFDcfleWLcD9NMuDVz+0V/xaBwi/rAcTAGxHowPwLOU9C K7f4J5QcvB7eDpO4q8OmrY0bIChH9mCrM4VNQyUlY+8Irm/U2QJGFqNr2GhcXU7juR YMLJ2/XVkDMFuaC2omqfBoYEgJQKY9jr037SqSgDijIDi9Ak7ac+2wBfAri8ZHw36e ogdxX4dc4I6PA== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 22 Jul 2023 17:58:44 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Vinod Koul Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , dmaengine@vger.kernel.org Subject: [PATCH] dmaengine: ep93xx: Use struct_size() Date: Sat, 22 Jul 2023 17:58:40 +0200 Message-Id: <36fa11d95b448b5f3f1677da41fe35b9e2751427.1690041500.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_BLOCKED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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: INBOX X-GMAIL-THRID: 1772142705727020239 X-GMAIL-MSGID: 1772142705727020239 Use struct_size() instead of hand-writing it, when allocating a structure with a flex array. This is less verbose, more robust and more informative. Signed-off-by: Christophe JAILLET --- It will also be helpful if the __counted_by() annotation is added with a Coccinelle script such as: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?h=devel/counted_by&id=adc5b3cb48a049563dc673f348eab7b6beba8a9b --- drivers/dma/ep93xx_dma.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/dma/ep93xx_dma.c b/drivers/dma/ep93xx_dma.c index 5338a94f1a69..5c4a448a1254 100644 --- a/drivers/dma/ep93xx_dma.c +++ b/drivers/dma/ep93xx_dma.c @@ -1320,11 +1320,9 @@ static int __init ep93xx_dma_probe(struct platform_device *pdev) struct ep93xx_dma_platform_data *pdata = dev_get_platdata(&pdev->dev); struct ep93xx_dma_engine *edma; struct dma_device *dma_dev; - size_t edma_size; int ret, i; - edma_size = pdata->num_channels * sizeof(struct ep93xx_dma_chan); - edma = kzalloc(sizeof(*edma) + edma_size, GFP_KERNEL); + edma = kzalloc(struct_size(edma, channels, pdata->num_channels), GFP_KERNEL); if (!edma) return -ENOMEM;