From patchwork Mon Apr 17 17:15:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 673952 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 8EDEAC77B7A for ; Mon, 17 Apr 2023 17:16:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230224AbjDQRQW (ORCPT ); Mon, 17 Apr 2023 13:16:22 -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 ); 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 To: Herve Codina , Lee Jones , Rob Herring , Krzysztof Kozlowski , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Christophe Leroy , Thomas Petazzoni 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 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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; 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);