Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1237737pxb; Fri, 21 Jan 2022 13:04:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrasVfxqzarpMvpWsP+Ee+LnLs0cAF5S8L5PDhvEIFP26NNiWb8I5PZtFQHapDzHD8EbIl X-Received: by 2002:a63:e70b:: with SMTP id b11mr4188164pgi.203.1642799064261; Fri, 21 Jan 2022 13:04:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642799064; cv=none; d=google.com; s=arc-20160816; b=bKF11PPvhH5pu9FJ+Wh2jNXVcmeoMFNBxtAOYxQQ5roklblk9apMqTc4DWmoiu9J1p Y5LeLUd8ehK3swUxcaXSoiI1ra0CDQUAORbrHSnJmaMh42E/Iqu6U5PswdcPIBmn2BoH KZGiCzV7zxn+GPIcgBqtV5Pa613DlU0B3n1iNle4yQqkUWAcif1fFqIV7aWULf+CvAyh 2me+DZ8OGtq4wKHzMvs9jPRmhEul3Zvih6Oclu/uCufR9m0rDsNHsLhR4jc7T2oGdNJ3 1gX+QTwofdS0jWc/mYx52jluOdLxE9HLrOMCWNJNiPHu4L8GU442GjwRxsn8TnOLrRLH zpog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:to:from; bh=7YOXm7sNJhxTZNnw7CDiOejNBu92kS/3JaeKhD4kMJk=; b=eUkAiBU6Fni/JCZSYW+YlaVR6cDQhxR88oMzpFRczbIKl2Zo7ATGTve6LsPkA0n8Ww L6ClBswCLPLf56Uj1KuAQczImbind5efXd32MK3ivKCTJD7OITPYyhyl9lYUvHO+sNRi xdSa1JigpSgMN5UA4LWXhEg4Z6PFUfLpJnn4BxAwT+m7QvXPKFzuPcn6jqXqLa5S8c1z M1Xt55OsbbXP9sUCeU2z177fnWIx5/zNhHDWEFXsYud+koAaCmVRnG5oRwH3bkLPkeGt FissYXbWRodNrsIDlCZhDUZzqkFpUvEdV2mVnCrfj763QvzeUQ2InpR/ec8Y8xVXfRO+ 1etQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n18si7938795plh.454.2022.01.21.13.04.12; Fri, 21 Jan 2022 13:04:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358282AbiATDOa (ORCPT + 99 others); Wed, 19 Jan 2022 22:14:30 -0500 Received: from inva021.nxp.com ([92.121.34.21]:44944 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358275AbiATDO2 (ORCPT ); Wed, 19 Jan 2022 22:14:28 -0500 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id DC3FA201004; Thu, 20 Jan 2022 04:14:26 +0100 (CET) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id A3DAE201001; Thu, 20 Jan 2022 04:14:26 +0100 (CET) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 5A412183ACDD; Thu, 20 Jan 2022 11:14:24 +0800 (+08) From: Shengjiu Wang To: lars@metafoo.de, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH] ASoC: soc-generic-dmaengine-pcm: separate max_buffer_size assignment Date: Thu, 20 Jan 2022 10:44:02 +0800 Message-Id: <1642646642-15908-1-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The config->pcm_hardware may be NULL when config->prealloc_buffer_size is not zero, so it is better to move max_buffer_size assignment under a separate condition. Signed-off-by: Shengjiu Wang --- sound/soc/soc-generic-dmaengine-pcm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index c54c8ca8d715..8659cb1794f1 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c @@ -237,13 +237,15 @@ static int dmaengine_pcm_new(struct snd_soc_component *component, size_t max_buffer_size; unsigned int i; - if (config && config->prealloc_buffer_size) { + if (config && config->prealloc_buffer_size) prealloc_buffer_size = config->prealloc_buffer_size; - max_buffer_size = config->pcm_hardware->buffer_bytes_max; - } else { + else prealloc_buffer_size = prealloc_buffer_size_kbytes * 1024; + + if (config && config->pcm_hardware && config->pcm_hardware->buffer_bytes_max) + max_buffer_size = config->pcm_hardware->buffer_bytes_max; + else max_buffer_size = SIZE_MAX; - } for_each_pcm_streams(i) { struct snd_pcm_substream *substream = rtd->pcm->streams[i].substream; -- 2.17.1