Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2415615rwd; Fri, 26 May 2023 06:23:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5d6r6tTjVUDSxJTG8XX59Djqp+ZldKhSqo/XREpikxCjyKszdvQ90mviSEPQ2evG/Q0IZL X-Received: by 2002:a17:90a:756:b0:256:28ab:de61 with SMTP id s22-20020a17090a075600b0025628abde61mr2735887pje.11.1685107387714; Fri, 26 May 2023 06:23:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685107387; cv=none; d=google.com; s=arc-20160816; b=Quok3Kdzj8zpxKCp6CJ/fTpvGZcd58CLVY4ZAhxERsrIGNWOWITr+duo5NbXS2mY9S BBw6o92zNuxkv2mcktvBHvEgwq/t4qJuQ/4yZiYxWkn+OTIuZRp+93+92Hiowf7IoBSD gZa5nzslHFLuiBHKIUJuNb7jwm6p2QHVvr/dU9qFcVzOu+FZqClP+BRDN3BcgTccyc5U M9w1XEdOuXjSk1KgPr4rxtHzMQVGxaDT6RfXccCXo/lP4gHxekq71hDSgwnFMSjh3TiJ +94U/yzmUb4/OmeCtLxDwwumcOHqz2LOzX8SdxskxKPUt/Cl9xkRW15GSyRbag5HTX7k g3Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=o2J4eEM5RXIP4b+rP/8OD/qqkXSOa3635HqS8iL6gx8=; b=ain7Cs8JL6el3rPX/idciZt47mAlrmujdm2JgBFIXM7A/UhYu2ZQUTnUjoVcbZ/sKK DM5uy51awwyjKfI06wqvhultSEYH8Jz2tYjzUUha4AhMYCBx6BP0EIjAZE7PM4L0wMHi zY3zJcYn4ZWSpjHLfWvYQBXKH/Pk9LeRt90aMSDjqtEvOEu9mAJUsw5yohU1yNMgvuQe NJzplhTLpfenj4HZlS/CapKaLJ6o+6cv03NJSVC0GB0I5pBufovF49wNitKwrSSFAGxy m5tIuRia631JOQegHRVmwDfqN/5M3wUgFyYs02GBU78EqTKhI7rD6FDa7gDiIpee3gAl qrfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=WzpM75Se; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a17-20020a17090a8c1100b002533d06fefcsi4128849pjo.50.2023.05.26.06.22.55; Fri, 26 May 2023 06:23:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=WzpM75Se; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243316AbjEZNHM (ORCPT + 99 others); Fri, 26 May 2023 09:07:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231158AbjEZNHL (ORCPT ); Fri, 26 May 2023 09:07:11 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55F26119; Fri, 26 May 2023 06:07:09 -0700 (PDT) X-GND-Sasl: herve.codina@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1685106427; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o2J4eEM5RXIP4b+rP/8OD/qqkXSOa3635HqS8iL6gx8=; b=WzpM75Segot68BM+UMKk6uK+WErmwQKY5qyywJZSqXmF+qnTvlpGH35vAa9h6Epog44iG/ 8m1dH5Q9VTLZDgmDqYDwqMSyVaz2/u207HwBoHuT73nEXYAJ4D8u8GYiggK/yL2S0zGp4/ eYTZfGcvi/nIiAZw0Z10Jl7DaDCgVn9OSz8rJo0x2Cy8sxYsd5P1qCBfE71+EpcLqw1yDX 8Aq8tv2ynvm6CqTfdEso1ZVd8z4Om265ppGvsYMflNGj3LPY+2GfQVp84xmsqqB9sMFJDK m30UQ6DP6OGGxrRwcWiy/xP7+Qj3CVvuyNkOm0aisl+ob4Kzmj4ibxfoF0R76w== X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 9E9B2C0006; Fri, 26 May 2023 13:07:03 +0000 (UTC) Date: Fri, 26 May 2023 15:07:02 +0200 From: Herve Codina To: Kuninori Morimoto Cc: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Cameron , Lars-Peter Clausen , Jaroslav Kysela , Takashi Iwai , 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 9/9] ASoC: simple-card: Handle additional devices Message-ID: <20230526150702.2555143c@bootlin.com> In-Reply-To: <87v8ghgtyu.wl-kuninori.morimoto.gx@renesas.com> References: <20230523151223.109551-1-herve.codina@bootlin.com> <20230523151223.109551-10-herve.codina@bootlin.com> <87mt1u7fql.wl-kuninori.morimoto.gx@renesas.com> <20230524141411.28765782@bootlin.com> <87v8ghgtyu.wl-kuninori.morimoto.gx@renesas.com> Organization: Bootlin X-Mailer: Claws Mail 4.1.1 (GTK 3.24.37; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 25 May 2023 00:01:14 +0000 Kuninori Morimoto wrote: > Hi Herve > > Thank you for your reply. > > > So, IMHO, calling simple_populate_aux() from __simple_for_each_link() is > > not correct as it has nothing to do with DAI links and must be call once > > per Card. > > My biggest concern is that this code is calling same code multiple times. > It is easy to forget such thing when updating in this kind of code. > We don't forget / take mistake if these are merged. > But we have such code everywhere ;) this is just my concern, not a big deal. > > static int __simple_for_each_link (...) > { > ... > => add_devs = of_get_child_by_name(top, PREFIX "additional-devs"); > ... > } > > static int simple_populate_aux(...) > { > ... > => node = of_get_child_by_name(dev->of_node, PREFIX "additional-devs"); > ... > } > Well, of_get_child_by_name() is called twice to retrieve the additional-devs node but for very different reason. In __simple_for_each_link() to filter out the node as it has nothing to do with a DAI. In simple_populate_aux() to take care of the devices declared in the node. I am not sure that we should avoid that. It will lead to a more complex code and flags just to avoid this call. Not sure that it will be better. __simple_for_each_link() is called multiple times and is supposed to look at links. To avoid the of_get_child_by_name() filter-out call, __simple_for_each_link() will look at link *and* populate devices calling simple_populate_aux(). And to do that correctly it will use a flag to be sure that simple_populate_aux() was called only once. In order to avoid some kind of duplication (at least the node name): static struct device_node *simple_of_get_add_devs(struct device_node *node) { return of_get_child_by_name(node, PREFIX "additional-devs"); } static int __simple_for_each_link (...) { ... => add_devs = simple_of_get_add_devs(top); ... } static int simple_populate_aux(...) { ... => node = simple_of_get_add_devs(dev->of_node); ... } Does it look better ? Best regards, Hervé > Thank you for your help !! > > Best regards > --- > Kuninori Morimoto -- Hervé Codina, Bootlin Embedded Linux and Kernel engineering https://bootlin.com