From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752730AbeENVcJ (ORCPT ); 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 X-Google-Smtp-Source: AB8JxZp6fDm6Yx9oV0uMQw2KMAkjvkh5Im8yhwCWGhEGb4Yn2ndKZxRMQrAvXzMjVhqDt2DWW4YR2IIofAt7di44omk= MIME-Version: 1.0 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 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Geert Uytterhoeven Subject: Re: [PATCH 12/12] of/platform: make the OF code aware of early platform drivers Date: Mon, 14 May 2018 23:32:02 +0200 Message-ID: References: <20180511162028.20616-1-brgl@bgdev.pl> <20180511162028.20616-13-brgl@bgdev.pl> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: <20180511162028.20616-13-brgl@bgdev.pl> Sender: linux-kernel-owner@vger.kernel.org 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 List-Id: devicetree@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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: geert@linux-m68k.org (Geert Uytterhoeven) Date: Mon, 14 May 2018 23:32:02 +0200 Subject: [PATCH 12/12] of/platform: make the OF code aware of early platform drivers In-Reply-To: <20180511162028.20616-13-brgl@bgdev.pl> References: <20180511162028.20616-1-brgl@bgdev.pl> <20180511162028.20616-13-brgl@bgdev.pl> Message-ID: To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.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 at 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