From patchwork Tue Jul 28 13:19:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 6884821 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1683EC05AC for ; Tue, 28 Jul 2015 13:23:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 388DC2065B for ; Tue, 28 Jul 2015 13:23:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5387B206BE for ; Tue, 28 Jul 2015 13:23:43 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZK4oU-0004yq-EG; Tue, 28 Jul 2015 13:20:58 +0000 Received: from mail-wi0-x231.google.com ([2a00:1450:400c:c05::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZK4oR-0004sx-3s for linux-arm-kernel@lists.infradead.org; Tue, 28 Jul 2015 13:20:55 +0000 Received: by wibxm9 with SMTP id xm9so160466021wib.1 for ; Tue, 28 Jul 2015 06:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=2ed2kd8AAegIOJLe5aVzeqK8MnhBREokmifYWfNcYYI=; b=KOiJ+SN8dDmWel9wuykb/u/HxqHGDfnPQCKeHl2yWhDdNKRPwM19emqTTFkSj/jCsD 9CzXtsycG5HjjijcPCiBUj2HDQB/yADVfZy42CLFV5KXsnemXAQ7Xt7OTYKM26BfuI5f VWTUUOb9l/yDgMd514t8kuwQEC+6BW6deTU+pUF5KHP8Jb6Jm2XdNULxw4eraY82+l7x Didar8T5les92U4u7kjjLHHrqS7wKSbuoH2YaBLgY3ku7E/dsOPtRxJvE8WV6MGAWTgw +41scELZpzS4hDnKOTMKNUiUwUyzYjt9zjDKjOgHy3qOVDeCDP3wZ0C9sBankPE31G1c IcWg== X-Received: by 10.194.58.167 with SMTP id s7mr40527683wjq.69.1438089633553; Tue, 28 Jul 2015 06:20:33 -0700 (PDT) Received: from cizrna.lan ([109.72.12.179]) by smtp.gmail.com with ESMTPSA id h9sm33265696wjx.20.2015.07.28.06.20.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jul 2015 06:20:32 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Subject: [PATCH v2 01/22] platform: delay device-driver matches until late_initcall Date: Tue, 28 Jul 2015 15:19:32 +0200 Message-Id: <1438089593-7696-2-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1438089593-7696-1-git-send-email-tomeu.vizoso@collabora.com> References: <1438089593-7696-1-git-send-email-tomeu.vizoso@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150728_062055_309210_9F138A07 X-CRM114-Status: GOOD ( 14.42 ) X-Spam-Score: -2.4 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, Arnd Bergmann , Stephen Warren , Greg Kroah-Hartman , Linus Walleij , Dmitry Torokhov , "Rafael J. Wysocki" , Tomeu Vizoso , Javier Martinez Canillas , Mark Brown , Thierry Reding , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Delay matches of platform devices until late_initcall, when we are sure that all built-in drivers have been registered already. This is needed to prevent deferred probes because of some drivers not having registered yet. The reason why only platform devices are delayed is that some other devices are expected to be probed earlier than late_initcall, for example, the system PNP driver needs to probe its devices in fs_initcall. Signed-off-by: Tomeu Vizoso --- Changes in v2: - Move delay to platform.c drivers/base/platform.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 063f0ab15259..fcf654678e27 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -33,6 +33,8 @@ /* For automatically allocated device IDs */ static DEFINE_IDA(platform_devid_ida); +static bool enable_matches; + struct device platform_bus = { .init_name = "platform", }; @@ -839,6 +841,15 @@ static int platform_match(struct device *dev, struct device_driver *drv) struct platform_device *pdev = to_platform_device(dev); struct platform_driver *pdrv = to_platform_driver(drv); + /* + * Delay matches of platform devices until late_initcall, when we are + * sure that all built-in drivers have been registered already. This + * is needed to prevent deferred probes because of some drivers + * not having registered yet. + */ + if (!enable_matches) + return false; + /* When driver_override is set, only bind to the matching driver */ if (pdev->driver_override) return !strcmp(pdev->driver_override, drv->name); @@ -859,6 +870,23 @@ static int platform_match(struct device *dev, struct device_driver *drv) return (strcmp(pdev->name, drv->name) == 0); } +static int __probe_device(struct device *dev, void *data) +{ + device_initial_probe(dev); + + return 0; +} + +static int probe_delayed_matches_initcall(void) +{ + enable_matches = true; + + bus_for_each_dev(&platform_bus_type, NULL, NULL, __probe_device); + + return 0; +} +late_initcall(probe_delayed_matches_initcall); + #ifdef CONFIG_PM_SLEEP static int platform_legacy_suspend(struct device *dev, pm_message_t mesg)