public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Rosen Penev <rosenp@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Patrice Chotard <patrice.chotard@foss.st.com>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	linux-arm-kernel@lists.infradead.org (moderated list:ARM/STI
	ARCHITECTURE)
Subject: [PATCH] reset: sti: kzalloc + kcalloc to kzalloc
Date: Thu, 19 Mar 2026 18:05:17 -0700	[thread overview]
Message-ID: <20260320010517.31917-1-rosenp@gmail.com> (raw)

Simplify allocation.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/reset/sti/reset-syscfg.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/reset/sti/reset-syscfg.c b/drivers/reset/sti/reset-syscfg.c
index 2324060b747c..38f78d78fa4f 100644
--- a/drivers/reset/sti/reset-syscfg.c
+++ b/drivers/reset/sti/reset-syscfg.c
@@ -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;
-- 
2.53.0



             reply	other threads:[~2026-03-20  1:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-20  1:05 Rosen Penev [this message]
2026-03-20  8:16 ` [PATCH] reset: sti: kzalloc + kcalloc to kzalloc Patrice CHOTARD
2026-03-20 10:12 ` Philipp Zabel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260320010517.31917-1-rosenp@gmail.com \
    --to=rosenp@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=patrice.chotard@foss.st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox