Deleted Added
full compact
scsi_ch.c (287806) scsi_ch.c (293350)
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>
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 287806 2015-09-15 05:09:17Z markj $");
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;
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;
375
376 cgd = (struct ccb_getdev *)arg;
377 if (cgd == NULL) {
378 printf("chregister: no getdev CCB, can't register device\n");
379 return(CAM_REQ_CMP_ERR);
380 }
381
382 softc = (struct ch_softc *)malloc(sizeof(*softc),M_DEVBUF,M_NOWAIT);

--- 43 unchanged lines hidden (view full) ---

426 xpt_print(periph->path, "%s: lost periph during "
427 "registration!\n", __func__);
428 cam_periph_lock(periph);
429 return (CAM_REQ_CMP_ERR);
430 }
431
432
433 /* Register the device */
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 */
434 softc->dev = make_dev(&ch_cdevsw, periph->unit_number, UID_ROOT,
435 GID_OPERATOR, 0600, "%s%d", periph->periph_name,
436 periph->unit_number);
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);
437 cam_periph_lock(periph);
445 cam_periph_lock(periph);
438 softc->dev->si_drv1 = periph;
446 if (error != 0) {
447 cam_periph_release_locked(periph);
448 return (CAM_REQ_CMP_ERR);
449 }
439
440 /*
441 * Add an async callback so that we get
442 * notified if this device goes away.
443 */
444 xpt_register_async(AC_LOST_DEVICE, chasync, periph, periph->path);
445
446 /*

--- 55 unchanged lines hidden (view full) ---

502static int
503chclose(struct cdev *dev, int flag, int fmt, struct thread *td)
504{
505 struct cam_periph *periph;
506 struct ch_softc *softc;
507 struct mtx *mtx;
508
509 periph = (struct cam_periph *)dev->si_drv1;
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;
510 if (periph == NULL)
511 return(ENXIO);
512 mtx = cam_periph_mtx(periph);
513 mtx_lock(mtx);
514
515 softc = (struct ch_softc *)periph->softc;
516 softc->open_count--;
517
518 cam_periph_release_locked(periph);
519

--- 229 unchanged lines hidden (view full) ---

749static int
750chioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
751{
752 struct cam_periph *periph;
753 struct ch_softc *softc;
754 int error;
755
756 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;
757 if (periph == NULL)
758 return(ENXIO);
759
760 cam_periph_lock(periph);
761 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("entering chioctl\n"));
762
763 softc = (struct ch_softc *)periph->softc;
764
765 error = 0;
766
767 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE,

--- 1167 unchanged lines hidden ---
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 ---