From patchwork Mon Sep 7 12:23:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 7134341 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 44505BEEC1 for ; Mon, 7 Sep 2015 12:26:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 770F520673 for ; Mon, 7 Sep 2015 12:26:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A49232066B for ; Mon, 7 Sep 2015 12:26:56 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZYvTi-00084m-G3; Mon, 07 Sep 2015 12:24:54 +0000 Received: from mail-wi0-x236.google.com ([2a00:1450:400c:c05::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZYvTN-0007tX-Eo for linux-arm-kernel@lists.infradead.org; Mon, 07 Sep 2015 12:24:34 +0000 Received: by wicge5 with SMTP id ge5so82206346wic.0 for ; Mon, 07 Sep 2015 05:24:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=PIE8VJWyegYoZLwP0lVHrg+JtfVzbUgjcO20AbL0ohk=; b=lwPE26xme4ZnVzqs1nIY82RYQevwG4OOuYr2b1y60IDCepXbqevvtHsnlsnqr7k3Zj Lxu6jSpGt6oq6XB0JcsIWjoEbFYCu9R9/I1/bGsbafbYjrSs9SsS2jjHKlpMKzd+sL67 7TY9OVjdksBcCaKtZB7erQofBXuHRL8M5PCM73pDgaDEK4PYj7OecD7d1XtwtjiqeklS AOgZa98Vxm85h/eYP5FYvLolGJndefNaoEbZ2426WmXopt98XKxKL4AD1sTS7hxG2iUn lOK5uRqzJrqB1E/huZr//epPqPAVpKluMA77Q+VtT8jKaukzBlQ7vsb41D3lU9Yw0j2i Tdjw== X-Received: by 10.194.179.137 with SMTP id dg9mr35424940wjc.55.1441628651916; Mon, 07 Sep 2015 05:24:11 -0700 (PDT) Received: from cizrna.lan ([109.72.12.78]) by smtp.gmail.com with ESMTPSA id cm6sm15438wib.22.2015.09.07.05.24.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2015 05:24:11 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Subject: [PATCH v4 03/22] of/platform: Point to struct device from device node Date: Mon, 7 Sep 2015 14:23:28 +0200 Message-Id: <1441628627-5143-4-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441628627-5143-1-git-send-email-tomeu.vizoso@collabora.com> References: <1441628627-5143-1-git-send-email-tomeu.vizoso@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150907_052433_656057_817C70B6 X-CRM114-Status: GOOD ( 17.24 ) X-Spam-Score: -2.3 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tomeu Vizoso , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, Arnd Bergmann , Stephen Warren , Linus Walleij , Dmitry Torokhov , "Rafael J. Wysocki" , Rob Herring , Javier Martinez Canillas , Mark Brown , Thierry Reding , Grant Likely , Frank Rowand , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When adding a platform device, set the device node's device member to point to it. This speeds lookups considerably and is safe because we only create one platform device for any given device node. Signed-off-by: Tomeu Vizoso --- Changes in v4: None Changes in v3: None Changes in v2: None drivers/of/platform.c | 13 +++++-------- include/linux/of.h | 1 + 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 1001efaedcb8..baf04d7249bd 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -32,11 +32,6 @@ const struct of_device_id of_default_bus_match_table[] = { {} /* Empty terminated list */ }; -static int of_dev_node_match(struct device *dev, void *data) -{ - return dev->of_node == data; -} - /** * of_find_device_by_node - Find the platform_device associated with a node * @np: Pointer to device tree node @@ -45,10 +40,10 @@ static int of_dev_node_match(struct device *dev, void *data) */ struct platform_device *of_find_device_by_node(struct device_node *np) { - struct device *dev; + if (np->device && np->device->bus == &platform_bus_type) + return to_platform_device(np->device); - dev = bus_find_device(&platform_bus_type, NULL, np, of_dev_node_match); - return dev ? to_platform_device(dev) : NULL; + return NULL; } EXPORT_SYMBOL(of_find_device_by_node); @@ -192,6 +187,8 @@ static struct platform_device *of_platform_device_create_pdata( goto err_clear_flag; } + np->device = &dev->dev; + return dev; err_clear_flag: diff --git a/include/linux/of.h b/include/linux/of.h index 2194b8ca41f9..eb091be0f8ee 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -52,6 +52,7 @@ struct device_node { phandle phandle; const char *full_name; struct fwnode_handle fwnode; + struct device *device; struct property *properties; struct property *deadprops; /* removed properties */