public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pmdomain: qcom: cpr: simplify main allocation
@ 2026-03-15 21:41 Rosen Penev
  2026-03-17 11:52 ` Konrad Dybcio
  2026-03-18 18:22 ` Ulf Hansson
  0 siblings, 2 replies; 3+ messages in thread
From: Rosen Penev @ 2026-03-15 21:41 UTC (permalink / raw)
  To: linux-pm
  Cc: Bjorn Andersson, Konrad Dybcio, Ulf Hansson,
	open list:QUALCOMM CORE POWER REDUCTION (CPR) AVS DRIVER,
	open list

Remove kcalloc by using a flexible array member to combine allocations.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/pmdomain/qcom/cpr.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/pmdomain/qcom/cpr.c b/drivers/pmdomain/qcom/cpr.c
index 3ee8184e4be3..c30690ef6919 100644
--- a/drivers/pmdomain/qcom/cpr.c
+++ b/drivers/pmdomain/qcom/cpr.c
@@ -239,7 +239,6 @@ struct cpr_drv {
 	u32			gcnt;
 	unsigned long		flags;
 
-	struct fuse_corner	*fuse_corners;
 	struct corner		*corners;
 
 	const struct cpr_desc *desc;
@@ -247,6 +246,8 @@ struct cpr_drv {
 	const struct cpr_fuse *cpr_fuses;
 
 	struct dentry *debugfs;
+
+	struct fuse_corner	fuse_corners[];
 };
 
 static bool cpr_is_allowed(struct cpr_drv *drv)
@@ -1600,19 +1601,15 @@ static int cpr_probe(struct platform_device *pdev)
 	if (!data || !data->cpr_desc || !data->acc_desc)
 		return -EINVAL;
 
-	drv = devm_kzalloc(dev, sizeof(*drv), GFP_KERNEL);
+	drv = devm_kzalloc(dev,
+			struct_size(drv, fuse_corners, data->cpr_desc->num_fuse_corners),
+			GFP_KERNEL);
 	if (!drv)
 		return -ENOMEM;
 	drv->dev = dev;
 	drv->desc = data->cpr_desc;
 	drv->acc_desc = data->acc_desc;
 
-	drv->fuse_corners = devm_kcalloc(dev, drv->desc->num_fuse_corners,
-					 sizeof(*drv->fuse_corners),
-					 GFP_KERNEL);
-	if (!drv->fuse_corners)
-		return -ENOMEM;
-
 	np = of_parse_phandle(dev->of_node, "acc-syscon", 0);
 	if (!np)
 		return -ENODEV;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] pmdomain: qcom: cpr: simplify main allocation
  2026-03-15 21:41 [PATCH] pmdomain: qcom: cpr: simplify main allocation Rosen Penev
@ 2026-03-17 11:52 ` Konrad Dybcio
  2026-03-18 18:22 ` Ulf Hansson
  1 sibling, 0 replies; 3+ messages in thread
From: Konrad Dybcio @ 2026-03-17 11:52 UTC (permalink / raw)
  To: Rosen Penev, linux-pm
  Cc: Bjorn Andersson, Konrad Dybcio, Ulf Hansson,
	open list:QUALCOMM CORE POWER REDUCTION (CPR) AVS DRIVER,
	open list

On 3/15/26 10:41 PM, Rosen Penev wrote:
> Remove kcalloc by using a flexible array member to combine allocations.
> 
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

Konrad

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] pmdomain: qcom: cpr: simplify main allocation
  2026-03-15 21:41 [PATCH] pmdomain: qcom: cpr: simplify main allocation Rosen Penev
  2026-03-17 11:52 ` Konrad Dybcio
@ 2026-03-18 18:22 ` Ulf Hansson
  1 sibling, 0 replies; 3+ messages in thread
From: Ulf Hansson @ 2026-03-18 18:22 UTC (permalink / raw)
  To: Rosen Penev
  Cc: linux-pm, Bjorn Andersson, Konrad Dybcio,
	open list:QUALCOMM CORE POWER REDUCTION (CPR) AVS DRIVER,
	open list

On Sun, 15 Mar 2026 at 22:42, Rosen Penev <rosenp@gmail.com> wrote:
>
> Remove kcalloc by using a flexible array member to combine allocations.
>
> Signed-off-by: Rosen Penev <rosenp@gmail.com>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/pmdomain/qcom/cpr.c | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/pmdomain/qcom/cpr.c b/drivers/pmdomain/qcom/cpr.c
> index 3ee8184e4be3..c30690ef6919 100644
> --- a/drivers/pmdomain/qcom/cpr.c
> +++ b/drivers/pmdomain/qcom/cpr.c
> @@ -239,7 +239,6 @@ struct cpr_drv {
>         u32                     gcnt;
>         unsigned long           flags;
>
> -       struct fuse_corner      *fuse_corners;
>         struct corner           *corners;
>
>         const struct cpr_desc *desc;
> @@ -247,6 +246,8 @@ struct cpr_drv {
>         const struct cpr_fuse *cpr_fuses;
>
>         struct dentry *debugfs;
> +
> +       struct fuse_corner      fuse_corners[];
>  };
>
>  static bool cpr_is_allowed(struct cpr_drv *drv)
> @@ -1600,19 +1601,15 @@ static int cpr_probe(struct platform_device *pdev)
>         if (!data || !data->cpr_desc || !data->acc_desc)
>                 return -EINVAL;
>
> -       drv = devm_kzalloc(dev, sizeof(*drv), GFP_KERNEL);
> +       drv = devm_kzalloc(dev,
> +                       struct_size(drv, fuse_corners, data->cpr_desc->num_fuse_corners),
> +                       GFP_KERNEL);
>         if (!drv)
>                 return -ENOMEM;
>         drv->dev = dev;
>         drv->desc = data->cpr_desc;
>         drv->acc_desc = data->acc_desc;
>
> -       drv->fuse_corners = devm_kcalloc(dev, drv->desc->num_fuse_corners,
> -                                        sizeof(*drv->fuse_corners),
> -                                        GFP_KERNEL);
> -       if (!drv->fuse_corners)
> -               return -ENOMEM;
> -
>         np = of_parse_phandle(dev->of_node, "acc-syscon", 0);
>         if (!np)
>                 return -ENODEV;
> --
> 2.53.0
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-18 18:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-15 21:41 [PATCH] pmdomain: qcom: cpr: simplify main allocation Rosen Penev
2026-03-17 11:52 ` Konrad Dybcio
2026-03-18 18:22 ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox