regulator: da9063: kzalloc + kcalloc to kzalloc
PATCH 1/1 regulator: da9063: kzalloc + kcalloc to kzalloc
Reduce main allocation to a single kzalloc call by using a flexible array member.
Allows using __counted_by for extra runtime analysis.
--- drivers/regulator/da9063-regulator.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/regulator/da9063-regulator.c +2 -7
@@ -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 ;
Signature · 1 line
2.53.0
Mark Brown
maintainerQuoted 1 line · Rosen Penev
regulator: da9063: kzalloc + kcalloc to kzalloc
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-7.1
Thanks!
[1/1] regulator: da9063: kzalloc + kcalloc to kzalloc
https://git.kernel.org/broonie/misc/c/cf4812898b58
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark