1/*- 2 * Copyright (c) 1997 Justin T. Gibbs. 3 * Copyright (c) 1997, 1998, 1999 Kenneth D. Merry. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 54 unchanged lines hidden (view full) --- 63 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 64 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 65 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 66 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 67 * SUCH DAMAGE. 68 */ 69 70#include <sys/cdefs.h> |
71__FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_ch.c 293350 2016-01-07 20:22:55Z kib $"); |
72 73#include <sys/param.h> 74#include <sys/queue.h> 75#include <sys/systm.h> 76#include <sys/kernel.h> 77#include <sys/types.h> 78#include <sys/malloc.h> 79#include <sys/fcntl.h> --- 287 unchanged lines hidden (view full) --- 367} 368 369static cam_status 370chregister(struct cam_periph *periph, void *arg) 371{ 372 struct ch_softc *softc; 373 struct ccb_getdev *cgd; 374 struct ccb_pathinq cpi; |
375 struct make_dev_args args; 376 int error; |
377 378 cgd = (struct ccb_getdev *)arg; 379 if (cgd == NULL) { 380 printf("chregister: no getdev CCB, can't register device\n"); 381 return(CAM_REQ_CMP_ERR); 382 } 383 384 softc = (struct ch_softc *)malloc(sizeof(*softc),M_DEVBUF,M_NOWAIT); --- 43 unchanged lines hidden (view full) --- 428 xpt_print(periph->path, "%s: lost periph during " 429 "registration!\n", __func__); 430 cam_periph_lock(periph); 431 return (CAM_REQ_CMP_ERR); 432 } 433 434 435 /* Register the device */ |
436 make_dev_args_init(&args); 437 args.mda_devsw = &ch_cdevsw; 438 args.mda_unit = periph->unit_number; 439 args.mda_uid = UID_ROOT; 440 args.mda_gid = GID_OPERATOR; 441 args.mda_mode = 0600; 442 args.mda_si_drv1 = periph; 443 error = make_dev_s(&args, &softc->dev, "%s%d", periph->periph_name, 444 periph->unit_number); |
445 cam_periph_lock(periph); |
446 if (error != 0) { 447 cam_periph_release_locked(periph); 448 return (CAM_REQ_CMP_ERR); 449 } |
450 451 /* 452 * Add an async callback so that we get 453 * notified if this device goes away. 454 */ 455 xpt_register_async(AC_LOST_DEVICE, chasync, periph, periph->path); 456 457 /* --- 55 unchanged lines hidden (view full) --- 513static int 514chclose(struct cdev *dev, int flag, int fmt, struct thread *td) 515{ 516 struct cam_periph *periph; 517 struct ch_softc *softc; 518 struct mtx *mtx; 519 520 periph = (struct cam_periph *)dev->si_drv1; |
521 mtx = cam_periph_mtx(periph); 522 mtx_lock(mtx); 523 524 softc = (struct ch_softc *)periph->softc; 525 softc->open_count--; 526 527 cam_periph_release_locked(periph); 528 --- 229 unchanged lines hidden (view full) --- 758static int 759chioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td) 760{ 761 struct cam_periph *periph; 762 struct ch_softc *softc; 763 int error; 764 765 periph = (struct cam_periph *)dev->si_drv1; |
766 cam_periph_lock(periph); 767 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("entering chioctl\n")); 768 769 softc = (struct ch_softc *)periph->softc; 770 771 error = 0; 772 773 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, --- 1167 unchanged lines hidden --- |