From 2cbf101b17b627249bc6dc949b1b260199dd91a7 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Mon, 20 Apr 2009 10:40:42 +0000 Subject: [PATCH] Get rid of the device index number stored in the sa(4) unit number. The device index number stored in the unit number of sa(4) devices is only used to print debug messages. Get rid of this index number and use devtoname() to just print the entire device name. --- sys/cam/scsi/scsi_sa.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/sys/cam/scsi/scsi_sa.c b/sys/cam/scsi/scsi_sa.c index ef76a9031bcf..7ce5d559a5e0 100644 --- a/sys/cam/scsi/scsi_sa.c +++ b/sys/cam/scsi/scsi_sa.c @@ -173,13 +173,9 @@ typedef enum { SA_QUIRK_NO_CPAGE = 0x80 /* Don't use DEVICE COMPRESSION page */ } sa_quirks; -/* units are bits 4-7, 16-21 (1024 units) */ -#define SAUNIT(DEV) \ - (((dev2unit(DEV) & 0xF0) >> 4) | ((dev2unit(DEV) & 0x3f0000) >> 16)) - -#define SAMODE(z) ((dev2unit(z) & 0x3)) -#define SADENSITY(z) (((dev2unit(z) >> 2) & 0x3)) -#define SA_IS_CTRL(z) (dev2unit(z) & (1 << 29)) +#define SAMODE(z) (dev2unit(z) & 0x3) +#define SADENSITY(z) ((dev2unit(z) >> 2) & 0x3) +#define SA_IS_CTRL(z) (dev2unit(z) & (1 << 4)) #define SA_NOT_CTLDEV 0 #define SA_CTLDEV 1 @@ -188,9 +184,8 @@ typedef enum { #define SA_ATYPE_NR 1 #define SA_ATYPE_ER 2 -#define SAMINOR(ctl, unit, mode, access) \ - ((ctl << 29) | ((unit & 0x3f0) << 16) | ((unit & 0xf) << 4) | \ - (mode << 0x2) | (access & 0x3)) +#define SAMINOR(ctl, mode, access) \ + ((ctl << 4) | (mode << 2) | (access & 0x3)) #define SA_NUM_MODES 4 struct sa_devs { @@ -445,11 +440,8 @@ saopen(struct cdev *dev, int flags, int fmt, struct thread *td) { struct cam_periph *periph; struct sa_softc *softc; - int unit; int error; - unit = SAUNIT(dev); - periph = (struct cam_periph *)dev->si_drv1; if (cam_periph_acquire(periph) != CAM_REQ_CMP) { return (ENXIO); @@ -460,7 +452,7 @@ saopen(struct cdev *dev, int flags, int fmt, struct thread *td) softc = (struct sa_softc *)periph->softc; CAM_DEBUG(periph->path, CAM_DEBUG_TRACE|CAM_DEBUG_INFO, - ("saopen(%d): dev=0x%x softc=0x%x\n", unit, unit, softc->flags)); + ("saopen(%s): softc=0x%x\n", devtoname(dev), softc->flags)); if (SA_IS_CTRL(dev)) { softc->ctrl_mode = 1; @@ -521,10 +513,9 @@ saclose(struct cdev *dev, int flag, int fmt, struct thread *td) { struct cam_periph *periph; struct sa_softc *softc; - int unit, mode, error, writing, tmp; + int mode, error, writing, tmp; int closedbits = SA_FLAG_OPEN; - unit = SAUNIT(dev); mode = SAMODE(dev); periph = (struct cam_periph *)dev->si_drv1; if (periph == NULL) @@ -535,7 +526,7 @@ saclose(struct cdev *dev, int flag, int fmt, struct thread *td) softc = (struct sa_softc *)periph->softc; CAM_DEBUG(periph->path, CAM_DEBUG_TRACE|CAM_DEBUG_INFO, - ("saclose(%d): dev=0x%x softc=0x%x\n", unit, unit, softc->flags)); + ("saclose(%s): softc=0x%x\n", devtoname(dev), softc->flags)); softc->open_rdonly = 0; @@ -1496,26 +1487,26 @@ saregister(struct cam_periph *periph, void *arg) DEVSTAT_TYPE_IF_SCSI, DEVSTAT_PRIORITY_TAPE); softc->devs.ctl_dev = make_dev(&sa_cdevsw, SAMINOR(SA_CTLDEV, - periph->unit_number, 0, SA_ATYPE_R), UID_ROOT, GID_OPERATOR, + 0, SA_ATYPE_R), UID_ROOT, GID_OPERATOR, 0660, "%s%d.ctl", periph->periph_name, periph->unit_number); softc->devs.ctl_dev->si_drv1 = periph; for (i = 0; i < SA_NUM_MODES; i++) { softc->devs.mode_devs[i].r_dev = make_dev(&sa_cdevsw, - SAMINOR(SA_NOT_CTLDEV, periph->unit_number, i, SA_ATYPE_R), + SAMINOR(SA_NOT_CTLDEV, i, SA_ATYPE_R), UID_ROOT, GID_OPERATOR, 0660, "%s%d.%d", periph->periph_name, periph->unit_number, i); softc->devs.mode_devs[i].r_dev->si_drv1 = periph; softc->devs.mode_devs[i].nr_dev = make_dev(&sa_cdevsw, - SAMINOR(SA_NOT_CTLDEV, periph->unit_number, i, SA_ATYPE_NR), + SAMINOR(SA_NOT_CTLDEV, i, SA_ATYPE_NR), UID_ROOT, GID_OPERATOR, 0660, "n%s%d.%d", periph->periph_name, periph->unit_number, i); softc->devs.mode_devs[i].nr_dev->si_drv1 = periph; softc->devs.mode_devs[i].er_dev = make_dev(&sa_cdevsw, - SAMINOR(SA_NOT_CTLDEV, periph->unit_number, i, SA_ATYPE_ER), + SAMINOR(SA_NOT_CTLDEV, i, SA_ATYPE_ER), UID_ROOT, GID_OPERATOR, 0660, "e%s%d.%d", periph->periph_name, periph->unit_number, i); softc->devs.mode_devs[i].er_dev->si_drv1 = periph;