Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp507562imp; Wed, 20 Feb 2019 04:13:53 -0800 (PST) X-Google-Smtp-Source: AHgI3IYJBMPBCDFx7E2/U/1GB8nK4zE+AQFhLKyu59v6FU82LihBBXuf9UhPCRRLSEozSjz38dy0 X-Received: by 2002:a17:902:583:: with SMTP id f3mr37164609plf.202.1550664833117; Wed, 20 Feb 2019 04:13:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550664833; cv=none; d=google.com; s=arc-20160816; b=LPexXcsIM1vPjqeF+6VC/h5ug11K+x0/RjpnN/r7gz7QMR82zFZaXGHBlZzyR4V79Y Xa85eCQfXD2XXpk0ZQ+JulkyUp9ZRt0y2XpVxbsxiP49UD29Sehkqp197yFDeC8AcXbt /tCpeaLn+EAjFs5ho0Ka8sC9WVKOsN+U2AKW5LQ4Au567yHvUTBsQivIBIjABktD7wsB 5/hZfoD7HCZHIGEq1+9Rx+sCuEJWzLePVTlNCgavpy9inwq5VWk4cG0KAfHHuGKkT2YY iiFt9iT+1m/R6L4TKqHQq+WJjMI3XpH5vDEXOmzV/K0d3uWEbDf+lQTzR/NiAuyK8nJH a+QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:message-id:in-reply-to:date:references:subject:cc:to :from; bh=fz+pbOL4/MhvL3sbqpO5EePyh5bEIyhAwP/TarM1CMM=; b=BLFhedXoN6VuO7bi7GM88W9eZt5kXlY6iZ+8SnKibH7sWdikSt7gq+OaAUjlqtjgHd h3Gfuk2zY4/02/U8VqCRmOMDEOK6tpn9bQjrsuHxJPZGRyddU5boh1Xv53SrEuFAN8BU pZQENjUlFobspH88WTsOOtjwgfL4C+4Ju/01GpjrTdbMb4rpxZKD2Nv/5eB4cNilpw54 Od40X4e1TW/JQ3ADnHJUIJTfGBW6VVzRmuE6VmJ7+fCDM7/hsvxH6O1gr4urjQiPN83n xcVPknbVJcJX7m+4njLwgPir8qx3tye9neKaWNj2zvZ8VTghP79dqwXrs+jrVEF1yJn6 /Log== ARC-Authentication-Results: i=1; mx.google.com; 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 e125si18641600pfe.14.2019.02.20.04.13.36; Wed, 20 Feb 2019 04:13:53 -0800 (PST) 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; 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 S1727404AbfBTMMg convert rfc822-to-8bit (ORCPT + 99 others); Wed, 20 Feb 2019 07:12:36 -0500 Received: from unicorn.mansr.com ([81.2.72.234]:44814 "EHLO unicorn.mansr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725836AbfBTMMg (ORCPT ); Wed, 20 Feb 2019 07:12:36 -0500 Received: by unicorn.mansr.com (Postfix, from userid 51770) id F288015632; Wed, 20 Feb 2019 12:12:34 +0000 (GMT) From: =?iso-8859-1?Q?M=E5ns_Rullg=E5rd?= To: Johan Hovold Cc: "Rafael J. Wysocki" , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: Re: [PATCH] platform: set of_node in platform_device_register_full() References: <20190216164512.9525-1-mans@mansr.com> <20190220113506.11009-1-mans@mansr.com> <20190220115117.GK4072@localhost> Date: Wed, 20 Feb 2019 12:12:34 +0000 In-Reply-To: <20190220115117.GK4072@localhost> (Johan Hovold's message of "Wed, 20 Feb 2019 12:51:17 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Johan Hovold 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 >> --- >> 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