Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp445344imp; Wed, 20 Feb 2019 03:05:09 -0800 (PST) X-Google-Smtp-Source: AHgI3IaGAG+NNtE7JQ/DiWPKAEoX7TuTzoOXF3JFqa0/qawJUp8pNjZ2VOaVwmcsOaYBNugnkh07 X-Received: by 2002:a63:e309:: with SMTP id f9mr28470687pgh.280.1550660709553; Wed, 20 Feb 2019 03:05:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550660709; cv=none; d=google.com; s=arc-20160816; b=MMD6BNEUkchRHlpYHhi4MmMcG1Y9UKvpOg2nSXuyfriQ8aoNN9/aTzFhIJcEEYbxE3 v9VvSkgfusgrWc2Lbthg2OkbNfxCp8PukgOkEKnhMrYW3iYEi8I6uNii2aaJG+mvy9oR HRApsqqAbx6FB/4nUem8gebQVbAyY1AyrGzA/vUC0sjK8VCBq09Y/9ocGODIT2EfrsZc VGYRXvrQHfr1ksA6IRnji/60JNhkbCleY71fbX8jFhQyYNNC6lrY65/xlHT9OSHX86rc Pmu2d09xH46bHJRogOBRcKPzT/h1sIrivkXkOIq+Ngb84BHbtG0IGjNNWWcVRlIJpT5N bqug== 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=PBs2XhtYClrQVa/O6x8TbPWQ73Ug/tl966aoEH3rkUw=; b=EpdKraYVNwz/NrZTEyVypt/1aVWZLKuu5bgGs8nMDI9OWdObxmzkv4mvG5azqUgY1a dCauU1k9cKLbYWgVq1zUgsHnUJPVa84UPmu4BnLc3erMnwEMuJbar97TOSsB7bh2xMNx kf1KFay1sc/RdzY6wPWX8wkJhENJML+/omBq9mpvtvafvynU6J9cRdwyOlKMDEe9IuV9 IDkq+SLwCmrGap2piDNTRJcS0QCErGdRvJ+/ZLw+zIZM5SGjfLJr9ne7LV8PFFKAdzxO 3koQCcZ5jbgx+aqHK4DV0fkdtQaeb1wz2gjCw7JPc+bx4SWs7EWYaCWr8yskD13Mx8At RXNA== 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 o24si6432748pgh.114.2019.02.20.03.04.53; Wed, 20 Feb 2019 03:05:09 -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 S1727604AbfBTLC6 convert rfc822-to-8bit (ORCPT + 99 others); Wed, 20 Feb 2019 06:02:58 -0500 Received: from unicorn.mansr.com ([81.2.72.234]:44296 "EHLO unicorn.mansr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726370AbfBTLC5 (ORCPT ); Wed, 20 Feb 2019 06:02:57 -0500 Received: by unicorn.mansr.com (Postfix, from userid 51770) id CA65415632; Wed, 20 Feb 2019 11:02:56 +0000 (GMT) From: =?iso-8859-1?Q?M=E5ns_Rullg=E5rd?= To: "Rafael J. Wysocki" Cc: Greg Kroah-Hartman , Linux Kernel Mailing List Subject: Re: [PATCH] platform: set of_node in platform_device_register_full() References: <20190216164512.9525-1-mans@mansr.com> Date: Wed, 20 Feb 2019 11:02:56 +0000 In-Reply-To: (Rafael J. Wysocki's message of "Wed, 20 Feb 2019 11:51:01 +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 "Rafael J. Wysocki" writes: > On Wed, Feb 20, 2019 at 11:41 AM M?ns Rullg?rd wrote: >> >> "Rafael J. Wysocki" writes: >> >> > On Mon, Feb 18, 2019 at 12:10 PM M?ns Rullg?rd wrote: >> >> >> >> "Rafael J. Wysocki" writes: >> >> >> >> > On Sat, Feb 16, 2019 at 5:50 PM Mans Rullgard wrote: >> >> >> >> >> >> If the provided fwnode is an OF node, set dev.of_node as well. >> >> >> >> >> >> 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)); >> >> > >> >> > of_node_get() generally does a kobject_get() on the node's kobject, so >> >> > when is that reference dropped? Or if it doesn't need to be dropped >> >> > at all, why is this the case? >> >> >> >> platform_device_release() calls of_device_node_put(). >> > >> > Yes, it does, but this is the reference that's already acquired for >> > devices added while parsing DT, isn't it? >> > >> > Your change adds an extra reference AFAICS. >> > >> > Also, why is this patch needed? >> >> 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 other >> cases, the same real driver matches the DT node directly. When a glue >> device is used, it needs to get a reference to the original DT node in >> order for the main driver to access properties and child nodes. >> >> Right now, my problem is that the suxi-musb driver creates such a glue >> device for the musb core driver to bind to without setting of_node. >> This means devices attached to this USB interface don't get associated >> with DT nodes, if present, the way they do with EHCI. > > You really should describe problems that you want to address in patch > changelogs. This helps a lot to understand the motivation for the > changes. Do you want me to send a new patch with the above explanation in the commit message? >> The sunxi-musb driver uses platform_device_register_full(), so this >> seemed like the easiest way to let it set of_node of the new device. >> Since this creates a second reference to the same node, of_node_get() >> is required. > > But what about devices that already have of_node set at this point? > > Maybe check if of_node is NULL before trying to set it? It's a brand new device allocated a few lines above. of_node has to be null here. -- M?ns Rullg?rd