Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4858047imm; Mon, 14 May 2018 14:33:15 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrIgfZQLlrIwzeZICst1w4hAK4pgJEB23gbnJQj+SozWBHw6kLgyZxseuX9H/Wt7PTaPXip X-Received: by 2002:a62:3745:: with SMTP id e66-v6mr12019798pfa.43.1526333594940; Mon, 14 May 2018 14:33:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526333594; cv=none; d=google.com; s=arc-20160816; b=CO+4OafgZZTjBqHQUF+35AOR9kU5gEC0WtLbrlyd1/bvBwv1mS8CuamUYHcJshVBye oBLu3CGNyTVyF7+QeChPGjgAyL6RD7B07UkrGn2as8+rbrhKWg1U7QcmVSWRbIq1wQSI suCkxORkstlykvyNjRLJBIxHvBjw7ArU1WCXAVVLlc1Mna/o+ahbdcWkiM6bHHrINP8S BrXv9w9c6lvXTNWmYsa6d3fz8d1scM1u8QFkXr6Dr1hGjqyxAhS7z2wPyWzoh7qUtORz 1NIfFp33UoHrf05egETEUjRSlCjobyjvWGHYRINzw6ztndny5ss/YUmuuz089GRf9azq JYbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=RXuPDg5rbCIi6Yj3q3dS0bITqQynhtM5o3AhF9R4xw0=; b=nU4mQdOwvYlZum/DiTqVAkTRYLbbfYlKm8rvgjWorY1x8G/ktU/gfuFiyw9sZ1G2WN j1uJUXTwUDbofvqm+fKiPiWDKsSsip9PsvUsuR8JF5klrPes57fOyDqsAd+AQYnzx/2K v0as2PxfJcCxlimQfsoMFG4ie9KSYJrkRrIJfz9dU+yFB6RbwQTQSQfLQVOUhn0smIAu YkCjYvYh33So2Tg0DjT1RFPsG7njXdHIm38KWZwmQhvUTtuCG9Ws7ApKzCS3Vdwm48U+ N0J3d8Ebj54BdCT2iHL0BhoTOVQu4G+AHUPxvMgq3DlpLTWJbQWFr/p2v6pn79Shi+tJ nWGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Mj5Uuvyn; 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 y16-v6si9977896pfm.140.2018.05.14.14.33.00; Mon, 14 May 2018 14:33:14 -0700 (PDT) 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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Mj5Uuvyn; 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 S1752698AbeENVcJ (ORCPT + 99 others); Mon, 14 May 2018 17:32:09 -0400 Received: from mail-vk0-f66.google.com ([209.85.213.66]:39771 "EHLO mail-vk0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752582AbeENVcE (ORCPT ); Mon, 14 May 2018 17:32:04 -0400 Received: by mail-vk0-f66.google.com with SMTP id g83-v6so8451004vkc.6; Mon, 14 May 2018 14:32:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=RXuPDg5rbCIi6Yj3q3dS0bITqQynhtM5o3AhF9R4xw0=; b=Mj5Uuvyn59f5mOExnutjG7IDZqACmbSmhCPjgNthzPwubRxxa+zPC924M6/RitRa86 pJXdQP0C/SaPx8AEJvDxDukFsDkYNjTLmcSMGOBgZG0oyeUC3gbVotIb7GLdpXZM9lgj ZVCZw+I6J5L4u6r2YYkz0I0SMLH/C1l8wEzr4nfaC2QY+HUi/la1syafPBYbFuMni+zC Doog5WPHjcYp/94WWPtb52+X/3TpLAWiRnThC+zn/viHGwF/i2wozHMb7Pts3HQam//e 5dyOSVj9XB5SatGJ4k0M1uTSoiR2WnaYxOs9uJMBIM/OCEQDRdN9Nd0f25ixSxufPqcf ybnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=RXuPDg5rbCIi6Yj3q3dS0bITqQynhtM5o3AhF9R4xw0=; b=YXhzbIoGmin4YIYuVON5XAdTmDUfo9EjAa4/0rBX6aOO7nzb+EVXJbZpFvyNWVOF9f vSnXU9V2/W9mmL1N5EtSoIEC2wnHPOQX3c0J57sbrL5ZnDdT8fXxl+yFQA0/5KF7E7A1 pMENdLTvKp3cQUHC2QiGNr7+6Y0U+BZenv8YjLy/v1ZKVRlTz+4AeOrJc91xEeYU8byO OvPVKHLRpLpvazpgkoRojA2Urn6qXNNQFen636qmuOzaTmRZbsUA0w89k366mur/5rvr w7Qi+Gjl5BYYO1Ks5MVBbQa5R9Gi8pes/1C1FMbS+ipbdtabOyPbJMkPHivFoM0jKTJF RwFA== X-Gm-Message-State: ALKqPwcmqDUyQrqPsdz16lY6drqQjVYJeAIXyG7bBybzws9cmUDJOBSF kDUJ86RoJWPYwSipE38rIAJ2IlPpp/nsfMxtvBo= X-Received: by 2002:a1f:8994:: with SMTP id l142-v6mr12328321vkd.50.1526333523537; Mon, 14 May 2018 14:32:03 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.122.10 with HTTP; Mon, 14 May 2018 14:32:02 -0700 (PDT) In-Reply-To: <20180511162028.20616-13-brgl@bgdev.pl> References: <20180511162028.20616-1-brgl@bgdev.pl> <20180511162028.20616-13-brgl@bgdev.pl> From: Geert Uytterhoeven Date: Mon, 14 May 2018 23:32:02 +0200 X-Google-Sender-Auth: _tJGpww_npuLInz__AuWwdwvX2M Message-ID: Subject: Re: [PATCH 12/12] of/platform: make the OF code aware of early platform drivers To: Bartosz Golaszewski Cc: 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 , Magnus Damm , Johan Hovold , Rob Herring , Frank Rowand , Linux ARM , Linux Kernel Mailing List , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Linux-Arch , Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Bartosz, On Fri, May 11, 2018 at 6:20 PM, Bartosz Golaszewski wrote: > 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 Thanks for your patch! > --- a/drivers/of/platform.c > +++ b/drivers/of/platform.c > @@ -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; > + } The above may become cleaner if: 1. of_early_to_platform_device() would return NULL instead -ENOENT, 2. of_device_alloc() would be split in alloc and init phases, too. Then you can do: dev = of_node_check_flag(np, OF_POPULATED_EARLY) ? of_early_to_platform_device(np) : __of_device_alloc(np, bus_id, parent); if (!dev) goto err_clear_flag; of_device_init(dev, np, bus_id, parent); Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds