From owner-svn-src-head@freebsd.org Wed Dec 2 14:21:17 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 997DAA3F4FE; Wed, 2 Dec 2015 14:21:17 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4FA8510F0; Wed, 2 Dec 2015 14:21:17 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tB2ELGFb002358; Wed, 2 Dec 2015 14:21:16 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tB2ELGHZ002356; Wed, 2 Dec 2015 14:21:16 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201512021421.tB2ELGHZ002356@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Wed, 2 Dec 2015 14:21:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r291648 - head/sys/dev/ofw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Dec 2015 14:21:17 -0000 Author: mmel Date: Wed Dec 2 14:21:16 2015 New Revision: 291648 URL: https://svnweb.freebsd.org/changeset/base/291648 Log: OFW: Move code for searching interrupt parent into separate function. It can be used by interrupt controller drivers. Approved by: kib (mentor) Modified: head/sys/dev/ofw/ofw_bus_subr.c head/sys/dev/ofw/ofw_bus_subr.h Modified: head/sys/dev/ofw/ofw_bus_subr.c ============================================================================== --- head/sys/dev/ofw/ofw_bus_subr.c Wed Dec 2 12:58:20 2015 (r291647) +++ head/sys/dev/ofw/ofw_bus_subr.c Wed Dec 2 14:21:16 2015 (r291648) @@ -430,6 +430,27 @@ ofw_bus_reg_to_rl(device_t dev, phandle_ return (0); } +/* + * Get interrupt parent for given node. + * Returns 0 if interrupt parent doesn't exist. + */ +phandle_t +ofw_bus_find_iparent(phandle_t node) +{ + phandle_t iparent; + + if (OF_searchencprop(node, "interrupt-parent", &iparent, + sizeof(iparent)) == -1) { + for (iparent = node; iparent != 0; + iparent = OF_parent(iparent)) { + if (OF_hasprop(iparent, "interrupt-controller")) + break; + } + iparent = OF_xref_from_node(iparent); + } + return (iparent); +} + int ofw_bus_intr_to_rl(device_t dev, phandle_t node, struct resource_list *rl, int *rlen) @@ -442,18 +463,11 @@ ofw_bus_intr_to_rl(device_t dev, phandle nintr = OF_getencprop_alloc(node, "interrupts", sizeof(*intr), (void **)&intr); if (nintr > 0) { - if (OF_searchencprop(node, "interrupt-parent", &iparent, - sizeof(iparent)) == -1) { - for (iparent = node; iparent != 0; - iparent = OF_parent(iparent)) { - if (OF_hasprop(iparent, "interrupt-controller")) - break; - } - if (iparent == 0) { - device_printf(dev, "No interrupt-parent found, " - "assuming direct parent\n"); - iparent = OF_parent(node); - } + iparent = ofw_bus_find_iparent(node); + if (iparent == 0) { + device_printf(dev, "No interrupt-parent found, " + "assuming direct parent\n"); + iparent = OF_parent(node); iparent = OF_xref_from_node(iparent); } if (OF_searchencprop(OF_node_from_xref(iparent), Modified: head/sys/dev/ofw/ofw_bus_subr.h ============================================================================== --- head/sys/dev/ofw/ofw_bus_subr.h Wed Dec 2 12:58:20 2015 (r291647) +++ head/sys/dev/ofw/ofw_bus_subr.h Wed Dec 2 14:21:16 2015 (r291648) @@ -82,7 +82,7 @@ const char *ofw_bus_get_status(device_t int ofw_bus_status_okay(device_t dev); /* Helper to get node's interrupt parent */ -void ofw_bus_find_iparent(phandle_t); +phandle_t ofw_bus_find_iparent(phandle_t); /* Helper routine for checking compat prop */ int ofw_bus_is_compatible(device_t, const char *);