From patchwork Fri Feb 21 16:51:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marian-Cristian Rotariu X-Patchwork-Id: 11396947 X-Patchwork-Delegate: pavel@denx.de Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C914313A4 for ; Fri, 21 Feb 2020 16:52:25 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AF9DC222C4 for ; Fri, 21 Feb 2020 16:52:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AF9DC222C4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=cip-dev-bounces@lists.cip-project.org Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id A0D3C87F38; Fri, 21 Feb 2020 16:52:25 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7XxTjsbHTZKg; Fri, 21 Feb 2020 16:52:24 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id DB0A2879A6; Fri, 21 Feb 2020 16:52:23 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C676FC1D88; Fri, 21 Feb 2020 16:52:23 +0000 (UTC) X-Original-To: cip-dev@lists.cip-project.org Delivered-To: cip-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9E8B1C013E for ; Fri, 21 Feb 2020 16:52:22 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 9BBF784BCF for ; Fri, 21 Feb 2020 16:52:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rEDVAAXbTT0u for ; Fri, 21 Feb 2020 16:52:21 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by whitealder.osuosl.org (Postfix) with ESMTP id C187D875DC for ; Fri, 21 Feb 2020 16:52:20 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.70,468,1574089200"; d="scan'208";a="39726128" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 22 Feb 2020 01:52:20 +0900 Received: from marian-VirtualBox.ree.adwin.renesas.com (unknown [10.226.36.164]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id A95D740A3602; Sat, 22 Feb 2020 01:52:19 +0900 (JST) From: Marian-Cristian Rotariu To: cip-dev@lists.cip-project.org Date: Fri, 21 Feb 2020 16:51:55 +0000 Message-Id: <1582303929-5773-9-git-send-email-marian-cristian.rotariu.rb@bp.renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1582303929-5773-1-git-send-email-marian-cristian.rotariu.rb@bp.renesas.com> References: <1582303929-5773-1-git-send-email-marian-cristian.rotariu.rb@bp.renesas.com> Subject: [cip-dev] [PATCH v2 4.19.y-cip 08/22] device property: Introduce fwnode_find_reference() X-BeenThere: cip-dev@lists.cip-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: cip-dev-bounces@lists.cip-project.org Sender: "cip-dev" From: Heikki Krogerus commit 83b34afb6b79c69f5478a7249451cab858af97d6 upstream. In most cases the references that the drivers look for don't have any arguments. This introduces a wrapper function for fwnode_property_get_reference_args() that looks for references by using only the name and index. Signed-off-by: Heikki Krogerus Tested-by: Hans de Goede Signed-off-by: Rafael J. Wysocki Signed-off-by: Marian-Cristian Rotariu --- drivers/base/property.c | 24 ++++++++++++++++++++++++ include/linux/property.h | 4 ++++ 2 files changed, 28 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 240ab52..52be8c8 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -946,6 +946,30 @@ static struct property_set *pset_copy_set(const struct property_set *pset) } /** + * fwnode_find_reference - Find named reference to a fwnode_handle + * @fwnode: Firmware node where to look for the reference + * @name: The name of the reference + * @index: Index of the reference + * + * @index can be used when the named reference holds a table of references. + * + * Returns pointer to the reference fwnode, or ERR_PTR. Caller is responsible to + * call fwnode_handle_put() on the returned fwnode pointer. + */ +struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode, + const char *name, + unsigned int index) +{ + struct fwnode_reference_args args; + int ret; + + ret = fwnode_property_get_reference_args(fwnode, name, NULL, 0, index, + &args); + return ret ? ERR_PTR(ret) : args.fwnode; +} +EXPORT_SYMBOL_GPL(fwnode_find_reference); + +/** * device_remove_properties - Remove properties from a device object. * @dev: Device whose properties to remove. * diff --git a/include/linux/property.h b/include/linux/property.h index 1a12364..216dcfe 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -78,6 +78,10 @@ int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode, unsigned int nargs, unsigned int index, struct fwnode_reference_args *args); +struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode, + const char *name, + unsigned int index); + struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode); struct fwnode_handle *fwnode_get_next_parent( struct fwnode_handle *fwnode);