Changeset View
Changeset View
Standalone View
Standalone View
sys/cam/scsi/scsi_enc.c
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | |||||
static d_ioctl_t enc_ioctl; | static d_ioctl_t enc_ioctl; | ||||
static periph_init_t enc_init; | static periph_init_t enc_init; | ||||
static periph_ctor_t enc_ctor; | static periph_ctor_t enc_ctor; | ||||
static periph_oninv_t enc_oninvalidate; | static periph_oninv_t enc_oninvalidate; | ||||
static periph_dtor_t enc_dtor; | static periph_dtor_t enc_dtor; | ||||
static void enc_async(void *, uint32_t, struct cam_path *, void *); | static void enc_async(void *, uint32_t, struct cam_path *, void *); | ||||
static enctyp enc_type(struct ccb_getdev *); | static enctyp enc_type(struct ccb_getdev *); | ||||
static void enc_status_updater(void *arg); | |||||
SYSCTL_NODE(_kern_cam, OID_AUTO, enc, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, | SYSCTL_NODE(_kern_cam, OID_AUTO, enc, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, | ||||
"CAM Enclosure Services driver"); | "CAM Enclosure Services driver"); | ||||
#if defined(DEBUG) || defined(ENC_DEBUG) | #if defined(DEBUG) || defined(ENC_DEBUG) | ||||
int enc_verbose = 1; | int enc_verbose = 1; | ||||
#else | #else | ||||
int enc_verbose = 0; | int enc_verbose = 0; | ||||
▲ Show 20 Lines • Show All 364 Lines • ▼ Show 20 Lines | #endif | ||||
case ENCIOC_SETENCSTAT: { | case ENCIOC_SETENCSTAT: { | ||||
encioc_enc_status_t tmp; | encioc_enc_status_t tmp; | ||||
error = copyin(addr, &tmp, sizeof(tmp)); | error = copyin(addr, &tmp, sizeof(tmp)); | ||||
if (error) | if (error) | ||||
break; | break; | ||||
cam_periph_lock(periph); | cam_periph_lock(periph); | ||||
error = enc->enc_vec.set_enc_status(enc, tmp, 1); | error = enc->enc_vec.set_enc_status(enc, tmp, 1); | ||||
enc_status_updater(enc); | |||||
cam_periph_unlock(periph); | cam_periph_unlock(periph); | ||||
break; | break; | ||||
} | } | ||||
case ENCIOC_GETSTRING: | case ENCIOC_GETSTRING: | ||||
case ENCIOC_SETSTRING: | case ENCIOC_SETSTRING: | ||||
case ENCIOC_GETENCNAME: | case ENCIOC_GETENCNAME: | ||||
case ENCIOC_GETENCID: { | case ENCIOC_GETENCID: { | ||||
encioc_string_t sstr; | encioc_string_t sstr; | ||||
if (enc->enc_vec.handle_string == NULL) { | if (enc->enc_vec.handle_string == NULL) { | ||||
error = EINVAL; | error = EINVAL; | ||||
break; | break; | ||||
} | } | ||||
error = copyin(addr, &sstr, sizeof(sstr)); | error = copyin(addr, &sstr, sizeof(sstr)); | ||||
if (error) | if (error) | ||||
break; | break; | ||||
cam_periph_lock(periph); | cam_periph_lock(periph); | ||||
error = enc->enc_vec.handle_string(enc, &sstr, cmd); | error = enc->enc_vec.handle_string(enc, &sstr, cmd); | ||||
if (cmd == ENCIOC_SETSTRING) | |||||
enc_status_updater(enc); | |||||
cam_periph_unlock(periph); | cam_periph_unlock(periph); | ||||
if (error == 0 || error == ENOMEM) | if (error == 0 || error == ENOMEM) | ||||
(void)copyout(&sstr.bufsiz, | (void)copyout(&sstr.bufsiz, | ||||
&((encioc_string_t *)addr)->bufsiz, | &((encioc_string_t *)addr)->bufsiz, | ||||
sizeof(sstr.bufsiz)); | sizeof(sstr.bufsiz)); | ||||
break; | break; | ||||
} | } | ||||
case ENCIOC_GETELMSTAT: { | case ENCIOC_GETELMSTAT: { | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | if (error) | ||||
break; | break; | ||||
if (elms.elm_idx >= cache->nelms) { | if (elms.elm_idx >= cache->nelms) { | ||||
error = EINVAL; | error = EINVAL; | ||||
break; | break; | ||||
} | } | ||||
cam_periph_lock(periph); | cam_periph_lock(periph); | ||||
error = enc->enc_vec.set_elm_status(enc, &elms, 1); | error = enc->enc_vec.set_elm_status(enc, &elms, 1); | ||||
enc_status_updater(enc); | |||||
cam_periph_unlock(periph); | cam_periph_unlock(periph); | ||||
break; | break; | ||||
} | } | ||||
case ENCIOC_INIT: | case ENCIOC_INIT: | ||||
cam_periph_lock(periph); | cam_periph_lock(periph); | ||||
error = enc->enc_vec.init_enc(enc); | error = enc->enc_vec.init_enc(enc); | ||||
▲ Show 20 Lines • Show All 465 Lines • Show Last 20 Lines |