From patchwork Fri May 11 16:20:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10394707 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 353B860236 for ; Fri, 11 May 2018 16:32:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFCF728F4E for ; Fri, 11 May 2018 16:32:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B481B28F50; Fri, 11 May 2018 16:32:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 11C1228F4E for ; Fri, 11 May 2018 16:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=DvXOvgjY0hUIB6MI8uujZzlWFPcVxuw2x0hH5dCNss4=; b=WTuxTIbsnvb/vg+Ay7yuehUcaj X05p6hslRwStxUt7m0q8JQukUnuks0BEbFabGNPqsm2gfHLpmPOSMmjFkd7zTLXDSGY3YTsysj1yp La14H+Guer0MebB8IXsHMAsW2y7YObntQWwZIpGPSWSOBsCYS8O6uaMPatmRNFWNramOd7j25j8v6 IY6z/nevGsyl916kSvonbifcnnVfDScHNNsfOW95Y+Hxjop4T/BLbTLjsa1eVTdAwJVNJSfFKwy7f CXjgHNoXvItr+EQkyF3fhN7LktRyHeW4lz5wygRZmGkeP7GYA5M6WJG+5Jiz0SzkJJ7vz6jmKjvR7 WD0QC0ww==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fHAyI-00026k-N5; Fri, 11 May 2018 16:32:42 +0000 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fHAnz-0002mt-Ab for linux-arm-kernel@lists.infradead.org; Fri, 11 May 2018 16:22:07 +0000 Received: by mail-wr0-x244.google.com with SMTP id p4-v6so5914388wrh.3 for ; Fri, 11 May 2018 09:21:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DahAdSlzgc7DeiUSxkEimltI3pxa0xtlyVdWzMrvjGU=; b=RWhgBF2bpcE0B5hLyDslTLTAx8lknLzTfPXFV7YnRpG43rjtSVgpBDzMl4k4ESIlRk DoJCNNVPa6TS1Qt2Y2eMbIj9Er1EGJjXeaprzqCRbpa0ReP5ovz3mP6wYH+BVXALSYQR zBy4/73hjjMmLXIJ5f5h1TJO1xMTQvTJGF49IN3I/kZrujsbIlg1F/cXJTT0UYW4UAbl 8iU8y242fUkNVddVyw8I7oo71GRAE5XulbONTaQSM8XEfSI4oixBCxOOPSkMvBbVgMo+ Ke/29vcBOiANY9dAgbdMMIpAmLn69N2vmm5lC3+TiKZEcW9+fq3x0IM49muVYmDkq85b tvrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DahAdSlzgc7DeiUSxkEimltI3pxa0xtlyVdWzMrvjGU=; b=maJ9WzXmerbmpFmljcw+2zNG2QrjhDCjAjDxahre3jpDdVCz6HbEc1RWgGm18UmbNq Ad22V2OxeLHoEmTxzW1JVacJQlekeJHUPk/8dXMJORITdDCOXo+51vSywNlPdaa8hVXo aC3vfwgsEs5XCmfGeJPLqb8XQhtIoy5SyWFZbjDTAiOk9rIymQ88JNF0ORKeFPgXtmg9 fe23vBj10YOm+AxoscGEV/0xnNFfykoawpXNdf0Iqoy7MJcA2cAm17tM1uy8kVVNhf+I hFmS9WbZods3XjcjDXDldSUoSxBVCW9lRYdP5OZaxw/XOD2hmCVKAIF1AE/+Oty7Gczm j+Kw== X-Gm-Message-State: ALKqPwckbGA8KchDuQas2GJeIoevbCYpZjxA2Cn1jAovfLPB6iis9dgW 8c4FDOEamPOzOXG96Od0qevmgg== X-Google-Smtp-Source: AB8JxZoMok5oqILkdW/GUzAGliKmgXox7uRFpKKRqn/Sa7lBSzLlDWjn2YZHiW8PLATYBJ6vmJOx4g== X-Received: by 2002:adf:df02:: with SMTP id y2-v6mr5252392wrl.92.1526055711301; Fri, 11 May 2018 09:21:51 -0700 (PDT) Received: from brgl-bgdev.baylibre.local ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id q17-v6sm1429523wmf.3.2018.05.11.09.21.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 May 2018 09:21:50 -0700 (PDT) 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180511_092203_398183_2C7409E5 X-CRM114-Status: GOOD ( 15.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bartosz Golaszewski MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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;