From patchwork Mon May 29 01:03:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13257968 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 E513CC77B7E for ; Mon, 29 May 2023 01:05:21 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id D6EB083B; Mon, 29 May 2023 03:04:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D6EB083B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685322320; bh=ZuNMos54AIJNlqmD0jq22TXyOPV/7yJ53PYTpNN2gro=; h=From:To:Cc:In-Reply-To:References:Subject:Date:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=GS6urPrGR54kUzlgVpZHdDr7atdUT8GLiWlk/Gxza4RAo59ngDwM7feseCHCoC2yQ n/yJd7/hAKJE2o7ir2qtskoOGs/BGkZstg7fXQxsPa7kbeepcqmh4dlHGZoVReG3BZ EJuAoMTm8d1AfGfz3OtlzemOBnVf1gwLG/yD8eHo= Received: by alsa1.perex.cz (Postfix, from userid 50401) id BA7A6F805B5; Mon, 29 May 2023 03:03:28 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 2B796F805AF; Mon, 29 May 2023 03:03:28 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C827FF805B0; Mon, 29 May 2023 03:03:23 +0200 (CEST) Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01on20703.outbound.protection.outlook.com [IPv6:2a01:111:f403:7010::703]) (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 06486F8058C for ; Mon, 29 May 2023 03:03:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 06486F8058C Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=renesas.com header.i=@renesas.com header.a=rsa-sha256 header.s=selector1 header.b=RCFnT7Mk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SZ5cfXu5H7VYQqM614DU5rhc4g2vBR5rmMZMKZys20kqBDjIZQ9taBVW6pjjHoDsiIUspAjg6n8Tdv9hz+NfcnlEctpHMNrz1Ci05l7zg/tEQDAozkq5FsV8pqg/CIB8fC625kYxuqPAcLXWrXp6f+hZxvxqG5Nc2lszHXIqG9Qe04rKr7okBuK9l6ge9MbU2mPLYhd468hpFXh01oPeRXH0GSvjXD2hrDJrZHY7rngr8yJQI+XTLocI/yMTXDE9S5ZO/2ciOzlyByLj5U37gJWd3F/hJdgvmgO1ihqyNqs68HfHgT3gyipbfVem6UQof0/h87Lpdp2xDfcIxBW3kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+oOkqhKbkTL/3SiEEeyds8HkZVDM28kI07WMjcz5kLc=; b=ay4uX9OiBH3lDZyhoHkx+Q9aCpAbua1gSTTySCeKU63NmjE6mVBQ2WIEDDS9gQZm3siIVSABU/nU08TfeZ3RZ1iNaosrLw7F/5Fs90NkBpSeD7powIo4a6fHT2MDNdKQs9t8gxpEvDwoqUonQiFGUvW7bKOjJ3kEXMQRlJ4VHvbZAcbZh6Y02nbUb9l9T7N1sPN7lwOciHdW3izb1eVVFv5De8wlW0bmFA6tEXRyMfTF85ROJeeJO5BrCcllTeI4uz+SxGBxUb2jm6xgvqyGOZMC78t7P1NGnQ1n7J+lGZkrQUKQoE7/n+mzGVB9QWQJtn+9L2prDJ2VKQfChOjdIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=renesas.com; dmarc=pass action=none header.from=renesas.com; dkim=pass header.d=renesas.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesas.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+oOkqhKbkTL/3SiEEeyds8HkZVDM28kI07WMjcz5kLc=; b=RCFnT7MkhDCTYS4vqvcf2q79a4iDPYad49/zb9gL8V1lCDt89n1LgcsZHtfARmQwEg+JWLX0WUzYw8cg4fWuHjWMbPus1T6InMeeEP6hfPj3Ukt80tCvOsDsN2pzkog13qliN1iI8g3UeEC1pJXpgZeUV+zrz23ZtFE1d08X2wQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=renesas.com; Received: from OS3PR01MB8426.jpnprd01.prod.outlook.com (2603:1096:604:194::10) by TYCPR01MB8658.jpnprd01.prod.outlook.com (2603:1096:400:15e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.22; Mon, 29 May 2023 01:03:14 +0000 Received: from OS3PR01MB8426.jpnprd01.prod.outlook.com ([fe80::91e7:a94f:9f75:d840]) by OS3PR01MB8426.jpnprd01.prod.outlook.com ([fe80::91e7:a94f:9f75:d840%7]) with mapi id 15.20.6433.022; Mon, 29 May 2023 01:03:14 +0000 Message-ID: <87ilcclzjh.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto To: Jaroslav Kysela , Liam Girdwood , Mark Brown , Takashi Iwai Cc: alsa-devel@alsa-project.org In-Reply-To: <87o7m4lzl3.wl-kuninori.morimoto.gx@renesas.com> References: <87o7m4lzl3.wl-kuninori.morimoto.gx@renesas.com> Subject: [PATCH v3 04/21] ASoC: soc-pcm.c: use temporary variable at soc_get_playback_capture() User-Agent: Wanderlust/2.15.9 Emacs/27.1 Mule/6.0 Date: Mon, 29 May 2023 01:03:14 +0000 X-ClientProxiedBy: TYWPR01CA0016.jpnprd01.prod.outlook.com (2603:1096:400:a9::21) To OS3PR01MB8426.jpnprd01.prod.outlook.com (2603:1096:604:194::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS3PR01MB8426:EE_|TYCPR01MB8658:EE_ X-MS-Office365-Filtering-Correlation-Id: 35fe0a33-e22b-44e9-68f5-08db5fe07b34 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ly72blHgvg/6i5LLxRqRNaHDDfI/qUEzkVkSPHJ+OaV2xiaI5fTB57P7FD8eJW4fMyAvlW7pOHch7EYWCzCnKwCTVaz7J24NfcFjqQPTWN9ESZQa8eKtNcmUC4AjWjK8HwC/pjZ20Q9AU0/WjIdsbW0VzcjsgNILhPPyQLvcCjPWqIN2fz8/1IajkLqFhWs6e6NapmeTuk/1a1BtJXxja3Mr/29J6sUIFA+RGEkLyPSbV+YnKYQbP14v6NP9i7iX5NkFlKD379mdZ3C96wgkSbOH5+DBelpevmDIW4EOFSdyzG/Og47nAyLmTsANUeuOu6kGeHrHPuuSXhaf5Lov7sKR8H/dQqGzI5i4e1qzTTiXbxGUCHNBoSZPWOnxC0Yt9sfY089rsodQg4nV9wS9NlE9bqLvwEhtOnEiA3E7kCtapD3226N/GaBUc7RnS6SZiWi6AsMLXd3ERdn8dSzocfD3jM9k4MM1mR4M1dcH2NmZQqfy9GgPllxQWh5cbDxxu2/LAfWwZcsI0JCuUYM2CXI/X6WQxt3NM8rLhcAKElWlkntYxGqtVxMDkw+tkA5kJSs/D+5cZk42M+hrwTSkiLwEN4pXx+WJ70vzAHK2cCLYt/CQUgyQcbuZc3qr/CDDmpZGPKv9qGB0Wq/6u2/3/Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS3PR01MB8426.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(136003)(39860400002)(346002)(376002)(396003)(451199021)(26005)(38350700002)(38100700002)(41300700001)(52116002)(6486002)(83380400001)(186003)(6512007)(6506007)(2616005)(478600001)(110136005)(66946007)(66556008)(66476007)(4326008)(316002)(2906002)(5660300002)(8676002)(8936002)(86362001)(36756003)(21314003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rypZsQTYc9freb2HjGlUXhgRYMdBDbcVwa4bpZ62Wd3U44scb/DQA1nWS+BAgCuehSZx97fYYsHZMdPSRweUQVuuCxeYiXNjYsRI2k1OK4OXwJWOd5s9p/ciDP3BPamz/cwiqlwLV8E5/orjDnCvdiyLjoGzgsb5wLdIMPhNHnpQlGJOvZwVC3Z+MaUeKYib2NhqM72CL8bKWtLqFEo4lY4JYhyGl1si+z/NIAlBBSu3WKrF5fg8mjx1cjNymKSZowCaekNIxe6QDvN95axjIDB2F7Maqo5XqhYP71rJOq4uAD0mChQbnfq02nWDWPCBLmNKjMLnaJV/hO0e7rriWaUKsJcabdN/42LUJp1UQDLpsCEwkniAi/vH+G8TH9GkYu4Nd2yEZ0UH8zr3CQAf49W7LgZW+oFFoSKc9ToLQrAd9lunKg+iutoiQHcDLzzpg/adeyNmSw24cyG2TsQDabmsAef/w4Ivh6k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5+sTODjIRX4jkHmeBo6nw4ys47qGQQg4qbuv5drUe7kOxagG3lMTTXPTs1DW63lrs= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35fe0a33-e22b-44e9-68f5-08db5fe07b34 X-MS-Exchange-CrossTenant-AuthSource: OS3PR01MB8426.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2023 01:03:14.8402 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jIT/Z/UhKkF6f6AoZhMWE+ge4Vpb72uhfFPkz2+VnkLHTxjsbDbwmIcsoRJ9ZTyEd0u6Si6foE0gXAu9hwJENux+PIkxAQy+4vLoCobNfHZw7od/0wHVgs+/VlydmNGh X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYCPR01MB8658 Message-ID-Hash: ZPDFS76B3LKTEP4BOGP7BPEI2CE6ZT6J X-Message-ID-Hash: ZPDFS76B3LKTEP4BOGP7BPEI2CE6ZT6J X-MailFrom: kuninori.morimoto.gx@renesas.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: soc_get_playback_capture() (A) returns number of substreams for playback/capture (B). (A) static int soc_get_playback_capture(..., (B) int *playback, int *capture) { ... for_each_xxx(...) { if (xxx) return -EINVAL; => *playback = 1; ... => *capture = 1; ... } ... } But, it is directly updating playback/capture which is the result of this function even though it might be error. It should be updated in case of succeed only. This patch updates it. Signed-off-by: Kuninori Morimoto --- sound/soc/soc-pcm.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 47da3be0ff46..b3d569e7ba61 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -2733,6 +2733,8 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd, { struct snd_soc_dai_link *dai_link = rtd->dai_link; struct snd_soc_dai *cpu_dai; + int has_playback = 0; + int has_capture = 0; int i; if (dai_link->dynamic && dai_link->num_cpus > 1) { @@ -2748,11 +2750,11 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd, for_each_rtd_cpu_dais(rtd, i, cpu_dai) { if (snd_soc_dai_stream_valid(cpu_dai, stream)) { - *playback = 1; + has_playback = 1; break; } } - if (!*playback) { + if (!has_playback) { dev_err(rtd->card->dev, "No CPU DAIs support playback for stream %s\n", dai_link->stream_name); @@ -2764,12 +2766,12 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd, for_each_rtd_cpu_dais(rtd, i, cpu_dai) { if (snd_soc_dai_stream_valid(cpu_dai, stream)) { - *capture = 1; + has_capture = 1; break; } } - if (!*capture) { + if (!has_capture) { dev_err(rtd->card->dev, "No CPU DAIs support capture for stream %s\n", dai_link->stream_name); @@ -2798,30 +2800,33 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd, if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) && snd_soc_dai_stream_valid(cpu_dai, cpu_playback)) - *playback = 1; + has_playback = 1; if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE) && snd_soc_dai_stream_valid(cpu_dai, cpu_capture)) - *capture = 1; + has_capture = 1; } } if (dai_link->playback_only) { - *playback = 1; - *capture = 0; + has_playback = 1; + has_capture = 0; } if (dai_link->capture_only) { - *playback = 0; - *capture = 1; + has_playback = 0; + has_capture = 1; } - if (!*playback && !*capture) { + if (!has_playback && !has_capture) { dev_err(rtd->dev, "substream %s has no playback, no capture\n", dai_link->stream_name); return -EINVAL; } + *playback = has_playback; + *capture = has_capture; + return 0; }