Message ID | 20230726150225.483464-23-herve.codina@bootlin.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp500880vqo; Wed, 26 Jul 2023 09:03:42 -0700 (PDT) X-Google-Smtp-Source: APBJJlGCD9kBNJdCzgPm3bwgdmScMWJysvzXYAg19M/WliOTSMFmbEwWs1NZ9+F+vP8i/Chx7sOx X-Received: by 2002:a2e:838b:0:b0:2b6:f85a:20b0 with SMTP id x11-20020a2e838b000000b002b6f85a20b0mr1658745ljg.16.1690387422223; Wed, 26 Jul 2023 09:03:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690387422; cv=none; d=google.com; s=arc-20160816; b=tDlj9Hxa/Uzp/OSGlEUo1J6XAukTTQZmhZj6QVeW/6AEfKLcf3iSVkYbvFLofZwBZ4 YYxJF8aVi6Y3013kOmqqw6R1pCGuPB5lLd36ocJbbMF4J3NaW9+2WshlaHfBoP6IU5qi PZXrLGmWn00uwc8LfxKhgyhGNo1i6gdzbNhsJcXlWzpO3m8rCkOzPOb6FW8rQ8F11BuB giWGeKuu27i/bxL6zypW4WOFx4fm1IJY9Owj2RbjGh155GsPsz6ia8I1bSxFMBFh4R2z smuX1I9tdO9BxmBwn3OHBq9NypH8cO99hTE6c0bLzxfDz3p3KCnrukO5YQvSE1WUz7Vp u+VA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jLRSjkxkJmKUj6adXqZKqUD1LC7hXnpWEfBGTFfcF3E=; fh=OtJVFpZ5Y8/ND7g8QcUIbRSFhG4LznwcYYtG4zWKevM=; b=ZNTqFfArM3mUCDRtcoHdR38bNSkQspTzkAfuTePodZ0c3hmfrFkob6rIdEZQhY0YRT boJ0FQlxK3hsE4RHJxRiqdRZyKeMvXEgB0fqa9Q2AK45hmlSBecrSbXgaaOdPCl33C6h bLWR3tk4/PtN8NB6wt32oGT/urcK0vQgXvqXn7BJ6Vgjv8vinBc6EQZTnkp/n3tICTkw ZNaPuyL7Bg/3jnX2orcw8BM6xGueWwcSUpGC3Kqq/b2cIZ86GG/hnavNCjyu8Zol5GNA XkJMiv6EZypK9gm7T7UaSuZPA2Zw0QPmiPbkb4gwompPa6+bVpVY4DCBmTQU7mDr8XY/ R+TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=FrfmVBLY; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j24-20020a170906475800b00992aa293be8si9271324ejs.204.2023.07.26.09.03.09; Wed, 26 Jul 2023 09:03:42 -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=FrfmVBLY; 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 S234842AbjGZPRy (ORCPT <rfc822;kloczko.tomasz@gmail.com> + 99 others); Wed, 26 Jul 2023 11:17:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234841AbjGZPR3 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 26 Jul 2023 11:17:29 -0400 Received: from mslow1.mail.gandi.net (mslow1.mail.gandi.net [217.70.178.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68D992D68; Wed, 26 Jul 2023 08:17:12 -0700 (PDT) Received: from relay5-d.mail.gandi.net (unknown [217.70.183.197]) by mslow1.mail.gandi.net (Postfix) with ESMTP id 2D1F3C924B; Wed, 26 Jul 2023 15:06:06 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPA id AE6701C0007; Wed, 26 Jul 2023 15:03:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1690383838; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jLRSjkxkJmKUj6adXqZKqUD1LC7hXnpWEfBGTFfcF3E=; b=FrfmVBLYeoT0Pgn1lDU5uEzi5+79gsoJhzpR3lUQHuVVR9d9w4vk7xAlAftIevtwAXM/+h c0njH1hmSJrCkiLUeqEYMovX1MR6ZH17ZpnBGeo2xTntQO9hWsLKUzxlblUrH3lAtchGl5 F0Fx9CTdjxVhJ+JMTkoT2zSnigHvQMjC6UuymSP6Lo5VDBUFZG0FI1NurjvmuXrFMZw/CV ay2iEXm93LUcLlPZkouY68jJa0kyS24uw5kqlrr+aGGAcLQuZIVmdMqAl04hy/Choj7tji vLQmHjTdhpxFnR9sj6ycqrzdkdLValF39NY7wOIroAvSSkNNsRLkUjfLdQpKbg== From: Herve Codina <herve.codina@bootlin.com> To: Herve Codina <herve.codina@bootlin.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Andrew Lunn <andrew@lunn.ch>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, Lee Jones <lee@kernel.org>, Linus Walleij <linus.walleij@linaro.org>, Qiang Zhao <qiang.zhao@nxp.com>, Li Yang <leoyang.li@nxp.com>, Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>, Shengjiu Wang <shengjiu.wang@gmail.com>, Xiubo Li <Xiubo.Lee@gmail.com>, Fabio Estevam <festevam@gmail.com>, Nicolin Chen <nicoleotsuka@gmail.com>, Christophe Leroy <christophe.leroy@csgroup.eu>, Randy Dunlap <rdunlap@infradead.org> Cc: netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, alsa-devel@alsa-project.org, Thomas Petazzoni <thomas.petazzoni@bootlin.com> Subject: [PATCH v2 22/28] mfd: core: Ensure disabled devices are skiped without aborting Date: Wed, 26 Jul 2023 17:02:18 +0200 Message-ID: <20230726150225.483464-23-herve.codina@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726150225.483464-1-herve.codina@bootlin.com> References: <20230726150225.483464-1-herve.codina@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: herve.codina@bootlin.com 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, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772499681407324800 X-GMAIL-MSGID: 1772499681407324800 |
Series |
Add support for QMC HDLC, framer infrastruture and PEF2256 framer
|
|
Commit Message
Herve Codina
July 26, 2023, 3:02 p.m. UTC
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 <herve.codina@bootlin.com>
---
drivers/mfd/mfd-core.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
Comments
On Wed, 26 Jul 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 <herve.codina@bootlin.com> > --- > 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 0ed7c0d7784e..bcc26e64639a 100644 > --- a/drivers/mfd/mfd-core.c > +++ b/drivers/mfd/mfd-core.c > @@ -146,6 +146,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 disabled; > int ret = -ENOMEM; > int platform_id; > int r; > @@ -181,13 +182,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) { > + disabled = false; This does not appear to reside in a loop. Why not set it to false on declaration? > 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); Doesn't this result in a resource leak? > - ret = 0; > - goto fail_alias; > + disabled = true; > + continue; > } > > ret = mfd_match_of_node_to_dev(pdev, np, cell); > @@ -197,10 +198,17 @@ static int mfd_add_device(struct device *parent, int id, > if (ret) > goto fail_alias; > > - break; > + goto match; > } > } > > + if (disabled) { > + /* 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.41.0 >
Hi Lee, On Thu, 27 Jul 2023 10:22:09 +0100 Lee Jones <lee@kernel.org> wrote: > On Wed, 26 Jul 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 <herve.codina@bootlin.com> > > --- > > 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 0ed7c0d7784e..bcc26e64639a 100644 > > --- a/drivers/mfd/mfd-core.c > > +++ b/drivers/mfd/mfd-core.c > > @@ -146,6 +146,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 disabled; > > int ret = -ENOMEM; > > int platform_id; > > int r; > > @@ -181,13 +182,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) { > > + disabled = false; > > This does not appear to reside in a loop. > > Why not set it to false on declaration? Indeed, I will change in the next iteration and set the value to false at the declaration. > > > 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); > > Doesn't this result in a resource leak? No because we change from 'goto fail_alias' to 'continue' and so we don't exit from the for_each_child_of_node(). The for_each_child_of_node() calls of_get_next_child() and, in turn, calls of_node_put(). Regards, Hervé > > > - ret = 0; > > - goto fail_alias; > > + disabled = true; > > + continue; > > } > > > > ret = mfd_match_of_node_to_dev(pdev, np, cell); > > @@ -197,10 +198,17 @@ static int mfd_add_device(struct device *parent, int id, > > if (ret) > > goto fail_alias; > > > > - break; > > + goto match; > > } > > } > > > > + if (disabled) { > > + /* 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.41.0 > > >
Le 26/07/2023 à 17:02, Herve Codina a écrit : > 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. s/avoid/prevents/ > > 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 <herve.codina@bootlin.com> Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu> > --- > 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 0ed7c0d7784e..bcc26e64639a 100644 > --- a/drivers/mfd/mfd-core.c > +++ b/drivers/mfd/mfd-core.c > @@ -146,6 +146,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 disabled; > int ret = -ENOMEM; > int platform_id; > int r; > @@ -181,13 +182,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) { > + disabled = false; > 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); > - ret = 0; > - goto fail_alias; > + disabled = true; > + continue; > } > > ret = mfd_match_of_node_to_dev(pdev, np, cell); > @@ -197,10 +198,17 @@ static int mfd_add_device(struct device *parent, int id, > if (ret) > goto fail_alias; > > - break; > + goto match; > } > } > > + if (disabled) { > + /* 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);
On Tue, 8 Aug 2023 08:13:27 +0000 Christophe Leroy <christophe.leroy@csgroup.eu> wrote: > Le 26/07/2023 à 17:02, Herve Codina a écrit : > > 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. > > s/avoid/prevents/ Yes, will be changed. > > > > > 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 <herve.codina@bootlin.com> > > Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu> >
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index 0ed7c0d7784e..bcc26e64639a 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c @@ -146,6 +146,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 disabled; int ret = -ENOMEM; int platform_id; int r; @@ -181,13 +182,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) { + disabled = false; 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); - ret = 0; - goto fail_alias; + disabled = true; + continue; } ret = mfd_match_of_node_to_dev(pdev, np, cell); @@ -197,10 +198,17 @@ static int mfd_add_device(struct device *parent, int id, if (ret) goto fail_alias; - break; + goto match; } } + if (disabled) { + /* 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);