From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE0383054C4; Mon, 10 Nov 2025 10:38:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762771102; cv=none; b=DJ5O9AgdKZ9UzosunzuntrJb2L2UCHMh6fH0gSJ3Fz09UW1DG6xcKUn+txPV1r4aPGBKWIkxsD72hVc9OuXrVwE2q3Gp0jMsEIhIN59sliySR9jZ9949Z1hUOlR51u3u3DhH8/mglqwl3skugU4LNukfLcdFUJ1BwruNZeujWM0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762771102; c=relaxed/simple; bh=kkqrRlJJXqaQ9jwjs0WWeFbHH6xsAR9/+T+ChQxdAVw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B1uK/I1tPvpahGQ7m8ZXqnhU1RL4bhwrnXWTGbfgAogUGKBhaBRuwRJiBg3otw4a9TZ+KTuEZx+fJ/5KeRxK7NFE5DX+xhxx06orQZ2dCSBF17EybCIQirhjGHXIkczlLYkmH2Qy/gAhld9fKYaK9eFj6JZbmdmvmxJVbK8k/aU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=EEdud+7a; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="EEdud+7a" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1762771101; x=1794307101; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kkqrRlJJXqaQ9jwjs0WWeFbHH6xsAR9/+T+ChQxdAVw=; b=EEdud+7aaAJndyb1uBczArRpOkc4g/SoKY3fhu4egsq+bGm8ayycpyK4 NXDyNT0dft8wVWMWz9nu41CezQuO8TTEmNW0mV0IpbABPHfzaUzF4mJxx ayiBd0T3EbcfeWNlmVtzhkUHcCbyQbwQoLexjz90UuntCqj6+8/npS6RX U4BoEM6GiHT9N0ZjzzklKiHuA/o8BwC05r/3qWTDRUmn5vZzDOj+uUDGv RXe1e14lDi/nV8mpnEeGbwG98tnVO8r6YxcLIG8o9JBJaQQFuBdNIWSPW FBXFTefte/skDfHmLrT/9/4yFD1721pzzC23Fcp/a65jTaIDYOkmsEmgB g==; X-CSE-ConnectionGUID: k4zgXj2QSwCRMSr3YDx+yw== X-CSE-MsgGUID: rjsYyKYbQn+YMi2tuPtiVg== X-IronPort-AV: E=McAfee;i="6800,10657,11608"; a="52376881" X-IronPort-AV: E=Sophos;i="6.19,293,1754982000"; d="scan'208";a="52376881" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2025 02:38:19 -0800 X-CSE-ConnectionGUID: PdOXYKXLT5KWq9LVRRqvJw== X-CSE-MsgGUID: naXh+AdZSgGcfLiJyiM+rg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,293,1754982000"; d="scan'208";a="188891262" Received: from black.igk.intel.com ([10.91.253.5]) by fmviesa008.fm.intel.com with ESMTP; 10 Nov 2025 02:38:13 -0800 Received: by black.igk.intel.com (Postfix, from userid 1003) id 967D19F; Mon, 10 Nov 2025 11:38:07 +0100 (CET) From: Andy Shevchenko To: Andy Shevchenko , Stefan Wahren , Vinod Koul , Thomas Andreatta , Caleb Sander Mateos , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: Olivier Dautricourt , Stefan Roese , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Lars-Peter Clausen , Eugeniy Paltsev , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Lizhi Hou , Brian Xu , Raj Kumar Rampelli , Michal Simek , Andrew Morton Subject: [PATCH v2 10/13] dmaengine: qcom: bam_dma: use sg_nents_for_dma() helper Date: Mon, 10 Nov 2025 11:23:37 +0100 Message-ID: <20251110103805.3562136-11-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251110103805.3562136-1-andriy.shevchenko@linux.intel.com> References: <20251110103805.3562136-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Instead of open coded variant let's use recently introduced helper. Signed-off-by: Andy Shevchenko --- drivers/dma/qcom/bam_dma.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c index 2cf060174795..62b3921f0d11 100644 --- a/drivers/dma/qcom/bam_dma.c +++ b/drivers/dma/qcom/bam_dma.c @@ -655,22 +655,17 @@ static struct dma_async_tx_descriptor *bam_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sg; u32 i; struct bam_desc_hw *desc; - unsigned int num_alloc = 0; - + unsigned int num_alloc; if (!is_slave_direction(direction)) { dev_err(bdev->dev, "invalid dma direction\n"); return NULL; } - /* calculate number of required entries */ - for_each_sg(sgl, sg, sg_len, i) - num_alloc += DIV_ROUND_UP(sg_dma_len(sg), BAM_FIFO_SIZE); - /* allocate enough room to accommodate the number of entries */ + num_alloc = sg_nents_for_dma(sgl, sg_len, BAM_FIFO_SIZE); async_desc = kzalloc(struct_size(async_desc, desc, num_alloc), GFP_NOWAIT); - if (!async_desc) return NULL; -- 2.50.1