lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <yw1ximxewte5.fsf@mansr.com>
Date:   Wed, 20 Feb 2019 12:12:34 +0000
From:   Måns Rullgård <mans@...sr.com>
To:     Johan Hovold <johan@...nel.org>
Cc:     "Rafael J. Wysocki" <rafael@...nel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] platform: set of_node in platform_device_register_full()

Johan Hovold <johan@...nel.org> writes:

> On Wed, Feb 20, 2019 at 11:35:06AM +0000, Mans Rullgard wrote:
>> If the provided fwnode is an OF node, set dev.of_node as well.
>> 
>> Some drivers are just shims that create extra "glue" devices with the
>> DT device as parent and have the real driver bind to these.  In these
>> cases, the glue device needs to get a reference to the original DT node
>> in order for the main driver to access properties and child nodes.
>> 
>> For example, the sunxi-musb driver creates such a glue device using
>> platform_device_register_full().  Consequently, devices attached to
>> this USB interface don't get associated with DT nodes, if present,
>> the way they do with EHCI.
>> 
>> This change will allow sunxi-musb and similar driver to easily
>> propagate the DT node to child devices as required.
>
> Just a drive-by comment, didn't look to closely at this patch, but this
> all sounds familiar.
>
> Note that if both platform devices are bound to drivers you may end up
> with some resources like pinctrl which are handled automatically by
> driver core at probe time to be requested twice (and failing the second
> time).
>
> Take a look at 4e75e1d7dac9 ("driver core: add helper to reuse a
> device-tree node"), which provides a means to avoid this, and
> 49484abd93ab ("USB: musb: dsps: propagate device-tree node").

Thanks, and ugh.  So we should be setting the of_node_reused flag when
this is the case.  It's easy for the musb-dsps driver since it doesn't
use platform_device_register_full() and can do this before the
device_add() call.  How can we convey that this flag needs to be set?

>> Signed-off-by: Mans Rullgard <mans@...sr.com>
>> ---
>>  drivers/base/platform.c | 1 +
>>  1 file changed, 1 insertion(+)
>> 
>> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
>> index dff82a3c2caa..853a1d0e5845 100644
>> --- a/drivers/base/platform.c
>> +++ b/drivers/base/platform.c
>> @@ -512,6 +512,7 @@ struct platform_device *platform_device_register_full(
>>  
>>  	pdev->dev.parent = pdevinfo->parent;
>>  	pdev->dev.fwnode = pdevinfo->fwnode;
>> +	pdev->dev.of_node = of_node_get(to_of_node(pdev->dev.fwnode));
>>  
>>  	if (pdevinfo->dma_mask) {
>>  		/*
>
> Johan

-- 
Måns Rullgård

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ