]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mailbox: rockchip: kzalloc + kcalloc to kzalloc
authorRosen Penev <rosenp@gmail.com>
Wed, 11 Mar 2026 00:37:44 +0000 (17:37 -0700)
committerJassi Brar <jassisinghbrar@gmail.com>
Sun, 29 Mar 2026 15:50:05 +0000 (10:50 -0500)
Use a flexible array member to reduce allocations.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>
drivers/mailbox/rockchip-mailbox.c

index 4d966cb2ed03673106bb4d41df90c2a6fda33c46..a1a7dee643567cc4e108c03d5b1ec5450c36b11a 100644 (file)
@@ -46,7 +46,7 @@ struct rockchip_mbox {
        /* The maximum size of buf for each channel */
        u32 buf_size;
 
-       struct rockchip_mbox_chan *chans;
+       struct rockchip_mbox_chan chans[];
 };
 
 static int rockchip_mbox_send_data(struct mbox_chan *chan, void *data)
@@ -173,15 +173,10 @@ static int rockchip_mbox_probe(struct platform_device *pdev)
 
        drv_data = (const struct rockchip_mbox_data *) device_get_match_data(&pdev->dev);
 
-       mb = devm_kzalloc(&pdev->dev, sizeof(*mb), GFP_KERNEL);
+       mb = devm_kzalloc(&pdev->dev, struct_size(mb, chans, drv_data->num_chans), GFP_KERNEL);
        if (!mb)
                return -ENOMEM;
 
-       mb->chans = devm_kcalloc(&pdev->dev, drv_data->num_chans,
-                                sizeof(*mb->chans), GFP_KERNEL);
-       if (!mb->chans)
-               return -ENOMEM;
-
        mb->mbox.chans = devm_kcalloc(&pdev->dev, drv_data->num_chans,
                                      sizeof(*mb->mbox.chans), GFP_KERNEL);
        if (!mb->mbox.chans)