public inbox for dmaengine@vger.kernel.org
 help / color / mirror / Atom feed
From: Rosen Penev <rosenp@gmail.com>
To: dmaengine@vger.kernel.org
Cc: Vinod Koul <vkoul@kernel.org>, Frank Li <Frank.Li@kernel.org>,
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] dmaengine: pl08x: use kzalloc_flex()
Date: Mon,  6 Apr 2026 20:52:10 -0700	[thread overview]
Message-ID: <20260407035210.99085-1-rosenp@gmail.com> (raw)

kzalloc_obj and kzalloc_objs can be combined by changing the array type
to a flexible array member to simplify allocation.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/dma/amba-pl08x.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c
index 5e88fd44812d..255b33064945 100644
--- a/drivers/dma/amba-pl08x.c
+++ b/drivers/dma/amba-pl08x.c
@@ -268,12 +268,12 @@ struct pl08x_dma_chan {
  * @adev: the corresponding AMBA (PrimeCell) bus entry
  * @vd: vendor data for this PL08x variant
  * @pd: platform data passed in from the platform/machine
- * @phy_chans: array of data for the physical channels
  * @pool: a pool for the LLI descriptors
  * @lli_buses: bitmask to or in to LLI pointer selecting AHB port for LLI
  * fetches
  * @mem_buses: set to indicate memory transfers on AHB2.
  * @lli_words: how many words are used in each LLI item for this variant
+ * @phy_chans: array of data for the physical channels
  */
 struct pl08x_driver_data {
 	struct dma_device slave;
@@ -283,11 +283,11 @@ struct pl08x_driver_data {
 	struct amba_device *adev;
 	const struct vendor_data *vd;
 	struct pl08x_platform_data *pd;
-	struct pl08x_phy_chan *phy_chans;
 	struct dma_pool *pool;
 	u8 lli_buses;
 	u8 mem_buses;
 	u8 lli_words;
+	struct pl08x_phy_chan phy_chans[];
 };
 
 /*
@@ -2709,7 +2709,7 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)
 		goto out_no_pl08x;
 
 	/* Create the driver state holder */
-	pl08x = kzalloc_obj(*pl08x);
+	pl08x = kzalloc_flex(*pl08x, phy_chans, vd->channels);
 	if (!pl08x) {
 		ret = -ENOMEM;
 		goto out_no_pl08x;
@@ -2854,13 +2854,6 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)
 		goto out_no_irq;
 	}
 
-	/* Initialize physical channels */
-	pl08x->phy_chans = kzalloc_objs(*pl08x->phy_chans, vd->channels);
-	if (!pl08x->phy_chans) {
-		ret = -ENOMEM;
-		goto out_no_phychans;
-	}
-
 	for (i = 0; i < vd->channels; i++) {
 		struct pl08x_phy_chan *ch = &pl08x->phy_chans[i];
 
@@ -2962,8 +2955,6 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)
 out_no_slave:
 	pl08x_free_virtual_channels(&pl08x->memcpy);
 out_no_memcpy:
-	kfree(pl08x->phy_chans);
-out_no_phychans:
 	free_irq(adev->irq[0], pl08x);
 out_no_irq:
 	dma_pool_destroy(pl08x->pool);
-- 
2.53.0


                 reply	other threads:[~2026-04-07  3:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260407035210.99085-1-rosenp@gmail.com \
    --to=rosenp@gmail.com \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vkoul@kernel.org \
    /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