Deleted Added
sdiff udiff text old ( 287289 ) new ( 293350 )
full compact
1/*-
2 * Implementation of SCSI Sequential Access Peripheral driver for CAM.
3 *
4 * Copyright (c) 1999, 2000 Matthew Jacob
5 * Copyright (c) 2013, 2014, 2015 Spectra Logic Corporation
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_sa.c 287289 2015-08-29 11:21:20Z mav $");
32
33#include <sys/param.h>
34#include <sys/queue.h>
35#ifdef _KERNEL
36#include <sys/systm.h>
37#include <sys/kernel.h>
38#endif
39#include <sys/types.h>

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

726{
727 struct cam_periph *periph;
728 struct sa_softc *softc;
729 int mode, error, writing, tmp, i;
730 int closedbits = SA_FLAG_OPEN;
731
732 mode = SAMODE(dev);
733 periph = (struct cam_periph *)dev->si_drv1;
734 if (periph == NULL)
735 return (ENXIO);
736
737 cam_periph_lock(periph);
738
739 softc = (struct sa_softc *)periph->softc;
740
741 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE|CAM_DEBUG_INFO,
742 ("saclose(%s): softc=0x%x\n", devtoname(dev), softc->flags));
743
744

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

901 struct sa_softc *softc;
902
903 bp->bio_resid = bp->bio_bcount;
904 if (SA_IS_CTRL(bp->bio_dev)) {
905 biofinish(bp, NULL, EINVAL);
906 return;
907 }
908 periph = (struct cam_periph *)bp->bio_dev->si_drv1;
909 if (periph == NULL) {
910 biofinish(bp, NULL, ENXIO);
911 return;
912 }
913 cam_periph_lock(periph);
914
915 softc = (struct sa_softc *)periph->softc;
916
917 if (softc->flags & SA_FLAG_INVALID) {
918 cam_periph_unlock(periph);
919 biofinish(bp, NULL, ENXIO);
920 return;

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

1512 int mode;
1513 int error = 0;
1514
1515 mode = SAMODE(dev);
1516 error = 0; /* shut up gcc */
1517 spaceop = 0; /* shut up gcc */
1518
1519 periph = (struct cam_periph *)dev->si_drv1;
1520 if (periph == NULL)
1521 return (ENXIO);
1522
1523 cam_periph_lock(periph);
1524 softc = (struct sa_softc *)periph->softc;
1525
1526 /*
1527 * Check for control mode accesses. We allow MTIOCGET and
1528 * MTIOCERRSTAT (but need to be the only one open in order
1529 * to clear latched status), and MTSETBSIZE, MTSETDNSTY
1530 * and MTCOMP (but need to be the only one accessing this

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

2280 cam_periph_async(periph, code, path, arg);
2281 break;
2282 }
2283}
2284
2285static void
2286sasetupdev(struct sa_softc *softc, struct cdev *dev)
2287{
2288 dev->si_drv1 = softc->periph;
2289 dev->si_iosize_max = softc->maxio;
2290 dev->si_flags |= softc->si_flags;
2291 /*
2292 * Keep a count of how many non-alias devices we have created,
2293 * so we can make sure we clean them all up on shutdown. Aliases
2294 * are cleaned up when we destroy the device they're an alias for.
2295 */
2296 if ((dev->si_flags & SI_ALIAS) == 0)

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

2342}
2343
2344static cam_status
2345saregister(struct cam_periph *periph, void *arg)
2346{
2347 struct sa_softc *softc;
2348 struct ccb_getdev *cgd;
2349 struct ccb_pathinq cpi;
2350 caddr_t match;
2351 char tmpstr[80];
2352
2353 cgd = (struct ccb_getdev *)arg;
2354 if (cgd == NULL) {
2355 printf("saregister: no getdev CCB, can't register device\n");
2356 return (CAM_REQ_CMP_ERR);
2357 }
2358
2359 softc = (struct sa_softc *)

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

2501 */
2502 if (cam_periph_acquire(periph) != CAM_REQ_CMP) {
2503 xpt_print(periph->path, "%s: lost periph during "
2504 "registration!\n", __func__);
2505 cam_periph_lock(periph);
2506 return (CAM_REQ_CMP_ERR);
2507 }
2508
2509 softc->devs.ctl_dev = make_dev(&sa_cdevsw, SAMINOR(SA_CTLDEV,
2510 SA_ATYPE_R), UID_ROOT, GID_OPERATOR,
2511 0660, "%s%d.ctl", periph->periph_name, periph->unit_number);
2512 sasetupdev(softc, softc->devs.ctl_dev);
2513
2514 softc->devs.r_dev = make_dev(&sa_cdevsw, SAMINOR(SA_NOT_CTLDEV,
2515 SA_ATYPE_R), UID_ROOT, GID_OPERATOR,
2516 0660, "%s%d", periph->periph_name, periph->unit_number);
2517 sasetupdev(softc, softc->devs.r_dev);
2518
2519 softc->devs.nr_dev = make_dev(&sa_cdevsw, SAMINOR(SA_NOT_CTLDEV,
2520 SA_ATYPE_NR), UID_ROOT, GID_OPERATOR,
2521 0660, "n%s%d", periph->periph_name, periph->unit_number);
2522 sasetupdev(softc, softc->devs.nr_dev);
2523
2524 softc->devs.er_dev = make_dev(&sa_cdevsw, SAMINOR(SA_NOT_CTLDEV,
2525 SA_ATYPE_ER), UID_ROOT, GID_OPERATOR,
2526 0660, "e%s%d", periph->periph_name, periph->unit_number);
2527 sasetupdev(softc, softc->devs.er_dev);
2528
2529 cam_periph_lock(periph);
2530
2531 softc->density_type_bits[0] = 0;
2532 softc->density_type_bits[1] = SRDS_MEDIA;
2533 softc->density_type_bits[2] = SRDS_MEDIUM_TYPE;
2534 softc->density_type_bits[3] = SRDS_MEDIUM_TYPE | SRDS_MEDIA;
2535 /*

--- 3335 unchanged lines hidden ---