From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752265AbeEKQV4 (ORCPT ); Fri, 11 May 2018 12:21:56 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:44536 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752241AbeEKQVw (ORCPT ); Fri, 11 May 2018 12:21:52 -0400 X-Google-Smtp-Source: AB8JxZoMok5oqILkdW/GUzAGliKmgXox7uRFpKKRqn/Sa7lBSzLlDWjn2YZHiW8PLATYBJ6vmJOx4g== From: Bartosz Golaszewski To: Sekhar Nori , Kevin Hilman , David Lechner , Michael Turquette , Stephen Boyd , Arnd Bergmann , Greg Kroah-Hartman , Mark Rutland , Yoshinori Sato , Rich Felker , Andy Shevchenko , Marc Zyngier , "Rafael J . Wysocki" , Peter Rosin , Jiri Slaby , Thomas Gleixner , Daniel Lezcano , Geert Uytterhoeven , Magnus Damm , Johan Hovold , Rob Herring , Frank Rowand Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 12/12] of/platform: make the OF code aware of early platform drivers Date: Fri, 11 May 2018 18:20:28 +0200 Message-Id: <20180511162028.20616-13-brgl@bgdev.pl> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180511162028.20616-1-brgl@bgdev.pl> References: <20180511162028.20616-1-brgl@bgdev.pl> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bartosz Golaszewski Check the relevant flag in the device node and skip the allocation part for devices that were populated early. Signed-off-by: Bartosz Golaszewski --- drivers/of/platform.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 0e554fe1f325..91760e2d3dc7 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -21,6 +21,7 @@ #include #include #include +#include const struct of_device_id of_default_bus_match_table[] = { { .compatible = "simple-bus", }, @@ -196,9 +197,17 @@ static struct platform_device *of_platform_device_create_pdata( of_node_test_and_set_flag(np, OF_POPULATED)) return NULL; - dev = of_device_alloc(np, bus_id, parent); - if (!dev) - goto err_clear_flag; + if (of_node_check_flag(np, OF_POPULATED_EARLY)) { + dev = of_early_to_platform_device(np); + if (IS_ERR(dev)) + goto err_clear_flag; + + of_device_init(dev, np, bus_id, parent); + } else { + dev = of_device_alloc(np, bus_id, parent); + if (!dev) + goto err_clear_flag; + } dev->dev.bus = &platform_bus_type; dev->dev.platform_data = platform_data; -- 2.17.0