From patchwork Tue Jul 25 09:23: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: 125513 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2382511vqg; Tue, 25 Jul 2023 03:53:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlHNiHqy8M2Sm48PQ59UPVvESNMivy6JIk8z2OsHK0KYvtNWhGOiKgUGsL0LqG9OzPPfW76D X-Received: by 2002:a05:6a20:100d:b0:133:f0a8:fb60 with SMTP id gs13-20020a056a20100d00b00133f0a8fb60mr8436406pzc.15.1690282395693; Tue, 25 Jul 2023 03:53:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690282395; cv=none; d=google.com; s=arc-20160816; b=F4pdOkH3j8qQC4cOpBuDr1kcZs/rmOcNMZaJq4v/qW/2J28ukB6we1xBwEz9C74QpZ /J/6m2LFiluI5pPsFyfo38lX5Gc87AoEv9adPsX0GcW8vTvpdWIkKrAZ9ArHgxzp08xo WePi1QUr5NnxH9ILTlqNlEKWKJPzk8b+PouL51B020ound1QuKAKr+n4XPXBaubsQ/4O GlC6iBTF/+JQE4vU7mJTi2v8fw3pK9UNVOc7iAU8amXsCBvjcJze2f5DG3wLFqb9JMVO /pWZJ64P+cmKktoW58q27vx+lt77ne6u5VEnt3r4OC+aYPB+Oo9vKc7Qw1pDjar1WAme u53Q== 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=j5z+1OhFuGBFoHpqsKfNW8PvbyYDiDyztgOSDrYZWKg=; b=xmosB+9EE5MWcG77UTYSR5drfJkPU8IhD7Z8yBWrVrepp3FKg39SPwX4SesTeQdAMt XUCM++UBH7LiZDyUQkWT4kUqTy+McQPloaLc2x0YR8GhMuZ643zx9HwIFzdhiqDiXmrx 2PShxT5t40DRsptvNsBed8f6nnW3FrmWJb5SJBSCKsfwly/D32y5caJgg6/7Lio1WtBV PuZZwMZNV5cmo//OQOh8LPUsUZ5vVEG2vtFlJvcI+4mH73oEmCDBitZUFiYANDy6aJSV SL/LoZ8FHNyjM4ehJu0HliqR/V/oqpFDOSeBaevoe3Mhi6pwky9G0E711pISfcKxnUst Upnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=m6qek3IJ; 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 cl10-20020a056a0032ca00b0068686864ee9si2842192pfb.213.2023.07.25.03.53.02; Tue, 25 Jul 2023 03:53:15 -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=m6qek3IJ; 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 S233306AbjGYJ1z (ORCPT + 99 others); Tue, 25 Jul 2023 05:27:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233247AbjGYJ1R (ORCPT ); Tue, 25 Jul 2023 05:27:17 -0400 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53B0F3A8F; Tue, 25 Jul 2023 02:26:01 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPA id EE0C040005; Tue, 25 Jul 2023 09:25:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1690277149; 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=m6qek3IJXOcssYxuZT/eHvt1ZK+Bc//ZCjEmyXYc/ByJks5JBmWRJ+RC7B7JCjDOgUptyI eaBXfA/OZwSaORxmjVPXNoF7cz5RCu8inqNPYjRQ9a+OZlCSVdo1XM8FObkYZqogiiI1tp wzlnS/N0cO7anVyglMPV3eEwZxdXjSOa5eJEO1PoesIbNzMdFeYT3q58JYo1mis9HSFWw2 2SQ2beQF2OfQdJMxB5k9aj6rhZiena2XCNWNpKkDre3lqw7lH5hsebx/lUMC76Zx9LhCV8 +xg9vMeevPtta5Jx/fcNRbQJ4+JTrMtEkVhvG+whdT/XVfS+XjU0hJWZB2VGzA== 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 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 20/26] mfd: core: Ensure disabled devices are skiped without aborting Date: Tue, 25 Jul 2023 11:23:56 +0200 Message-ID: <20230725092417.43706-21-herve.codina@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230725092417.43706-1-herve.codina@bootlin.com> References: <20230725092417.43706-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_H3,RCVD_IN_MSPIKE_WL,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: 1772389553589468281 X-GMAIL-MSGID: 1772389553589468281 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 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);