From: Rosen Penev <rosenp@gmail.com>
To: dri-devel@linux-kernel@vger.kernel.org
Cc: Support Opensource <support.opensource@diasemi.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
linux-kernel@vger.kernel.org (open list:VOLTAGE AND CURRENT
REGULATOR FRAMEWORK),
linux-hardening@vger.kernel.org (open list:KERNEL HARDENING (not
covered by other areas):Keyword:\b__counted_by(_le|_be)?\b)
Subject: [PATCH] regulator: da9063: kzalloc + kcalloc to kzalloc
Date: Tue, 10 Mar 2026 17:41:59 -0700 [thread overview]
Message-ID: <20260311004159.32374-1-rosenp@gmail.com> (raw)
Reduce main allocation to a single kzalloc call by using a flexible
array member.
Allows using __counted_by for extra runtime analysis.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/regulator/da9063-regulator.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c
index 9d369cc45d41..bf34ea440d77 100644
--- a/drivers/regulator/da9063-regulator.c
+++ b/drivers/regulator/da9063-regulator.c
@@ -67,7 +67,7 @@ struct da9063_regulator_data {
struct da9063_regulators_pdata {
unsigned int n_regulators;
- struct da9063_regulator_data *regulator_data;
+ struct da9063_regulator_data regulator_data[] __counted_by(n_regulators);
};
/* Regulator capabilities and registers description */
@@ -857,15 +857,10 @@ static struct da9063_regulators_pdata *da9063_parse_regulators_dt(
return ERR_PTR(-EINVAL);
}
- pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+ pdata = devm_kzalloc(&pdev->dev, struct_size(pdata, regulator_data, num), GFP_KERNEL);
if (!pdata)
return ERR_PTR(-ENOMEM);
- pdata->regulator_data = devm_kcalloc(&pdev->dev,
- num, sizeof(*pdata->regulator_data),
- GFP_KERNEL);
- if (!pdata->regulator_data)
- return ERR_PTR(-ENOMEM);
pdata->n_regulators = num;
n = 0;
--
2.53.0
next reply other threads:[~2026-03-11 0:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-11 0:41 Rosen Penev [this message]
2026-03-14 21:58 ` [PATCH] regulator: da9063: kzalloc + kcalloc to kzalloc Mark Brown
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=20260311004159.32374-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=broonie@kernel.org \
--cc=dri-devel@linux-kernel \
--cc=gustavoars@kernel.org \
--cc=kees@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=support.opensource@diasemi.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