Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1351509ybx; Tue, 5 Nov 2019 14:44:44 -0800 (PST) X-Google-Smtp-Source: APXvYqyuQ8igZzkxLZ6vK0ulI/VHLAEtjPjjkbU3uKwbs4Cic98cxTKdSxPw4I9yXDVZq0XuIRRG X-Received: by 2002:aa7:d299:: with SMTP id w25mr18297272edq.14.1572993884360; Tue, 05 Nov 2019 14:44:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572993884; cv=none; d=google.com; s=arc-20160816; b=ec1iFZczYGnwiZM1HF+XgOvWBdVSSia2P0zlmV1kcvSNPNebtRbw1Vc8aTI3/1UuUv PJCoJRao1y6KdPfKna0fJ2S2sfW1H929ibwtEPtAubxIJ77/znoYOJwB1XMe9MAx3qkc zVZmTcnS1wVYBCW854tfDTFXWgxYL0Z1C+F+ymm5o1XEvL5lo/rDApfKMSjWRl5wmQd/ pWkDONcQsl2CKGcIDe4dv5PUrzcD9kpJ9nMlh3nkOnqOH1jIEjGgrYckp3tJqE69gRkX c/L4YE7YTL1V4v1dY/w8KnReGXo9MtXvomFyRfGlOh/oy67/pLUHPKLFEmY8yMXam+A3 +FEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=LV6l/4QQQG2Xw7AqaiWlLNFu8SHU8RvoqGdvCq51A8U=; b=mc6o0em/sDAoKo01272VzpMQm6KeonEsmMRiW1ZeN+Vl9acpLyhiUrDIuPSP80kWw9 CEHHaYpu0REuUAffcaN92BkZpkLo2mwwhWtxJuqwkuRlH84KVeRnKGmykV8HqyhFaPiW wOTYjIyZUyFMVFxBUlZpIh4Rjns65uV6OsnH6NFn36NdsejkeEaNeMV6aYRzVJPEGVuo 5FLsdgKx9LTDtxZkljK3DkQMiahwgG4sEVeOaYgmIZs7oxZ2Bn0lRCaK/JCGkRwZ7KXS 6aW+CdKqWMqCnKcQ9q013xCAsf8UR/XhOdQTwAz5AQAEKW/g07hXRUzkuDaoBehM+vDB XgbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 14si15454531eja.294.2019.11.05.14.44.19; Tue, 05 Nov 2019 14:44:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730451AbfKEWnR (ORCPT + 99 others); Tue, 5 Nov 2019 17:43:17 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:44080 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730054AbfKEWnR (ORCPT ); Tue, 5 Nov 2019 17:43:17 -0500 Received: from 79.184.254.83.ipv4.supernova.orange.pl (79.184.254.83) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.292) id a9bbc4ee93b8efe5; Tue, 5 Nov 2019 23:43:13 +0100 From: "Rafael J. Wysocki" To: Saravana Kannan Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Frank Rowand , Len Brown , kernel-team@android.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org Subject: Re: [PATCH v1 3/5] driver core: Allow fwnode_operations.add_links to differentiate errors Date: Tue, 05 Nov 2019 23:43:08 +0100 Message-ID: <7640808.4Pc6YCm0Y9@kreacher> In-Reply-To: <20191028220027.251605-4-saravanak@google.com> References: <20191028220027.251605-1-saravanak@google.com> <20191028220027.251605-4-saravanak@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday, October 28, 2019 11:00:24 PM CET Saravana Kannan wrote: > When add_links() still has suppliers that it needs to link to in the > future, this patch allows it to differentiate between suppliers that are > needed for probing vs suppliers that are needed for sync_state() > correctness. I guess you mean that it will return different error codes in the different cases. > Signed-off-by: Saravana Kannan > --- > drivers/base/core.c | 12 ++++++++---- > include/linux/fwnode.h | 13 +++++++++---- > 2 files changed, 17 insertions(+), 8 deletions(-) > > diff --git a/drivers/base/core.c b/drivers/base/core.c > index 48cd43a91ce6..e6d3e6d485da 100644 > --- a/drivers/base/core.c > +++ b/drivers/base/core.c > @@ -2297,7 +2297,7 @@ int device_add(struct device *dev) > struct device *parent; > struct kobject *kobj; > struct class_interface *class_intf; > - int error = -EINVAL; > + int error = -EINVAL, fw_ret; > struct kobject *glue_dir = NULL; > > dev = get_device(dev); > @@ -2413,9 +2413,13 @@ int device_add(struct device *dev) > */ > device_link_add_missing_supplier_links(); > > - if (fwnode_has_op(dev->fwnode, add_links) > - && fwnode_call_int_op(dev->fwnode, add_links, dev)) > - device_link_wait_for_mandatory_supplier(dev, true); > + if (fwnode_has_op(dev->fwnode, add_links)) { fw_ret can be defined here and I'd just call it "ret". > + fw_ret = fwnode_call_int_op(dev->fwnode, add_links, dev); > + if (fw_ret == -ENODEV) > + device_link_wait_for_mandatory_supplier(dev); > + else if (fw_ret) > + device_link_wait_for_optional_supplier(dev); > + } > > bus_probe_device(dev); > if (parent) > diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h > index 25bb81f8ded8..a19134eae5a5 100644 > --- a/include/linux/fwnode.h > +++ b/include/linux/fwnode.h > @@ -96,10 +96,15 @@ struct fwnode_reference_args { > * available suppliers. > * > * Return 0 if device links have been successfully created to all > - * the suppliers of this device or if the supplier information is > - * not known. Return an error if and only if the supplier > - * information is known but some of the suppliers are not yet > - * available to create device links to. > + * the suppliers this device needs to create device links to or if > + * the supplier information is not known. "the known suppliers of this device or if the supplier information is not known." > + * > + * Return -ENODEV if and only if the suppliers needed for probing > + * the device are not yet available to create device links to. It would be more precise to say something like this: "Return -ENODEV if an attempt to create a device link to one of the device's suppliers needed for probing it fails." > + * > + * Return -EAGAIN if there are suppliers that need to be linked to > + * that are not yet available but none of those suppliers are > + * necessary for probing this device. "Return -EAGAIN if attempts to create device links to some of the device's suppliers have failed, but those suppliers are not necessary for probing the device." > */ > struct fwnode_operations { > struct fwnode_handle *(*get)(struct fwnode_handle *fwnode); >