Changeset View
Changeset View
Standalone View
Standalone View
sys/cam/mmc/mmc_sim.c
Show All 40 Lines | |||||
#include <cam/cam_xpt_sim.h> | #include <cam/cam_xpt_sim.h> | ||||
#include <cam/mmc/mmc_sim.h> | #include <cam/mmc/mmc_sim.h> | ||||
#include "mmc_sim_if.h" | #include "mmc_sim_if.h" | ||||
static void | static void | ||||
mmc_cam_default_poll(struct cam_sim *sim) | mmc_cam_default_poll(struct cam_sim *sim) | ||||
{ | { | ||||
struct mmc_sim *mmc_sim; | |||||
return; | mmc_sim = cam_sim_softc(sim); | ||||
MMC_SIM_CAM_POLL(mmc_sim->dev); | |||||
} | } | ||||
mav: How can this be NULL if it is assigned in cam_sim_alloc() and never changed? | |||||
Done Inline ActionsHmm, I just thoughtlessly copied the check from mmc_cam_sim_default_action(). avg: Hmm, I just thoughtlessly copied the check from mmc_cam_sim_default_action().
I guess it can be… | |||||
static void | static void | ||||
mmc_sim_task(void *arg, int pending) | mmc_sim_task(void *arg, int pending) | ||||
{ | { | ||||
struct mmc_sim *mmc_sim; | struct mmc_sim *mmc_sim; | ||||
struct ccb_trans_settings *cts; | struct ccb_trans_settings *cts; | ||||
int rv; | int rv; | ||||
Show All 32 Lines | |||||
mmc_cam_sim_default_action(struct cam_sim *sim, union ccb *ccb) | mmc_cam_sim_default_action(struct cam_sim *sim, union ccb *ccb) | ||||
{ | { | ||||
struct mmc_sim *mmc_sim; | struct mmc_sim *mmc_sim; | ||||
struct ccb_trans_settings_mmc mmc; | struct ccb_trans_settings_mmc mmc; | ||||
int rv; | int rv; | ||||
mmc_sim = cam_sim_softc(sim); | mmc_sim = cam_sim_softc(sim); | ||||
if (mmc_sim == NULL) { | |||||
ccb->ccb_h.status = CAM_SEL_TIMEOUT; | |||||
xpt_done(ccb); | |||||
return; | |||||
} | |||||
mtx_assert(&mmc_sim->mtx, MA_OWNED); | mtx_assert(&mmc_sim->mtx, MA_OWNED); | ||||
if (mmc_sim->ccb != NULL) { | if (mmc_sim->ccb != NULL) { | ||||
ccb->ccb_h.status = CAM_BUSY; | ccb->ccb_h.status = CAM_BUSY; | ||||
xpt_done(ccb); | xpt_done(ccb); | ||||
return; | return; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | case XPT_MMC_SET_TRAN_SETTINGS: | ||||
return; | return; | ||||
/* NOTREACHED */ | /* NOTREACHED */ | ||||
break; | break; | ||||
} | } | ||||
case XPT_RESET_BUS: | case XPT_RESET_BUS: | ||||
ccb->ccb_h.status = CAM_REQ_CMP; | ccb->ccb_h.status = CAM_REQ_CMP; | ||||
break; | break; | ||||
case XPT_MMC_IO: | case XPT_MMC_IO: | ||||
{ | { | ||||
ccb->ccb_h.status = CAM_REQ_INVALID; | |||||
rv = MMC_SIM_CAM_REQUEST(mmc_sim->dev, ccb); | rv = MMC_SIM_CAM_REQUEST(mmc_sim->dev, ccb); | ||||
Done Inline ActionsCAM_REQ_INPROG should already be set by xpt_action(). It should not be needed here. mav: CAM_REQ_INPROG should already be set by xpt_action(). It should not be needed here. | |||||
Done Inline ActionsI see. Thank you for the advice. avg: I see. Thank you for the advice. | |||||
if (rv != 0) | if (rv != 0) | ||||
ccb->ccb_h.status = CAM_SIM_QUEUED; | ccb->ccb_h.status = CAM_SIM_QUEUED; | ||||
return; | return; | ||||
/* NOTREACHED */ | /* NOTREACHED */ | ||||
break; | break; | ||||
} | } | ||||
default: | default: | ||||
ccb->ccb_h.status = CAM_REQ_INVALID; | ccb->ccb_h.status = CAM_REQ_INVALID; | ||||
break; | break; | ||||
} | } | ||||
xpt_done(ccb); | xpt_done(ccb); | ||||
return; | return; | ||||
} | } | ||||
int | int | ||||
mmc_cam_sim_alloc(device_t dev, const char *name, struct mmc_sim *mmc_sim) | mmc_cam_sim_alloc(device_t dev, const char *name, struct mmc_sim *mmc_sim) | ||||
{ | { | ||||
kobjop_desc_t kobj_desc; | |||||
kobj_method_t *kobj_method; | |||||
mmc_sim->dev = dev; | mmc_sim->dev = dev; | ||||
if ((mmc_sim->devq = cam_simq_alloc(1)) == NULL) { | if ((mmc_sim->devq = cam_simq_alloc(1)) == NULL) { | ||||
goto fail; | goto fail; | ||||
} | } | ||||
snprintf(mmc_sim->name, sizeof(mmc_sim->name), "%s_sim", name); | snprintf(mmc_sim->name, sizeof(mmc_sim->name), "%s_sim", name); | ||||
mtx_init(&mmc_sim->mtx, mmc_sim->name, NULL, MTX_DEF); | mtx_init(&mmc_sim->mtx, mmc_sim->name, NULL, MTX_DEF); | ||||
/* Provide sim_poll hook only if the device has the poll method. */ | |||||
kobj_desc = &mmc_sim_cam_poll_desc; | |||||
kobj_method = kobj_lookup_method(((kobj_t)dev)->ops->cls, NULL, | |||||
kobj_desc); | |||||
mmc_sim->sim = cam_sim_alloc(mmc_cam_sim_default_action, | mmc_sim->sim = cam_sim_alloc(mmc_cam_sim_default_action, | ||||
mmc_cam_default_poll, | kobj_method == &kobj_desc->deflt ? NULL : mmc_cam_default_poll, | ||||
mmc_sim->name, mmc_sim, device_get_unit(dev), | mmc_sim->name, mmc_sim, device_get_unit(dev), | ||||
&mmc_sim->mtx, 1, 1, mmc_sim->devq); | &mmc_sim->mtx, 1, 1, mmc_sim->devq); | ||||
if (mmc_sim->sim == NULL) { | if (mmc_sim->sim == NULL) { | ||||
cam_simq_free(mmc_sim->devq); | cam_simq_free(mmc_sim->devq); | ||||
device_printf(dev, "cannot allocate CAM SIM\n"); | device_printf(dev, "cannot allocate CAM SIM\n"); | ||||
goto fail; | goto fail; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |
How can this be NULL if it is assigned in cam_sim_alloc() and never changed?