Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Jun 2021 22:24:04 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: fdd60a97dad5 - main - sdiob: get the device_t from periph's path
Message-ID:  <202106282224.15SMO4IU048797@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=fdd60a97dad5a0e81905a5d97cbc4b496638b06f

commit fdd60a97dad5a0e81905a5d97cbc4b496638b06f
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2021-06-28 22:00:09 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2021-06-28 22:13:02 +0000

    sdiob: get the device_t from periph's path
    
    Use the new xpt_path_device to get the device_t using the periph's path.
    
    Sponsored by:           Netflix
    Differential Revision:  https://reviews.freebsd.org/D30855
---
 sys/dev/sdio/sdiob.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/sys/dev/sdio/sdiob.c b/sys/dev/sdio/sdiob.c
index afa111971bf5..6209aa1f242e 100644
--- a/sys/dev/sdio/sdiob.c
+++ b/sys/dev/sdio/sdiob.c
@@ -112,7 +112,7 @@ struct sdiob_softc {
 #define	NB_STATE_SIM_ADDED		0x0002
 #define	NB_STATE_READY			0x0004
 
-	/* CAM side (including sim_dev). */
+	/* CAM side. */
 	struct card_info		cardinfo;
 	struct cam_periph		*periph;
 	union ccb			*ccb;
@@ -923,23 +923,21 @@ sdio_newbus_sim_add(struct sdiob_softc *sc)
 	/* Add ourselves to our parent (SIM) device. */
 
 	/* Add ourselves to our parent. That way we can become a parent. */
-	KASSERT(sc->periph->sim->sim_dev != NULL, ("%s: sim_dev is NULL, sc %p "
-	    "periph %p sim %p\n", __func__, sc, sc->periph, sc->periph->sim));
+	pdev = xpt_path_sim_device(sc->periph->path);
+	KASSERT(pdev != NULL,
+	    ("%s: pdev is NULL, sc %p periph %p sim %p\n",
+	    __func__, sc, sc->periph, sc->periph->sim));
 
 	if (sc->dev == NULL)
-		sc->dev = BUS_ADD_CHILD(sc->periph->sim->sim_dev, 0,
-		    SDIOB_NAME_S, -1);
+		sc->dev = BUS_ADD_CHILD(pdev, 0, SDIOB_NAME_S, -1);
 	if (sc->dev == NULL)
 		return (ENXIO);
 	device_set_softc(sc->dev, sc);
+
 	/*
 	 * Don't set description here; devclass_add_driver() ->
 	 * device_probe_child() -> device_set_driver() will nuke it again.
 	 */
-
-	pdev = device_get_parent(sc->dev);
-	KASSERT(pdev != NULL, ("%s: sc %p dev %p (%s) parent is NULL\n",
-	    __func__, sc, sc->dev, device_get_nameunit(sc->dev)));
 	bus_devclass = device_get_devclass(pdev);
 	if (bus_devclass == NULL) {
 		printf("%s: Failed to get devclass from %s.\n", __func__,
@@ -1032,9 +1030,8 @@ sdiobregister(struct cam_periph *periph, void *arg)
 		    __func__, periph);
 		return(CAM_REQ_CMP_ERR);
 	}
-	if (periph->sim == NULL || periph->sim->sim_dev == NULL) {
-		printf("%s: no sim %p or sim_dev %p\n", __func__, periph->sim,
-		    (periph->sim != NULL) ? periph->sim->sim_dev : NULL);
+	if (xpt_path_sim_device(periph->path) == NULL) {
+		printf("%s: no device_t for sim %p\n", __func__, periph->sim);
 		return(CAM_REQ_CMP_ERR);
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106282224.15SMO4IU048797>