From patchwork Wed Jan 26 01:17:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bard Liao X-Patchwork-Id: 12724429 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AF8F3C5AC75 for ; Wed, 26 Jan 2022 01:19:31 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 09B2D1F66; Wed, 26 Jan 2022 02:18:40 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 09B2D1F66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1643159970; bh=hRyebvpUmOlSx2YqWY7Ev21ywUBSfmUTYJfGzoRDvXo=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=vke5E+OV2J+zCzJtMEabBnvCDy8om6ZHaQtkrDUG0+lbV6I+tdeyV2HEBFcd9jDJR dy2B4g9tu28oO6J1utY8n4TERJopCA1orCueio4VLnsmwcCd6j/yEFrv8yq8napFqj XKYMnk/t0Lxgjm6bTPsYmEllpkMCjpHxhFSf/gtc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B0904F8051B; Wed, 26 Jan 2022 02:17:50 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A748BF80515; Wed, 26 Jan 2022 02:17:46 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D9C03F80161 for ; Wed, 26 Jan 2022 02:17:42 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D9C03F80161 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bZOWJp5f" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643159864; x=1674695864; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=hRyebvpUmOlSx2YqWY7Ev21ywUBSfmUTYJfGzoRDvXo=; b=bZOWJp5fCLhHoag+Qbb5azHFvVmCB847zbmZEhWi1ucIQTOY0ci2HRN1 PJOwMhXaOLBc70rh2v6e1AstgLG3+TZaArdu7oz0nuuFh9Pp73WnJfSAW E176xw2Hy3ACSECqVZyli5Nh/c5dKOX/xLoUK3MdovPWnZYzgBJamHR5A Xn+3nZ+T91AYM59qdqcG3MOQsnNoLwSaSAj+ZPOMEAkr6lQWH9FQ+vKno T+ak82juUwnEKPCyM4E4KRf9LsiGa7vDiPFFxvWVqhtVFW5Jc4ON+Gv8M 8FYTHx5lwRZjaaWBNIX/yiH6bRuEnSKDYQD/NHC5cJgyjfF9xcOU/pfCt g==; X-IronPort-AV: E=McAfee;i="6200,9189,10238"; a="246236143" X-IronPort-AV: E=Sophos;i="5.88,316,1635231600"; d="scan'208";a="246236143" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2022 17:17:42 -0800 X-IronPort-AV: E=Sophos;i="5.88,316,1635231600"; d="scan'208";a="520617427" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2022 17:17:40 -0800 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org Subject: [PATCH 05/19] soundwire: stream: split port allocation and configuration loops Date: Wed, 26 Jan 2022 09:17:01 +0800 Message-Id: <20220126011715.28204-6-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220126011715.28204-1-yung-chuan.liao@linux.intel.com> References: <20220126011715.28204-1-yung-chuan.liao@linux.intel.com> Cc: vinod.koul@linaro.org, gregkh@linuxfoundation.org, pierre-louis.bossart@linux.intel.com, linux-kernel@vger.kernel.org, srinivas.kandagatla@linaro.org, sanyog.r.kale@intel.com, bard.liao@intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Pierre-Louis Bossart Split loops before moving the allocation and configuration to separate functions. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Rander Wang Signed-off-by: Bard Liao --- drivers/soundwire/stream.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c index 49d3a8d2fa31..b97c59e71bdb 100644 --- a/drivers/soundwire/stream.c +++ b/drivers/soundwire/stream.c @@ -1232,10 +1232,14 @@ static int sdw_master_port_config(struct sdw_bus *bus, p_rt = sdw_port_alloc(&m_rt->port_list); if (!p_rt) return -ENOMEM; + } + i = 0; + list_for_each_entry(p_rt, &m_rt->port_list, port_node) { ret = sdw_port_config(p_rt, port_config, i); if (ret < 0) return ret; + i++; } return 0; @@ -1254,7 +1258,10 @@ static int sdw_slave_port_config(struct sdw_slave *slave, p_rt = sdw_port_alloc(&s_rt->port_list); if (!p_rt) return -ENOMEM; + } + i = 0; + list_for_each_entry(p_rt, &s_rt->port_list, port_node) { /* * TODO: Check valid port range as defined by DisCo/ * slave @@ -1266,6 +1273,7 @@ static int sdw_slave_port_config(struct sdw_slave *slave, ret = sdw_port_config(p_rt, port_config, i); if (ret < 0) return ret; + i++; } return 0;