From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 625B6374E57 for ; Tue, 7 Apr 2026 03:52:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775533952; cv=none; b=hdowivUJaobN8tPixbSVCug6bf5Lcv8fi4MApdfkb4ErIXh3ODDMVnLCkzUtv6ViWX6WIphyODwzRtKDDvJLSG51yocgw4Q3rP/vgCMfM5B+/SH3MNgkkm1yCYQkaM57JuVSnlyWhU6eQiubrYcwx82Z9bnRgBEoxC4dlI2Ys88= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775533952; c=relaxed/simple; bh=hWTqrbgs6Ynu8w+0/oInRnFbfmZqm7O0l+BAT/oCoac=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=DaLwTy8ZsiP2XU1Q8WdREU3wCdJT99SkmxVdhmuPDwRFD4ieygffEjqcoNm5ULefvdcRD6kMPvoKS1t6sGs9VpYaENe7a/2LQVmoyeEtKZg1/tD2CH/YzLFM8n2Ow7HLUq5N38gL8lOgW/2+LN3m33PqIInU627M34Y0GKjlYzc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ohFNyTwp; arc=none smtp.client-ip=209.85.222.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ohFNyTwp" Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-8d65f4073bfso362240185a.3 for ; Mon, 06 Apr 2026 20:52:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775533948; x=1776138748; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=MqMWReHNfBZQ1cD4RbW3GJ+O9AwhazTgpk4nLCPXKWQ=; b=ohFNyTwpi5Tvc7uwHySSIle/sRaBmd22CfFhvUNx/xpplRQC5ZdGvejTK2n9Iy5STL JCwbiTnJ1ECJQhLbWPTO9mvvz1tbpQzbN1fP+mjBrl0Kd+ztwVrrxnXd6IJC00MMSVw1 r/AHG0E4Ynzmjl8U3nUMuUtAn3pkRo6n89SgWaHQJPO+T4LxxvnatJYxGTiw3NOYD5br mxbfbzY+EfwpJpr1tEHKPNKo5hytS4YX6OqxJiLN4hhJZPZwurxeDIge23xbqEi5t2S7 s/zI+gK42i49tKb1ikm9Of+Ga5dYS6z7gnGJj47KF+a722BAVi3tkRyv41mXIgEYQRdg Z+rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775533948; x=1776138748; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MqMWReHNfBZQ1cD4RbW3GJ+O9AwhazTgpk4nLCPXKWQ=; b=YSR+NuRM1+/6cYXdEmJnGnskxxfVY+ic6IDY4mLAJHpW04K3wbcuERiCZX2JTDYOj7 lgLEljAtBLaC7EDwXzXWq1J3sKcUtCPOcgnK9Yjva0nTNDY1GF8meXsyb03N0ZTsA+0l rAPvfszTWv/z/c2dJBFXVaIPSJYIT0QEaINhGL/Q4kpF3lKZf3tDjSYsMUTwroXmX2WM 2+JbNbEydjTdyFTINGQ4rSKv5BoQbs2YsOdTyNfwxwRk55vcbR8VBKIEhuXFllD4A/77 aNgyGAi28IfVW1O+vj0pOZxH9mIIswM0MFPuQ0LBLQ8ZzdTmkMie/iQhzxCRij/bKpWh YKTg== X-Forwarded-Encrypted: i=1; AJvYcCVd0o/03x5mMvrhUvPQhWaIFargWE7lfy4GCpEwXdhQVvITc0I8VXrCdiGRQKs1lKU2Zfy1giTBiH1TAV4=@vger.kernel.org X-Gm-Message-State: AOJu0Yzpt8UTCYeq5FulZQuoXPnxP1e9jUldCH7K5Bj4zrOuX9Bmh5Mo s2vQhTmEcnRQZUQ4/HL1iPHfhboZ1s00TAMRVNXvdNNmCaeyj5u937dR X-Gm-Gg: AeBDiesELE6e0NRK2QdE+pnJc5I8XtPUi26/FnX026izwLhZATDrEotBmO6dixvhhgD OCLoBby6AEfbRLsg60d5/0UXcTfzKZiu6tW1rHnUy6zmLCaKPYX2Rnw6Nk4uRjE3ZwxYSQKJg9U RJB7Sv4ow6HI81We4s71HNMTSTWHIiS29CsYvQfWRvX1j+XsPnb4jWmt0NdE/l3FliUSKqLeC9X 48G2x3jRid1dg7oX5YWNw0zFjLYhMBPsUh6KPPbEGrvDWnXeDZZFPmxKyK7noZkNkDwoIbs6KK1 h6uU2RdE4fZOvICAsKO2UIPr75sg/w3+TKE5HetJKb1JDpbZhclMMEWdkZ06rgtK8XQ7a9/Myvh de8S1izWOeGHybjh/Nl4VZj9YF97t8LGiCFY/yxv3UvszeKiDe4MyYx+BadIjXsSpbYqKAa1jNE dC4s3c6v9jGArRljBbul0sXD45A24pJ8IFxKnzk/21EyO8xB7dbfhi5YigYXjMg2Cm+Q== X-Received: by 2002:a05:620a:4104:b0:8cf:d3a9:60ea with SMTP id af79cd13be357-8d419961f7bmr2287785185a.26.1775533948373; Mon, 06 Apr 2026 20:52:28 -0700 (PDT) Received: from ryzen ([2601:644:8000:5b5d::8bd]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8d5e69afdb6sm687935285a.40.2026.04.06.20.52.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2026 20:52:27 -0700 (PDT) From: Rosen Penev To: dmaengine@vger.kernel.org Cc: Vinod Koul , Frank Li , linux-kernel@vger.kernel.org (open list) Subject: [PATCH] dmaengine: pl08x: use kzalloc_flex() Date: Mon, 6 Apr 2026 20:52:10 -0700 Message-ID: <20260407035210.99085-1-rosenp@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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