From patchwork Sun Oct 29 13:48:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 831733 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=devicetree-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Zmf6B5R/"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yPzY673v6z9t2M for ; Mon, 30 Oct 2017 00:51:22 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751487AbdJ2NtY (ORCPT ); Sun, 29 Oct 2017 09:49:24 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:55224 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751395AbdJ2NtO (ORCPT ); Sun, 29 Oct 2017 09:49:14 -0400 Received: by mail-pf0-f196.google.com with SMTP id n89so8651824pfk.11 for ; Sun, 29 Oct 2017 06:49:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=MGNME3iV88Fpl6OXn/v2oDG0HfU336eiLHOcuqQrUh8=; b=Zmf6B5R/B7RNNkMCqqYtu+GmYtZDyoWShuQGUD3nY2hnvrpTRA8Jj7SbASMiUX0K+P gh4jaUgDqM1eKkd81Z7QMJRt8TNHMmcuEE+yJusoNXamjpNdph3BH85ENjhvwZcB947k 6Zi3wRW8rrl+i0yxtE4mzSvm+m8Cy0MiLdryg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=MGNME3iV88Fpl6OXn/v2oDG0HfU336eiLHOcuqQrUh8=; b=NYz8VSAVuzF/gY33MXAk0XsL5uHknzjlDO+d1ZDiqAy1HguN8p5LnPlJbb12POTWCh 99WFtU+4hZWWQ+CkukcZs6y4LaBpT2M3yEVaWreqfrUmAN6Vs/cKtRmZL/f3//SgPc3F VIlLTJYai2c3YMxphZ1EDFnApQeBAUv/Eonnt7RhKY+39Nn5TCjGlFG+CBEB0TQ6T+Xh QLfOtFKd5DauBB4o+v20zZzbv0Lj2gOAEaVb5Er8pi+yO9/+YAgetTnRl4YvRGB97J4x lgvABi2kWGp/YpRjKk6TnkOkYdrMRoeF1ZtU8F7duAlv7J99a2xiy16mpaNIJxgD5vdE vIqw== X-Gm-Message-State: AMCzsaVWneiYlj+gVN7Nd0KPC9q3EYFTBdGDdOHgX2ZzZo56zyErje5x LpsjArMGtgLoTdxlgsLK6H+wHw== X-Google-Smtp-Source: ABhQp+S4eIai9OoUtQiLiQlmGauDnzYXmgyHf2iGcSXyW1lg27mIOUFYh5OavZb/dG/Q1ubTPW6mUg== X-Received: by 10.98.181.1 with SMTP id y1mr5705387pfe.240.1509284953561; Sun, 29 Oct 2017 06:49:13 -0700 (PDT) Received: from localhost ([122.167.161.211]) by smtp.gmail.com with ESMTPSA id i8sm20407967pgq.67.2017.10.29.06.49.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Oct 2017 06:49:13 -0700 (PDT) From: Viresh Kumar To: Greg Kroah-Hartman Cc: Viresh Kumar , Vincent Guittot , Stephen Boyd , Rajendra Nayak , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robdclark@gmail.com, s.hauer@pengutronix.de, l.stach@pengutronix.de, shawnguo@kernel.org, fabio.estevam@nxp.com, nm@ti.com, xuwei5@hisilicon.com, robh+dt@kernel.org, Frank Rowand , devicetree@vger.kernel.org Subject: [PATCH V4 01/12] of: platform: Add of_find_amba_device_by_node() Date: Sun, 29 Oct 2017 19:18:49 +0530 Message-Id: <80731ad75f52781bf1d5fb1a1a211ee59b4a2ffb.1509284255.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.15.0.rc1.236.g92ea95045093 In-Reply-To: References: In-Reply-To: References: Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org of_find_device_by_node() works only with platform devices. Lets create one for amba devices as well. Cc: Frank Rowand Cc: devicetree@vger.kernel.org Signed-off-by: Viresh Kumar --- drivers/of/platform.c | 20 ++++++++++++++++++++ include/linux/of_platform.h | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index ac15d0e3d27d..b38a8e5908a3 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -60,6 +60,26 @@ struct platform_device *of_find_device_by_node(struct device_node *np) } EXPORT_SYMBOL(of_find_device_by_node); +#ifdef CONFIG_ARM_AMBA +/** + * of_find_amba_device_by_node - Find the amba_device associated with a node + * @np: Pointer to device tree node + * + * Takes a reference to the embedded struct device which needs to be dropped + * after use. + * + * Returns amba_device pointer, or NULL if not found + */ +struct amba_device *of_find_amba_device_by_node(struct device_node *np) +{ + struct device *dev; + + dev = bus_find_device(&amba_bustype, NULL, np, of_dev_node_match); + return dev ? to_amba_device(dev) : NULL; +} +EXPORT_SYMBOL(of_find_amba_device_by_node); +#endif + #ifdef CONFIG_OF_ADDRESS /* * The following routines scan a subtree and registers a device for diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h index 8a561e08bc9e..fbf8a6443885 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h @@ -61,6 +61,15 @@ static inline struct platform_device *of_find_device_by_node(struct device_node } #endif +#if defined(CONFIG_OF) && defined(CONFIG_ARM_AMBA) +extern struct amba_device *of_find_amba_device_by_node(struct device_node *np); +#else +static inline struct amba_device *of_find_amba_device_by_node(struct device_node *np) +{ + return NULL; +} +#endif + #ifdef CONFIG_OF_ADDRESS /* Platform drivers register/unregister */ extern struct platform_device *of_device_alloc(struct device_node *np,