From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FA68C7EE24 for ; Sat, 3 Jun 2023 14:07:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229784AbjFCOHs (ORCPT ); Sat, 3 Jun 2023 10:07:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229581AbjFCOHr (ORCPT ); Sat, 3 Jun 2023 10:07:47 -0400 Received: from fgw21-7.mail.saunalahti.fi (fgw21-7.mail.saunalahti.fi [62.142.5.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D02F9132 for ; Sat, 3 Jun 2023 07:07:46 -0700 (PDT) Received: from localhost (88-113-26-95.elisa-laajakaista.fi [88.113.26.95]) by fgw21.mail.saunalahti.fi (Halon) with ESMTP id 026c733a-0218-11ee-abf4-005056bdd08f; Sat, 03 Jun 2023 17:07:44 +0300 (EEST) From: andy.shevchenko@gmail.com Date: Sat, 3 Jun 2023 17:07:43 +0300 To: Herve Codina Cc: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Cameron , Lars-Peter Clausen , Jaroslav Kysela , Takashi Iwai , Kuninori Morimoto , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: Re: [PATCH v2 6/9] ASoC: soc-dapm.h: Add a helper to build a DAPM widget dynamically Message-ID: References: <20230523151223.109551-1-herve.codina@bootlin.com> <20230523151223.109551-7-herve.codina@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230523151223.109551-7-herve.codina@bootlin.com> Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Tue, May 23, 2023 at 05:12:20PM +0200, Herve Codina kirjoitti: > The SND_SOC_DAPM_* helpers family are used to build widgets array in a > static way. > > Introduce SND_SOC_DAPM_WIDGET() in order to use the SND_SOC_DAPM_* > helpers family in a dynamic way. The different SND_SOC_DAPM_* parameters > can be computed by the code and the widget can be built based on this > parameter computation. > For instance: > static int create_widget(char *input_name) > { > struct snd_soc_dapm_widget widget; > char name*; > ... > name = input_name; > if (!name) > name = "default"; > > widget = SND_SOC_DAPM_WIDGET(SND_SOC_DAPM_INPUT(name)); > ... > } Maybe instead of adding a helper, simply convert those macros to provide a compaund literal? (See, for example, https://elixir.bootlin.com/linux/v6.4-rc4/source/include/linux/pinctrl/pinctrl.h#L42) -- With Best Regards, Andy Shevchenko