From patchwork Sun Nov 20 08:25:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 23387 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1027998wrr; Sun, 20 Nov 2022 00:31:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf7lwCudeFRwdI8ce5ZYOpt6c1esTLJKbyhOlhrCawYPMZTUZjXHCQLHcS2rG+6m+vZ6h7qh X-Received: by 2002:a17:902:e294:b0:17c:620f:13ac with SMTP id o20-20020a170902e29400b0017c620f13acmr4734502plc.9.1668933097485; Sun, 20 Nov 2022 00:31:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668933097; cv=none; d=google.com; s=arc-20160816; b=xLN5A2YDyw5aZbHiO02Y7NiNKz64atP0oqh/C++RPoMFrOVfCm3ThHwK8d4W1zWiJ/ Y10xmXvEW/AFKHS+NjVH6rl6PXK1W+K/IanR0875oehlRLJMdxFvM8WPMR9GWwcz83sc ultVNy03zblzRBhzZoPVbI2nNWApJ+/WF7h2TVjQ5zlkL95tb2DjQk0wTU/XdtIMMO6T OZPBCVdLy+YxVDUh7w5SF0KsDVus/xssrmCEs5lqITUlwLAhAxTaIgM9goXbLNH8XsLk CYVLpzHaboEJ9OR7S/6DYpClA7FpNXoi0FfGSb3nSEpnBsuM12Q5z7ggfqtf9d/CQBUr 6U5w== 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; bh=HF56tP+8O9FgiKvYZILuajPBTxtZLbMSHNxXHbP6XEo=; b=PnUEj6b94PaXld7rSJ2SxCVd6lLaZp5hj77M4i+5MAQN9LmDg8mb0TLqQULc6LPnzL x6fGprOiXITo3VpfnpyYz9Fn8/RpsURgbfZiHhkXGUjNJvvFECpRJBQkneokyyttIIEi AjFZwJH1WEYDDpoKYBMBvXiUwE8QG+9V9fQnAPwM3kbCqlxKZfFxbQCbidHIastbYSUh 2x69UkgDfhvttd2h7KIbvSF6j4reSAd3tv8jPJvR3DdF2hcRMXH1sK8PvZgnVhprWiWC 8HtpBITvLoStRf1s8/cN9RhqSQ9vA5nKqPlyREpONJvf5SfUIhA+r6Lv1DjS/x95R9Fw XfQQ== ARC-Authentication-Results: i=1; mx.google.com; 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 pv16-20020a17090b3c9000b001fd9be4fb6csi11491554pjb.39.2022.11.20.00.31.24; Sun, 20 Nov 2022 00:31:37 -0800 (PST) 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; 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 S229446AbiKTI0P (ORCPT + 99 others); Sun, 20 Nov 2022 03:26:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbiKTI0D (ORCPT ); Sun, 20 Nov 2022 03:26:03 -0500 Received: from smtp.smtpout.orange.fr (smtp-29.smtpout.orange.fr [80.12.242.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57D5E2B632 for ; Sun, 20 Nov 2022 00:26:02 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id wfeJoeBiaNKuIwfeJoF2Sw; Sun, 20 Nov 2022 09:26:00 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 20 Nov 2022 09:26:00 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET To: Jassi Brar , Michal Simek Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-arm-kernel@lists.infradead.org Subject: [PATCH] mailbox: zynq: Switch to flexible array to simplify code Date: Sun, 20 Nov 2022 09:25:54 +0100 Message-Id: <3c21e60417a0b57e7a80976b786726048119b5cf.1668932733.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS 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?1750003191787289089?= X-GMAIL-MSGID: =?utf-8?q?1750003191787289089?= Using flexible array is more straight forward. It - saves 1 pointer in the 'zynqmp_ipi_pdata' structure - saves an indirection when using this array - saves some LoC and avoids some always spurious pointer arithmetic Signed-off-by: Christophe JAILLET Reviewed-by: Tanmay Shah --- Compile tested only --- drivers/mailbox/zynqmp-ipi-mailbox.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/mailbox/zynqmp-ipi-mailbox.c b/drivers/mailbox/zynqmp-ipi-mailbox.c index 31a0fa914274..68e5726f5157 100644 --- a/drivers/mailbox/zynqmp-ipi-mailbox.c +++ b/drivers/mailbox/zynqmp-ipi-mailbox.c @@ -110,7 +110,7 @@ struct zynqmp_ipi_pdata { unsigned int method; u32 local_id; int num_mboxes; - struct zynqmp_ipi_mbox *ipi_mboxes; + struct zynqmp_ipi_mbox ipi_mboxes[]; }; static struct device_driver zynqmp_ipi_mbox_driver = { @@ -633,7 +633,7 @@ static int zynqmp_ipi_probe(struct platform_device *pdev) int num_mboxes, ret = -EINVAL; num_mboxes = of_get_child_count(np); - pdata = devm_kzalloc(dev, sizeof(*pdata) + (num_mboxes * sizeof(*mbox)), + pdata = devm_kzalloc(dev, struct_size(pdata, ipi_mboxes, num_mboxes), GFP_KERNEL); if (!pdata) return -ENOMEM; @@ -647,8 +647,6 @@ static int zynqmp_ipi_probe(struct platform_device *pdev) } pdata->num_mboxes = num_mboxes; - pdata->ipi_mboxes = (struct zynqmp_ipi_mbox *) - ((char *)pdata + sizeof(*pdata)); mbox = pdata->ipi_mboxes; for_each_available_child_of_node(np, nc) {