Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/sdio/sdiob.c
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | |||||
#define SDIO_STATE_DEAD 0x0001 | #define SDIO_STATE_DEAD 0x0001 | ||||
#define SDIO_STATE_INITIALIZING 0x0002 | #define SDIO_STATE_INITIALIZING 0x0002 | ||||
#define SDIO_STATE_READY 0x0004 | #define SDIO_STATE_READY 0x0004 | ||||
uint32_t nb_state; | uint32_t nb_state; | ||||
#define NB_STATE_DEAD 0x0001 | #define NB_STATE_DEAD 0x0001 | ||||
#define NB_STATE_SIM_ADDED 0x0002 | #define NB_STATE_SIM_ADDED 0x0002 | ||||
#define NB_STATE_READY 0x0004 | #define NB_STATE_READY 0x0004 | ||||
/* CAM side (including sim_dev). */ | /* CAM side. */ | ||||
struct card_info cardinfo; | struct card_info cardinfo; | ||||
struct cam_periph *periph; | struct cam_periph *periph; | ||||
union ccb *ccb; | union ccb *ccb; | ||||
struct task discover_task; | struct task discover_task; | ||||
/* Newbus side. */ | /* Newbus side. */ | ||||
device_t dev; /* Ourselves. */ | device_t dev; /* Ourselves. */ | ||||
device_t child[8]; | device_t child[8]; | ||||
▲ Show 20 Lines • Show All 794 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
device_t pdev; | device_t pdev; | ||||
devclass_t bus_devclass; | devclass_t bus_devclass; | ||||
int error; | int error; | ||||
/* Add ourselves to our parent (SIM) device. */ | /* Add ourselves to our parent (SIM) device. */ | ||||
/* Add ourselves to our parent. That way we can become a parent. */ | /* 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 " | pdev = xpt_path_sim_device(sc->periph->path); | ||||
"periph %p sim %p\n", __func__, sc, sc->periph, sc->periph->sim)); | 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) | if (sc->dev == NULL) | ||||
sc->dev = BUS_ADD_CHILD(sc->periph->sim->sim_dev, 0, | sc->dev = BUS_ADD_CHILD(pdev, 0, SDIOB_NAME_S, -1); | ||||
SDIOB_NAME_S, -1); | |||||
if (sc->dev == NULL) | if (sc->dev == NULL) | ||||
return (ENXIO); | return (ENXIO); | ||||
device_set_softc(sc->dev, sc); | device_set_softc(sc->dev, sc); | ||||
/* | /* | ||||
* Don't set description here; devclass_add_driver() -> | * Don't set description here; devclass_add_driver() -> | ||||
* device_probe_child() -> device_set_driver() will nuke it again. | * 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); | bus_devclass = device_get_devclass(pdev); | ||||
if (bus_devclass == NULL) { | if (bus_devclass == NULL) { | ||||
printf("%s: Failed to get devclass from %s.\n", __func__, | printf("%s: Failed to get devclass from %s.\n", __func__, | ||||
device_get_nameunit(pdev)); | device_get_nameunit(pdev)); | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
mtx_lock(&Giant); | mtx_lock(&Giant); | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | sdiobregister(struct cam_periph *periph, void *arg) | ||||
int error; | int error; | ||||
CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("%s: arg %p\n", __func__, arg)); | CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("%s: arg %p\n", __func__, arg)); | ||||
if (arg == NULL) { | if (arg == NULL) { | ||||
printf("%s: no getdev CCB, can't register device pariph %p\n", | printf("%s: no getdev CCB, can't register device pariph %p\n", | ||||
__func__, periph); | __func__, periph); | ||||
return(CAM_REQ_CMP_ERR); | return(CAM_REQ_CMP_ERR); | ||||
} | } | ||||
if (periph->sim == NULL || periph->sim->sim_dev == NULL) { | if (xpt_path_sim_device(periph->path) == NULL) { | ||||
printf("%s: no sim %p or sim_dev %p\n", __func__, periph->sim, | printf("%s: no device_t for sim %p\n", __func__, periph->sim); | ||||
(periph->sim != NULL) ? periph->sim->sim_dev : NULL); | |||||
return(CAM_REQ_CMP_ERR); | return(CAM_REQ_CMP_ERR); | ||||
} | } | ||||
sc = (struct sdiob_softc *) malloc(sizeof(*sc), M_DEVBUF, | sc = (struct sdiob_softc *) malloc(sizeof(*sc), M_DEVBUF, | ||||
M_NOWAIT|M_ZERO); | M_NOWAIT|M_ZERO); | ||||
if (sc == NULL) { | if (sc == NULL) { | ||||
printf("%s: unable to allocate sc\n", __func__); | printf("%s: unable to allocate sc\n", __func__); | ||||
return (CAM_REQ_CMP_ERR); | return (CAM_REQ_CMP_ERR); | ||||
▲ Show 20 Lines • Show All 135 Lines • Show Last 20 Lines |