]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
reset: sti: kzalloc + kcalloc to kzalloc
authorRosen Penev <rosenp@gmail.com>
Fri, 20 Mar 2026 01:05:17 +0000 (18:05 -0700)
committerPhilipp Zabel <p.zabel@pengutronix.de>
Fri, 20 Mar 2026 09:53:51 +0000 (10:53 +0100)
Simplify allocation.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
drivers/reset/sti/reset-syscfg.c

index 2324060b747c863cb896f467a19c54b721ebf7d2..38f78d78fa4fb247f2fcc1d8fa431854d92c46ba 100644 (file)
@@ -41,7 +41,7 @@ struct syscfg_reset_channel {
 struct syscfg_reset_controller {
        struct reset_controller_dev rst;
        bool active_low;
-       struct syscfg_reset_channel *channels;
+       struct syscfg_reset_channel channels[];
 };
 
 #define to_syscfg_reset_controller(_rst) \
@@ -135,15 +135,10 @@ static int syscfg_reset_controller_register(struct device *dev,
        struct syscfg_reset_controller *rc;
        int i, err;
 
-       rc = devm_kzalloc(dev, sizeof(*rc), GFP_KERNEL);
+       rc = devm_kzalloc(dev, struct_size(rc, channels, data->nr_channels), GFP_KERNEL);
        if (!rc)
                return -ENOMEM;
 
-       rc->channels = devm_kcalloc(dev, data->nr_channels,
-                                   sizeof(*rc->channels), GFP_KERNEL);
-       if (!rc->channels)
-               return -ENOMEM;
-
        rc->rst.ops = &syscfg_reset_ops;
        rc->rst.of_node = dev->of_node;
        rc->rst.nr_resets = data->nr_channels;