From owner-svn-src-all@FreeBSD.ORG Thu Jun 11 18:29:12 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 356BC106566C; Thu, 11 Jun 2009 18:29:12 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0A1BB8FC13; Thu, 11 Jun 2009 18:29:12 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5BITBTn056768; Thu, 11 Jun 2009 18:29:11 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5BITBfd056767; Thu, 11 Jun 2009 18:29:11 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <200906111829.n5BITBfd056767@svn.freebsd.org> From: Andriy Gapon Date: Thu, 11 Jun 2009 18:29:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r194034 - in stable/7/sys: . contrib/pf dev/ath/ath_hal kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jun 2009 18:29:12 -0000 Author: avg Date: Thu Jun 11 18:29:11 2009 New Revision: 194034 URL: http://svn.freebsd.org/changeset/base/194034 Log: MFC r192379: sysctl_rman: report shared resources to devinfo Approved by: jhb (mentor) Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/kern/subr_rman.c Modified: stable/7/sys/kern/subr_rman.c ============================================================================== --- stable/7/sys/kern/subr_rman.c Thu Jun 11 18:19:48 2009 (r194033) +++ stable/7/sys/kern/subr_rman.c Thu Jun 11 18:29:11 2009 (r194034) @@ -835,6 +835,7 @@ sysctl_rman(SYSCTL_HANDLER_ARGS) int rman_idx, res_idx; struct rman *rm; struct resource_i *res; + struct resource_i *sres; struct u_rman urm; struct u_resource ures; int error; @@ -880,35 +881,44 @@ sysctl_rman(SYSCTL_HANDLER_ARGS) */ mtx_lock(rm->rm_mtx); TAILQ_FOREACH(res, &rm->rm_list, r_link) { - if (res_idx-- == 0) { - bzero(&ures, sizeof(ures)); - ures.r_handle = (uintptr_t)res; - ures.r_parent = (uintptr_t)res->r_rm; - ures.r_device = (uintptr_t)res->r_dev; - if (res->r_dev != NULL) { - if (device_get_name(res->r_dev) != NULL) { - snprintf(ures.r_devname, RM_TEXTLEN, - "%s%d", - device_get_name(res->r_dev), - device_get_unit(res->r_dev)); - } else { - strlcpy(ures.r_devname, "nomatch", - RM_TEXTLEN); + if (res->r_sharehead != NULL) { + LIST_FOREACH(sres, res->r_sharehead, r_sharelink) + if (res_idx-- == 0) { + res = sres; + goto found; } - } else { - ures.r_devname[0] = '\0'; - } - ures.r_start = res->r_start; - ures.r_size = res->r_end - res->r_start + 1; - ures.r_flags = res->r_flags; - - mtx_unlock(rm->rm_mtx); - error = SYSCTL_OUT(req, &ures, sizeof(ures)); - return (error); } + else if (res_idx-- == 0) + goto found; } mtx_unlock(rm->rm_mtx); return (ENOENT); + +found: + bzero(&ures, sizeof(ures)); + ures.r_handle = (uintptr_t)res; + ures.r_parent = (uintptr_t)res->r_rm; + ures.r_device = (uintptr_t)res->r_dev; + if (res->r_dev != NULL) { + if (device_get_name(res->r_dev) != NULL) { + snprintf(ures.r_devname, RM_TEXTLEN, + "%s%d", + device_get_name(res->r_dev), + device_get_unit(res->r_dev)); + } else { + strlcpy(ures.r_devname, "nomatch", + RM_TEXTLEN); + } + } else { + ures.r_devname[0] = '\0'; + } + ures.r_start = res->r_start; + ures.r_size = res->r_end - res->r_start + 1; + ures.r_flags = res->r_flags; + + mtx_unlock(rm->rm_mtx); + error = SYSCTL_OUT(req, &ures, sizeof(ures)); + return (error); } SYSCTL_NODE(_hw_bus, OID_AUTO, rman, CTLFLAG_RD, sysctl_rman,