Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2753790rwb; Sun, 20 Nov 2022 00:39:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf7753DIpZAR1akP7iQlnFgJHBFaZNmib5FW8sK9W7jhJkdYTwibkoxE3olrsi7VmL+WUmLy X-Received: by 2002:aa7:d816:0:b0:458:4868:814 with SMTP id v22-20020aa7d816000000b0045848680814mr12010343edq.190.1668933594259; Sun, 20 Nov 2022 00:39:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668933594; cv=none; d=google.com; s=arc-20160816; b=zjWqwzgV9LiFjGxhc7ViCsv60xlrt0mlrJSAu1yGilZpjr5a1Pi90aJeBhpiOjnuGr xlXSOeI5cmZjyGaPGPdS2w3uDGb7OY/zG8Yt4WuewzwI2zXAVxIbslRqsqxgppoYidCE VFESWhta4qFKREtll35M/8Cby1y4a5YgWHYRThi/kINPr1lJQ0pGTzYCRuXYnLhlD3xC IlgpSatVLaeUInq7QR7ZkLF04RybRId9NZ1xofL/NCJXVgYLa4ksfSiQgoIQdlDa21GE F0a2mDsWjf5WJrJdp9MK2yjcY0twik/NaspqFnvxufcNwirVu9ZHhosJijnZSpNUCi7c a2SA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o3-20020aa7c503000000b004645d47d9e1si6224891edq.345.2022.11.20.00.39.31; Sun, 20 Nov 2022 00:39:54 -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 + 92 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 Content-Transfer-Encoding: 8bit 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 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 --- 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) { -- 2.34.1