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: 10031487 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 365F1602D6 for ; Sun, 29 Oct 2017 13:50:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24A572879D for ; Sun, 29 Oct 2017 13:50:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15EC1286BF; Sun, 29 Oct 2017 13:50:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5F623286BF for ; Sun, 29 Oct 2017 13:50:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=+x3ysHSdbMqYUuVbFCXU6gqZPkkNDn8pxczl/qhNF8U=; b=JJjSm0U3WpAUw0M6ebqPwFm8IZ 8xl6IcheWbHq83EJ+gOs10rQVAfgYelNH9266jQqD04jtuwp9fB2DEYICVW7D+gNoXgFuO0om896H pRKzriR5iXMP5ZDYr86jCiYy4AZ+qlZF5IBSLl+zZujj4MUghnrH5dVzgU+xfGIYVaQjBf1rW/Tm8 56PbqVs+sFPl8sjp/mgUO4Icz2lPT3/KEN4Mdp9oxxH5v+vNQl4p9eFgyDf0RRczvakOaNAnht8Lu xTWpjpdp902kLXlbQlgu1jU4HLqo0n36cXGhKTeg60PB33xrPWYxFBfEZIX9Js8O8+J03tcdxRvDY 6Q9bt3iA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e8nyU-0004XN-8z; Sun, 29 Oct 2017 13:50:02 +0000 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e8ny2-0004E2-MN for linux-arm-kernel@lists.infradead.org; Sun, 29 Oct 2017 13:49:36 +0000 Received: by mail-pf0-x241.google.com with SMTP id d28so8664963pfe.2 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=Y89AJudNPMkbnbi8RfjB7pcLkjyFCNH2Yc5CCN57esVmh4jDbpzuo4TFc8mTtjxAGg mI2f38zPU8KjTPUIUkRPljVnWOOq894hpQGPD6ht1bX/iqN9787NWBFk2dsdt9hKVwER EMIFEIBecVkCHyY4OlQBikcW8kmb4uGg7YrUjKbVlyeRnWA9fg4Pxnih8WVcKvoLiqew G4SJgHnppEMdtlilQDMMraSwDbm2NSnYM+XXQV7CG1m9tLkUM0PXQU9x0XxmnlOciz6j /2FmNpuPV/vrBGOb9mEJMqvfZSSWouU+rVBjb2w4tq7RaP+jnR7+F7Hwa08MItxKCn8u t7gA== X-Gm-Message-State: AMCzsaX22TifspkVk8BzKB1rqdUjZHvi8Ulu350eCB6xZ1ht+4DL52G/ ChKM1r5KlZpiu3EeuJJkE4+Zhw== 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 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: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171029_064934_789711_561A9F97 X-CRM114-Status: GOOD ( 10.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nm@ti.com, devicetree@vger.kernel.org, Rajendra Nayak , Frank Rowand , Viresh Kumar , s.hauer@pengutronix.de, Stephen Boyd , linux-kernel@vger.kernel.org, xuwei5@hisilicon.com, robdclark@gmail.com, robh+dt@kernel.org, fabio.estevam@nxp.com, Vincent Guittot , shawnguo@kernel.org, linux-arm-kernel@lists.infradead.org, l.stach@pengutronix.de MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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,