From patchwork Mon Oct 17 23:37:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 616089 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 64144C4332F for ; Mon, 17 Oct 2022 23:38:50 +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 80E698E1E; Tue, 18 Oct 2022 01:37:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 80E698E1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1666049928; bh=0WcOp8MTXyasmNZkV8Wyu1Kx55UULwgfVzCqmvSlj1E=; h=From:Subject:To:In-Reply-To:References:Date:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=N4a4ZOIfa8Mi6QvtwFYdrAJIL29SsbSmKjCT+YqSK3wuDkTorlc1SVcsfp1EOQwJO G2s9FG5BjZO+CCavEFXVpN4vdiXby0wOST55ftJh0cR/nhO8C1RXvX7CV+QKMdFFpB oi0cZqlM3F6XTVK8RTuqflS0S3a7K3+zaece8u8g= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 420DBF8055A; Tue, 18 Oct 2022 01:37:17 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 11B53F80551; Tue, 18 Oct 2022 01:37:16 +0200 (CEST) Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01on2094.outbound.protection.outlook.com [40.107.114.94]) (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 EA2F9F80533 for ; Tue, 18 Oct 2022 01:37:09 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz EA2F9F80533 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=renesas.com header.i=@renesas.com header.b="HnUgH9YB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gc8TpfV+EzVe/3S3TG59fuTbk3strTWMd6/I5aUJ1priujj2dHZ4WV3zEbiCDe3fx2Dpr9AQhh3QmySn8yDBfheKXPMANUZkT9P++4c/f7Rt5Ot7xoefM2H2IYfWezWwbYeuBcFdx2OPwKzhpEDB/pM4BH8i3xb4ECfkA9faHyWzeH0bkDrRbbBvPh8FIkrcBZIuoqm4UWj4QMatEG/RF8dwSwH14COgpwgJcE6rC0sWtAJbT6uy6fLDDpANRKwn3XElrH85rQEAVsUcOZIMXjNAsgj/AeFVBgOSVBcpJZEutMx8DlrgjiP7uTITgcB+suaUzQL0QJsoC1yzaXpmNg== 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=HVVQrZc6UZrEvJwiSHgFbITlsLwkyYu1IMo64mlJr/Y=; b=XpB9bXoveazds4nJDNQMwodMiGIpXE6Ic/01kjSLzb09i63KfZo7loYk+HdU5dkaZ0rV9ekkoSgTD84M/UNpiKLfClAKLJXYEUMT4nbQa/NkdNln71I9in8apPBiVStbcZkJxH4Tbp9Hh5jN3GmwLKBY7bJ0+Kd0MtTeNEOls4fObW+2mikkZohWJfyKG2xk1j7BsQVyOLdMjBflOAkxTjtLs2bWYRSB/wBYWssa/BhcLXqT8Fg24N2K0+oGip0chkxAKWaqixy9EUk+grzGEYkmLXwGI3APQCtK+so7v+umPVnwLwlUj/OqHAOK3SD59B/nSxreqEovrAGLSiPyIA== 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=HVVQrZc6UZrEvJwiSHgFbITlsLwkyYu1IMo64mlJr/Y=; b=HnUgH9YB4SS9jv2tIFZz/3+fNeUMceSr7vqjhHQUhULepkkglWUgKVpw6rbeNbP1pZF4h6rGKt1DwEihSkuHGL+CkLU6UCO+du8tmYFWIl1HmSz8fC4wOnrbE4YxVeflARnJtwVWPf8ebyWki594o8jiVtCVd/ujX04JEkOesI4= 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 TYCPR01MB10199.jpnprd01.prod.outlook.com (2603:1096:400:1ef::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.31; Mon, 17 Oct 2022 23:37:04 +0000 Received: from OS3PR01MB8426.jpnprd01.prod.outlook.com ([fe80::8860:a9ae:8e74:ec53]) by OS3PR01MB8426.jpnprd01.prod.outlook.com ([fe80::8860:a9ae:8e74:ec53%6]) with mapi id 15.20.5723.033; Mon, 17 Oct 2022 23:37:02 +0000 Message-ID: <87tu42owdd.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 06/11] ASoC: soc-dapm.c: merge dapm_power_one_widget() and dapm_widget_set_power() User-Agent: Wanderlust/2.15.9 Emacs/26.3 Mule/6.0 To: Mark Brown In-Reply-To: <8735bmqazf.wl-kuninori.morimoto.gx@renesas.com> References: <8735bmqazf.wl-kuninori.morimoto.gx@renesas.com> Date: Mon, 17 Oct 2022 23:37:02 +0000 X-ClientProxiedBy: TY2PR01CA0017.jpnprd01.prod.outlook.com (2603:1096:404:a::29) To OS3PR01MB8426.jpnprd01.prod.outlook.com (2603:1096:604:194::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS3PR01MB8426:EE_|TYCPR01MB10199:EE_ X-MS-Office365-Filtering-Correlation-Id: 2ca3e2cc-4f9c-4254-f784-08dab0987e5c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ffeFLK+Z0nKJTDMY5azSwL8L8aLpQpvcNTJPQ96+qVZPUxcCI6id7SMecweME8jGQwcHGa2Nv6ado+n6Mn2BoXy8ALKwMQrRtBAPLTdVxOs0pc4oIDQ3xMjEQrs9zxnE8LsXO8EzIbkUyg2T9cTwRsNdhzWWI8YbiG4PGx+AtGd22VQBPD84j+SeSs035o8TDp5gsJ481HJmlByWgLG5IkhwjxTFZweOv2wXJYqbrA4Lyxf8gsR+5GF/g7/FekTdQI74gQ4qpzl6AICZCa2sQPg1OUH4SMQsXyXw1yHRKUCeAY3FW3CYoFswvdArd9GXi2hUjnvnshTOZZUQ3iTbI5ApmPN4yXxdkJ/ZDroS8rSjJTeFFkN2kz2zLkGycC6uZjyoz/wAbu1QaBmAAMvPehtgJETNAS91CbO0ANS1o8VXhFSBjxBMH0KwcJ93RrOlKaiXSyn87aCkQAfPyr1+a8tmqXBokYM7PKukyveiFpnI1xCT6A1rQ8lYMIOGLMzm6EpyKpKkQCVtmT6e84oaZJL7Qig3nKelNxopWDNxdgoQVo8KI6tKOkgJzih7AhVPuPRpsu9CyVK36AxM4udW8hu1g4q+XxIEiuO6vfaN149uFOd/Pju0l3sVxKptalKHjXUZ3iVzwfk7Ng50UYIuP7ord7QuKxb/Gt7HiR7iWWa56jjUjBfOVOlYSfQ2Gni77cekJ8p/gk3JUgTnAqSjq6efe5xr25CJKSLzNI2P47XTqjaI6HSYKKK9kdyFkALX 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:(13230022)(4636009)(346002)(39860400002)(376002)(396003)(136003)(366004)(451199015)(41300700001)(5660300002)(2906002)(8936002)(316002)(6916009)(36756003)(6506007)(52116002)(478600001)(6486002)(66476007)(66556008)(66946007)(4326008)(8676002)(83380400001)(86362001)(26005)(6512007)(38100700002)(38350700002)(2616005)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GGcxtH40UIGK0/oKbdvHvpW2QRpL4h4juUS2IVwzfguBRqH8JgU7u2ZYMo872bNx52POwe7c6HOqGqC4slJlMP0vzpG1sYco2uvyeGssp7RZLR6gpFm6P3xcJtrd61uP6HcT0LgYQuCTWI92ejOUBx49g9QOzInjdQRJrZhemSSX4KTq6xRHbJTtD0x6u9F8QVeTFyttO/QHr+Q0mOW+8Zs0TE7Y3YPQD00F/+udyUEDWWdwyZLF8RMoVbF3xDR9fzGQnwx2+AqiiI0nzeEgbAtcEYDNFiHc5x5WToG8qU1y1Mb+amlDc1nsqIg6t3c8nNAB6w0t/LDVzraYGKlj327wnKZqTBOfI21oSHIdwKBvMxgZ8YZqcEXNIrMF1jkGChInCXE3xY/fg9JPwEsJaNqI7/6sEBn6j7ek5baSNMIoCIo+9EaeTCT4LgroL/iKedn5mAI340IzDkEp5D53sGg3IL7B+InAYWm0x2B+tqKlhyuLMwS6idf2pmsi5Qu08hiDxw6pFB/koP2HTpVoT4UtfMBWfCN10axqL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y4= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2ca3e2cc-4f9c-4254-f784-08dab0987e5c X-MS-Exchange-CrossTenant-AuthSource: OS3PR01MB8426.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2022 23:37:02.8823 (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: 3ELpo3JSaHTL5/8HxC7l5JNWCUJjLqEzqoBwzuVkuqQsk/JNpKUSeELgJJXhMBeZFZFymiO5F4v5gLZVlylCFBU4xOZWF6vLNzh76KWon9joSjhTIBdHo/Tqm0ShXZ1c X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYCPR01MB10199 Cc: Linux-ALSA 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: Kuninori Morimoto dapm_widget_set_power() (= X) is called only from dapm_power_one_widget() (= Y), and total purpose of these functions are calling dapm_seq_insert() (= a) accordingly for each widget. (X) static void dapm_widget_set_power(...) { ... if (power) (a) dapm_seq_insert(w, up_list, true); else (a) dapm_seq_insert(w, down_list, false); } (Y) static void dapm_power_one_widget(...) { .. switch (w->id) { case snd_soc_dapm_pre: (a) dapm_seq_insert(w, down_list, false); break; case snd_soc_dapm_post: (a) dapm_seq_insert(w, up_list, true); break; default: power = dapm_widget_power_check(w); (X) dapm_widget_set_power(w, power, up_list, down_list); break; } } It should be more simple, but the code is unnecessarily complicated, and difficult to read/understand. This patch merge these into one. Signed-off-by: Kuninori Morimoto --- sound/soc/soc-dapm.c | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index d4281e776e44..764830a51d2d 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -1873,11 +1873,24 @@ static void dapm_widget_set_peer_power(struct snd_soc_dapm_widget *peer, dapm_mark_dirty(peer, "peer state change"); } -static void dapm_widget_set_power(struct snd_soc_dapm_widget *w, bool power, +static void dapm_power_one_widget(struct snd_soc_dapm_widget *w, struct list_head *up_list, struct list_head *down_list) { struct snd_soc_dapm_path *path; + int power; + + switch (w->id) { + case snd_soc_dapm_pre: + power = 0; + goto end; + case snd_soc_dapm_post: + power = 1; + goto end; + default: + } + + power = dapm_widget_power_check(w); if (w->power == power) return; @@ -1897,35 +1910,13 @@ static void dapm_widget_set_power(struct snd_soc_dapm_widget *w, bool power, if (!w->is_supply) snd_soc_dapm_widget_for_each_sink_path(w, path) dapm_widget_set_peer_power(path->sink, power, path->connect); - +end: if (power) dapm_seq_insert(w, up_list, true); else dapm_seq_insert(w, down_list, false); } -static void dapm_power_one_widget(struct snd_soc_dapm_widget *w, - struct list_head *up_list, - struct list_head *down_list) -{ - int power; - - switch (w->id) { - case snd_soc_dapm_pre: - dapm_seq_insert(w, down_list, false); - break; - case snd_soc_dapm_post: - dapm_seq_insert(w, up_list, true); - break; - - default: - power = dapm_widget_power_check(w); - - dapm_widget_set_power(w, power, up_list, down_list); - break; - } -} - static bool dapm_idle_bias_off(struct snd_soc_dapm_context *dapm) { if (dapm->idle_bias_off)