1/*- 2 * Copyright (c) 2000 Matthew Jacob 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_enc.c 293350 2016-01-07 20:22:55Z kib $"); |
29 30#include <sys/param.h> 31 32#include <sys/conf.h> 33#include <sys/errno.h> 34#include <sys/fcntl.h> 35#include <sys/kernel.h> 36#include <sys/kthread.h> --- 222 unchanged lines hidden (view full) --- 259static int 260enc_open(struct cdev *dev, int flags, int fmt, struct thread *td) 261{ 262 struct cam_periph *periph; 263 struct enc_softc *softc; 264 int error = 0; 265 266 periph = (struct cam_periph *)dev->si_drv1; |
267 if (cam_periph_acquire(periph) != CAM_REQ_CMP) 268 return (ENXIO); 269 270 cam_periph_lock(periph); 271 272 softc = (struct enc_softc *)periph->softc; 273 274 if ((softc->enc_flags & ENC_FLAG_INITIALIZED) == 0) { --- 18 unchanged lines hidden (view full) --- 293static int 294enc_close(struct cdev *dev, int flag, int fmt, struct thread *td) 295{ 296 struct cam_periph *periph; 297 struct enc_softc *enc; 298 struct mtx *mtx; 299 300 periph = (struct cam_periph *)dev->si_drv1; |
301 mtx = cam_periph_mtx(periph); 302 mtx_lock(mtx); 303 304 enc = periph->softc; 305 enc->open_count--; 306 307 cam_periph_release_locked(periph); 308 --- 44 unchanged lines hidden (view full) --- 353 354 355 if (arg_addr) 356 addr = *((caddr_t *) arg_addr); 357 else 358 addr = NULL; 359 360 periph = (struct cam_periph *)dev->si_drv1; |
361 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("entering encioctl\n")); 362 363 cam_periph_lock(periph); 364 enc = (struct enc_softc *)periph->softc; 365 cache = &enc->enc_cache; 366 367 /* 368 * Now check to see whether we're initialized or not. --- 522 unchanged lines hidden (view full) --- 891static cam_status 892enc_ctor(struct cam_periph *periph, void *arg) 893{ 894 cam_status status = CAM_REQ_CMP_ERR; 895 int err; 896 enc_softc_t *enc; 897 struct ccb_getdev *cgd; 898 char *tname; |
899 struct make_dev_args args; |
900 901 cgd = (struct ccb_getdev *)arg; 902 if (cgd == NULL) { 903 printf("enc_ctor: no getdev CCB, can't register device\n"); 904 goto out; 905 } 906 907 enc = ENC_MALLOCZ(sizeof(*enc)); --- 66 unchanged lines hidden (view full) --- 974 if (cam_periph_acquire(periph) != CAM_REQ_CMP) { 975 xpt_print(periph->path, "%s: lost periph during " 976 "registration!\n", __func__); 977 cam_periph_lock(periph); 978 979 return (CAM_REQ_CMP_ERR); 980 } 981 |
982 make_dev_args_init(&args); 983 args.mda_devsw = &enc_cdevsw; 984 args.mda_unit = periph->unit_number; 985 args.mda_uid = UID_ROOT; 986 args.mda_gid = GID_OPERATOR; 987 args.mda_mode = 0600; 988 args.mda_si_drv1 = periph; 989 err = make_dev_s(&args, &enc->enc_dev, "%s%d", periph->periph_name, 990 periph->unit_number); |
991 cam_periph_lock(periph); |
992 if (err != 0) { 993 cam_periph_release_locked(periph); 994 return (CAM_REQ_CMP_ERR); 995 } |
996 997 enc->enc_flags |= ENC_FLAG_INITIALIZED; 998 999 /* 1000 * Add an async callback so that we get notified if this 1001 * device goes away. 1002 */ 1003 xpt_register_async(AC_LOST_DEVICE, enc_async, periph, periph->path); --- 34 unchanged lines hidden --- |