public inbox for dmaengine@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dmaengine: pl08x: use kzalloc_flex()
@ 2026-04-07  3:52 Rosen Penev
  0 siblings, 0 replies; only message in thread
From: Rosen Penev @ 2026-04-07  3:52 UTC (permalink / raw)
  To: dmaengine; +Cc: Vinod Koul, Frank Li, open list

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-04-07  3:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-07  3:52 [PATCH] dmaengine: pl08x: use kzalloc_flex() Rosen Penev

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