From owner-dev-commits-src-main@freebsd.org Mon Jun 28 22:24:03 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DC5C465D83E; Mon, 28 Jun 2021 22:24:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GDMb64v4Jz4jx1; Mon, 28 Jun 2021 22:24:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8646E57F7; Mon, 28 Jun 2021 22:24:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15SMO2jS048749; Mon, 28 Jun 2021 22:24:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15SMO2NT048748; Mon, 28 Jun 2021 22:24:02 GMT (envelope-from git) Date: Mon, 28 Jun 2021 22:24:02 GMT Message-Id: <202106282224.15SMO2NT048748@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 1ed401626792 - main - cam: add xpt_path_sim_device to return device_t associated with a path MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1ed401626792b2888e2e29befb13c23ff2273c4e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jun 2021 22:24:03 -0000 The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=1ed401626792b2888e2e29befb13c23ff2273c4e commit 1ed401626792b2888e2e29befb13c23ff2273c4e Author: Warner Losh AuthorDate: 2021-06-28 21:57:51 +0000 Commit: Warner Losh CommitDate: 2021-06-28 21:57:51 +0000 cam: add xpt_path_sim_device to return device_t associated with a path Return the device associated with the sim's bus when it called xpt_bus_register, if any. Most real SIMs in the tree set this device, but some virtual ones do not have a device_t assocaited with them. Reviewed by: scottl@, mav@ (earlier version) Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D30853 --- sys/cam/cam_xpt.c | 18 +++++++++++++++++- sys/cam/cam_xpt.h | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index 81d5d98fb9d4..ee216451bd6d 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -5574,7 +5574,23 @@ camisr_runqueue(void) } } -struct kv +/** + * @brief Return the device_t associated with the path + * + * When a SIM is created, it registers a bus with a NEWBUS device_t. This is + * stored in the internal cam_eb bus structure. There is no guarnatee any given + * path will have a @c device_t associated with it (it's legal to call @c + * xpt_bus_register with a @c NULL @c device_t. + * + * @param path Path to return the device_t for. + */ +device_t +xpt_path_sim_device(const struct cam_path *path) +{ + return (path->bus->parent_dev); +} + +struct kv { uint32_t v; const char *name; diff --git a/sys/cam/cam_xpt.h b/sys/cam/cam_xpt.h index 7e7e6ac5880a..c8494d04234a 100644 --- a/sys/cam/cam_xpt.h +++ b/sys/cam/cam_xpt.h @@ -113,6 +113,7 @@ target_id_t xpt_path_target_id(struct cam_path *path); lun_id_t xpt_path_lun_id(struct cam_path *path); struct cam_sim *xpt_path_sim(struct cam_path *path); struct cam_periph *xpt_path_periph(struct cam_path *path); +device_t xpt_path_sim_device(const struct cam_path *path); void xpt_print_path(struct cam_path *path); void xpt_print_device(struct cam_ed *device); void xpt_print(struct cam_path *path, const char *fmt, ...);