Message ID | 20230417171601.74656-3-herve.codina@bootlin.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2288803vqo; Mon, 17 Apr 2023 10:31:39 -0700 (PDT) X-Google-Smtp-Source: AKy350bAQNXvWTfnHWCj50Xyqb0uWtm88uZmrSKH4qYGtBIRBcZf+WUZy9WXWTNRbW4Z9apxSDKM X-Received: by 2002:a05:6870:e38d:b0:187:fa48:b4c6 with SMTP id x13-20020a056870e38d00b00187fa48b4c6mr1606397oad.37.1681752699375; Mon, 17 Apr 2023 10:31:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681752699; cv=none; d=google.com; s=arc-20160816; b=YdnZIwgiup0gleARzPHggPB2teP7eu++NaKLhjCUmUTkkc30tnBdFOMzma6hdK3imA pLLUY+2piZRzEXbmfE2TyHkkLUVmiy2zFeJO23BZytBmItPTBdQOfN2i2DuXL0OCa+Mt Dz7DIM2Mb5ig3ND/Ou5rNKPbSa/udXb3bv+p8ZUzV2MEyHvddpzLKLLTcJcEzPmcnsiT dTFQUvF6rME9BkfDOX6xl8Jm8O90u/PEVctMUieT4NXeE57oHvzajN8PxeepAnV2XS0k YiL2wCKeTAtGNtyjNIKLwokW6KGDYxLXP/c1ikduvu+ytPVUdLN3qj8PKvatQZxzpqRs 8eZA== 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=h4awDvhGdDQISuFdVnpKwFbC3AMKibp9qWmNCuZN7E0=; b=HeKAMtj+lO2LZdje+TDQKGF/bi926xpNBEE5wpvGiwm9995ghDzQVB+eDecsIbraGV ioxVjw7o6yN2QuI4MebEfh8vTvCLOJvvoTvcsNWowwNuvluoYT4+mroEvt2DPBw2cv9y pYaNIMDI3t46Ixi+iHNwGqyRjTigfJzHC0zC0WGo/MA75Oi2Jqk9cFP4dARFyJFyP/tR KICZKv2PXlYiZO2WYwaxOgelJ7JadhX4n1XtI++ljOOwr5TCguAJfJEEyFcoRFWc97d3 1OFhJ6l6qDF+qHuPGXULZ+030sGaly31+60HFi5dsEQk22e3HIn+P8iMJYaJDRJkswHg EPJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=b64kLCm8; 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 s33-20020a056870eaa100b00180570000c2si9957329oap.72.2023.04.17.10.31.25; Mon, 17 Apr 2023 10:31:39 -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=b64kLCm8; 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 S230237AbjDQRQ0 (ORCPT <rfc822;leviz.kernel.dev@gmail.com> + 99 others); Mon, 17 Apr 2023 13:16:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230196AbjDQRQQ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 17 Apr 2023 13:16:16 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFF4EF7; Mon, 17 Apr 2023 10:16:12 -0700 (PDT) Received: (Authenticated sender: herve.codina@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 3F0ADC0003; Mon, 17 Apr 2023 17:16:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1681751771; 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=h4awDvhGdDQISuFdVnpKwFbC3AMKibp9qWmNCuZN7E0=; b=b64kLCm8zEislkGM3IzKY9wiXlTjEGtTiMm/34Tmm8y1JbYb4pmjj5XT17B2InBu+R8pl0 KvM+mXw+wI9IQfkW16Iy6vxHKx1ooNMac/M3P8y8H+pSW8S0POs/AVd46QjpjiuxTMI1cZ 0+QbudEauGFqofi6aAiGgdBth2g7qkUcFcxLRDZI7AnUSnRZ0W0Hlow5ExXn55e9mfC6xa 4Me6W5yYUFZMQR8FhmKUoAsBam0mQsl6z5sLnmvBSXetXZ7TABUQ6wyG8KM2SRcE29X1JY thiZW+jg28kwSkiWxQNnguKJHiwnMd4fepyJVjsCyY6wnCeVV3ZnPjZoTPbmrg== From: Herve Codina <herve.codina@bootlin.com> To: Herve Codina <herve.codina@bootlin.com>, Lee Jones <lee@kernel.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com> Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Christophe Leroy <christophe.leroy@csgroup.eu>, Thomas Petazzoni <thomas.petazzoni@bootlin.com> Subject: [PATCH v6 2/7] mfd: core: Ensure disabled devices are skiped without aborting Date: Mon, 17 Apr 2023 19:15:56 +0200 Message-Id: <20230417171601.74656-3-herve.codina@bootlin.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417171601.74656-1-herve.codina@bootlin.com> References: <20230417171601.74656-1-herve.codina@bootlin.com> MIME-Version: 1.0 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 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763445518094439976?= X-GMAIL-MSGID: =?utf-8?q?1763445518094439976?= |
Series |
Add the Lantiq PEF2256 audio support
|
|
Commit Message
Herve Codina
April 17, 2023, 5:15 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 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 <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 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 >
On Thu, 20 Apr 2023 13:29:55 +0100 Lee Jones <lee@kernel.org> wrote: > 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 <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 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? Yes, I can change to 'disabled'. > > > 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? The of_node_put() is done internally by for_each_child_of_node() calling of_get_next_child(). As the for_each_child_of_node() loop is not break, the of_node_put() must not be called here as it will be called by of_get_next_child(). > > > - 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 > > > Best regards, Hervé
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; 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; + 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);