From patchwork Sat May 6 16:22:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 90782 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1161801vqo; Sat, 6 May 2023 10:06:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ulmYm3mAbJED2IZzZkpiPrirGqUBOX3vq8TU90I98AG/2l0J0/0/vFM4OAMXT7zXpwb/M X-Received: by 2002:a17:902:7295:b0:1a2:6257:36b9 with SMTP id d21-20020a170902729500b001a2625736b9mr4886679pll.31.1683392771435; Sat, 06 May 2023 10:06:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683392771; cv=none; d=google.com; s=arc-20160816; b=XvhbJ/EpiGuwW18+gA4IeZvaWWcnVfEgR/bIdpzqZwWdYrVb5aMsji2DChij/cSYE+ KRVuWc85XQsTJQ5bhAaQZLq3Tc2s2gkTf43cOia8DkgAQNsfiuTa86Vi2RTcRYnUytzY 5ME1xtdJeCwyfioFdKXZUFDIkKTV8lCdK77J/nKRT6qxQjZ5mFMNkPWMkf2JQn0hQgeC F6v13J5nQum2FiDuvNTV36aIQ03mtjQ63Wghw/cSVMXJt7GOKym/YKPurqFOkfj7/0co +m2h4QpOVB//IXP3wm4/o927iSPq1mhAPrQBJx/hJNLwlKJPIHx13wakDf5BuiVEjUwP XijQ== 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=tQOt5gblo50yrL9JEVMTC1Kl+IqfyNk1DzG+I68m8IY=; b=QV5vKnXG+XU3/rWd/Ky/4Jowgn3+g35QQbxF2+IF2MdWi605MYK3csZ/WOXoDyPFYx JlVoklkdu9gGiY09hnsBSE0/4RER2EImDTtYKTLABtEP/L2U6To/68TnHSidaXep7ZVx UISxA62jq15UxeL79diZ+eRMn+i84l778yMvWcPOgYxq8uhX85HTT4ISlglPizPX4W5C PL5q3/O+LRbd3X46eA3SdSMSKPyJzK9suyCc/u5d1P8qn/QQiafnqrBJZQdUQfQH8cFg eLVW/QUc+7RJ6bL4lDe+O6no43sjEamwOX6/A9n2NNJ2tcUBnoGuF3GapSF3LEFRQlqj xpwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=p94vS1C8; 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 h7-20020a170902748700b0019a96849d6dsi4020983pll.605.2023.05.06.10.05.40; Sat, 06 May 2023 10:06:11 -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=p94vS1C8; 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 S229655AbjEFQWP (ORCPT + 99 others); Sat, 6 May 2023 12:22:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbjEFQWL (ORCPT ); Sat, 6 May 2023 12:22:11 -0400 Received: from smtp.smtpout.orange.fr (smtp-21.smtpout.orange.fr [80.12.242.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BAB61157B for ; Sat, 6 May 2023 09:22:10 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id vKfgpvoXUU7B5vKfgpeMVi; Sat, 06 May 2023 18:22:08 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1683390128; bh=tQOt5gblo50yrL9JEVMTC1Kl+IqfyNk1DzG+I68m8IY=; h=From:To:Cc:Subject:Date; b=p94vS1C8N7HOUEeVIz25beGwN21Adr6ZEyGrZH1UiycC2XTuLJfojX0oAmsxnfUTG K6Bn6vSB4JOcVBKwZvms6vjwwMB5tkSZO0oQBB30wqDI/KIZWuNYkq3lHSJVlfKWOW QLgcKeEQ2HhdDzGIuuOQ3GB4He4KFEFb0PjUZq5rY6od5MLPQXJm2Xxr8IYh2EiDh+ wg02zCSDzpiJ8xnx0Nqo5XvFu7iXUGxMiqY8p0KP0GIX5LNljM4h6SWX2V88tH0YsG CZdvRYpRcnyiWCRZmwo7Fky/mq9mv4fQWPxCpV7XpqompwmJQ1vbskmotOrahPl815 KaRIfIk+Rg2Eg== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 06 May 2023 18:22:08 +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: mcf-edma: Use struct_size() Date: Sat, 6 May 2023 18:22:06 +0200 Message-Id: <97c2bb1c9b69d0739da3762a7752ae6582c4ad02.1683390112.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, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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?1765165258344750911?= X-GMAIL-MSGID: =?utf-8?q?1765165258344750911?= Use struct_size() instead of hand writing it. This is less verbose and more informative. 'mcf_chan' is now unused and can be removed. In fact, it is shadowed by another variable in the 'for' loop below. Keep this one. Signed-off-by: Christophe JAILLET --- It will also help scripts when __counted_by macro will be added. See [1]. [1]: https://lore.kernel.org/all/6453f739.170a0220.62695.7785@mx.google.com/ --- drivers/dma/mcf-edma.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/dma/mcf-edma.c b/drivers/dma/mcf-edma.c index ebd8733f72ad..28304dd8763a 100644 --- a/drivers/dma/mcf-edma.c +++ b/drivers/dma/mcf-edma.c @@ -180,9 +180,8 @@ static int mcf_edma_probe(struct platform_device *pdev) { struct mcf_edma_platform_data *pdata; struct fsl_edma_engine *mcf_edma; - struct fsl_edma_chan *mcf_chan; struct edma_regs *regs; - int ret, i, len, chans; + int ret, i, chans; pdata = dev_get_platdata(&pdev->dev); if (!pdata) { @@ -191,8 +190,8 @@ static int mcf_edma_probe(struct platform_device *pdev) } chans = pdata->dma_channels; - len = sizeof(*mcf_edma) + sizeof(*mcf_chan) * chans; - mcf_edma = devm_kzalloc(&pdev->dev, len, GFP_KERNEL); + mcf_edma = devm_kzalloc(&pdev->dev, struct_size(mcf_edma, chans, chans), + GFP_KERNEL); if (!mcf_edma) return -ENOMEM;