From patchwork Wed Jul 26 15:02:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 126478 Return-Path: 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 + 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 ); 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 To: Herve Codina , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Linus Walleij , Qiang Zhao , Li Yang , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Shengjiu Wang , Xiubo Li , Fabio Estevam , Nicolin Chen , Christophe Leroy , Randy Dunlap 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 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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772499681407324800 X-GMAIL-MSGID: 1772499681407324800 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 Reviewed-by: Christophe Leroy --- 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);