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 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 BD100C77B73 for ; Thu, 20 Apr 2023 12:31:37 +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 C302BECB; Thu, 20 Apr 2023 14:30:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C302BECB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1681993893; bh=VE7EWjRbie5rJybEr6+xbW/1EFmgykY9w+gQ4IWRzQA=; h=Date:From:To:Subject:References:In-Reply-To:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=NkGdFckddAsZC4yjNzqBNZNTIeVWuSSVqtrAc5XrxczeRXRb+23gbqm3ms+Sn2wmc MGOVuHGIeTNmZQVP/mn2xMuz3eHOGiA1ptfgjs+0iigVB0LqeMRan1HC5JuGZSNVyZ tnTxBtAoPCg7uycl7+m673CJpMhQ+vjk1dK9K480= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 8233FF80155; Thu, 20 Apr 2023 14:30:18 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BCAA3F80155; Thu, 20 Apr 2023 14:30:13 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B5534F80053 for ; Thu, 20 Apr 2023 14:30:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B5534F80053 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=Fd0AjzBe Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A89D7615B4; Thu, 20 Apr 2023 12:30:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B46EEC433D2; Thu, 20 Apr 2023 12:29:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681993801; bh=VE7EWjRbie5rJybEr6+xbW/1EFmgykY9w+gQ4IWRzQA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Fd0AjzBesaZOfkihQtIdI1XWLKkZFcQ8C040snGRpbZuiXicincyOqwzgcU6jyxOE boa7J6EMQWbHkRsfTLTFGfgWSuudj1+NCK59q7+hS2yR0l3tL+5q14m5dhs/kS5VI3 ibjH8uvcrLR/qZFI82P8hXNLV+bLyvbVit+ovqW29M2b486ESGULIYgNf9Vvm97M9q l0jtc4AgjG1KpDm9o72+IgfMQShsOQcyrU2Iqd821k0dpsvSrvuonXOhicNCPuMj9R 5udkdqVaSdDIB0ONGTy0J6vpbo1TLJwUr9+OwYwNL7v1C1VSsPiGTMHXYA3dWZHDds YTcl3QsNqJ0Hg== Date: Thu, 20 Apr 2023 13:29:55 +0100 From: Lee Jones To: Herve Codina Subject: Re: [PATCH v6 2/7] mfd: core: Ensure disabled devices are skiped without aborting Message-ID: <20230420122955.GA996918@google.com> References: <20230417171601.74656-1-herve.codina@bootlin.com> <20230417171601.74656-3-herve.codina@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230417171601.74656-3-herve.codina@bootlin.com> Message-ID-Hash: H2J6ZON53H7JFTQJBFEWNGEMDPK4GAVU X-Message-ID-Hash: H2J6ZON53H7JFTQJBFEWNGEMDPK4GAVU X-MailFrom: lee@kernel.org 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 CC: Rob Herring , Krzysztof Kozlowski , Liam Girdwood , Mark Brown , Takashi Iwai , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Christophe Leroy , Thomas Petazzoni 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: On Mon, 17 Apr 2023, Herve Codina wrote: > The loop searching for a matching device based on its compatible > string is aborted when a matching disabled device is found. > This abort avoid to add devices as soon as one disabled device > is found. > > Continue searching for an other device instead of aborting on the > first disabled one fixes the issue. > > Fixes: 22380b65dc70 ("mfd: mfd-core: Ensure disabled devices are ignored without error") > Signed-off-by: Herve Codina > --- > drivers/mfd/mfd-core.c | 18 +++++++++++++----- > 1 file changed, 13 insertions(+), 5 deletions(-) > > diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c > index 16d1861e9682..7c47b50b358d 100644 > --- a/drivers/mfd/mfd-core.c > +++ b/drivers/mfd/mfd-core.c > @@ -176,6 +176,7 @@ static int mfd_add_device(struct device *parent, int id, > struct platform_device *pdev; > struct device_node *np = NULL; > struct mfd_of_node_entry *of_entry, *tmp; > + bool not_available; > int ret = -ENOMEM; > int platform_id; > int r; > @@ -211,13 +212,13 @@ static int mfd_add_device(struct device *parent, int id, > goto fail_res; > > if (IS_ENABLED(CONFIG_OF) && parent->of_node && cell->of_compatible) { > + not_available = false; Why not do: bool disabled = false; ... here instead? > for_each_child_of_node(parent->of_node, np) { > if (of_device_is_compatible(np, cell->of_compatible)) { > - /* Ignore 'disabled' devices error free */ > + /* Skip 'disabled' devices */ > if (!of_device_is_available(np)) { > - of_node_put(np); Why are you removing the put? > - ret = 0; > - goto fail_alias; > + not_available = true; > + continue; > } > > ret = mfd_match_of_node_to_dev(pdev, np, cell); > @@ -227,10 +228,17 @@ static int mfd_add_device(struct device *parent, int id, > if (ret) > goto fail_alias; > > - break; > + goto match; > } > } > > + if (not_available) { > + /* Ignore 'disabled' devices error free */ > + ret = 0; > + goto fail_alias; > + } > + > +match: > if (!pdev->dev.of_node) > pr_warn("%s: Failed to locate of_node [id: %d]\n", > cell->name, platform_id); > -- > 2.39.2 > -- Lee Jones [李琼斯] 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 2E38CC77B76 for ; Thu, 20 Apr 2023 12:30:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234924AbjDTMaH (ORCPT ); Thu, 20 Apr 2023 08:30:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232073AbjDTMaD (ORCPT ); Thu, 20 Apr 2023 08:30:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FD9B658B; Thu, 20 Apr 2023 05:30:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AFE3161647; Thu, 20 Apr 2023 12:30:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B46EEC433D2; Thu, 20 Apr 2023 12:29:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681993801; bh=VE7EWjRbie5rJybEr6+xbW/1EFmgykY9w+gQ4IWRzQA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Fd0AjzBesaZOfkihQtIdI1XWLKkZFcQ8C040snGRpbZuiXicincyOqwzgcU6jyxOE boa7J6EMQWbHkRsfTLTFGfgWSuudj1+NCK59q7+hS2yR0l3tL+5q14m5dhs/kS5VI3 ibjH8uvcrLR/qZFI82P8hXNLV+bLyvbVit+ovqW29M2b486ESGULIYgNf9Vvm97M9q l0jtc4AgjG1KpDm9o72+IgfMQShsOQcyrU2Iqd821k0dpsvSrvuonXOhicNCPuMj9R 5udkdqVaSdDIB0ONGTy0J6vpbo1TLJwUr9+OwYwNL7v1C1VSsPiGTMHXYA3dWZHDds YTcl3QsNqJ0Hg== Date: Thu, 20 Apr 2023 13:29:55 +0100 From: Lee Jones To: Herve Codina Cc: Rob Herring , Krzysztof Kozlowski , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Christophe Leroy , Thomas Petazzoni Subject: Re: [PATCH v6 2/7] mfd: core: Ensure disabled devices are skiped without aborting Message-ID: <20230420122955.GA996918@google.com> References: <20230417171601.74656-1-herve.codina@bootlin.com> <20230417171601.74656-3-herve.codina@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230417171601.74656-3-herve.codina@bootlin.com> Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On Mon, 17 Apr 2023, Herve Codina wrote: > The loop searching for a matching device based on its compatible > string is aborted when a matching disabled device is found. > This abort avoid to add devices as soon as one disabled device > is found. > > Continue searching for an other device instead of aborting on the > first disabled one fixes the issue. > > Fixes: 22380b65dc70 ("mfd: mfd-core: Ensure disabled devices are ignored without error") > Signed-off-by: Herve Codina > --- > drivers/mfd/mfd-core.c | 18 +++++++++++++----- > 1 file changed, 13 insertions(+), 5 deletions(-) > > diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c > index 16d1861e9682..7c47b50b358d 100644 > --- a/drivers/mfd/mfd-core.c > +++ b/drivers/mfd/mfd-core.c > @@ -176,6 +176,7 @@ static int mfd_add_device(struct device *parent, int id, > struct platform_device *pdev; > struct device_node *np = NULL; > struct mfd_of_node_entry *of_entry, *tmp; > + bool not_available; > int ret = -ENOMEM; > int platform_id; > int r; > @@ -211,13 +212,13 @@ static int mfd_add_device(struct device *parent, int id, > goto fail_res; > > if (IS_ENABLED(CONFIG_OF) && parent->of_node && cell->of_compatible) { > + not_available = false; Why not do: bool disabled = false; ... here instead? > for_each_child_of_node(parent->of_node, np) { > if (of_device_is_compatible(np, cell->of_compatible)) { > - /* Ignore 'disabled' devices error free */ > + /* Skip 'disabled' devices */ > if (!of_device_is_available(np)) { > - of_node_put(np); Why are you removing the put? > - ret = 0; > - goto fail_alias; > + not_available = true; > + continue; > } > > ret = mfd_match_of_node_to_dev(pdev, np, cell); > @@ -227,10 +228,17 @@ static int mfd_add_device(struct device *parent, int id, > if (ret) > goto fail_alias; > > - break; > + goto match; > } > } > > + if (not_available) { > + /* Ignore 'disabled' devices error free */ > + ret = 0; > + goto fail_alias; > + } > + > +match: > if (!pdev->dev.of_node) > pr_warn("%s: Failed to locate of_node [id: %d]\n", > cell->name, platform_id); > -- > 2.39.2 > -- Lee Jones [李琼斯]