Diff below simplifies umass(4) slightly: instead of attaching a two
target bus and reserving one target for the "host" (which doesn't do
anything), just attach a one target bus and let the SCSI subsystem
know that no target is reserved for the adapter.

Basically, this just changes the dmesg line from:

    scsibus3 at umass0: 2 targets, initiator 0

to

    scsibus3 at umass0: 1 targets

(Yes, it's poor grammar...)

Tested with a USB thumb drive on amd64.

ok?


Index: umass_scsi.c
===================================================================
RCS file: /home/mdempsky/anoncvs/cvs/src/sys/dev/usb/umass_scsi.c,v
retrieving revision 1.36
diff -u -p -r1.36 umass_scsi.c
--- umass_scsi.c        8 Jul 2011 22:09:27 -0000       1.36
+++ umass_scsi.c        9 Jul 2011 01:05:48 -0000
@@ -62,8 +62,7 @@ struct umass_scsi_softc {
 };
 
 
-#define UMASS_SCSIID_HOST      0x00
-#define UMASS_SCSIID_DEVICE    0x01
+#define UMASS_SCSIID_DEVICE    0x00
 
 int umass_scsi_probe(struct scsi_link *);
 void umass_scsi_cmd(struct scsi_xfer *);
@@ -91,13 +90,13 @@ umass_scsi_attach(struct umass_softc *sc
        struct umass_scsi_softc *scbus;
 
        scbus = umass_scsi_setup(sc);
-       scbus->sc_link.adapter_target = UMASS_SCSIID_HOST;
+       scbus->sc_link.adapter_target = SCSI_NO_ADAPTER_TARGET;
        scbus->sc_link.flags &= ~SDEV_ATAPI;
        scbus->sc_link.flags |= SDEV_UMASS;
 
        bzero(&saa, sizeof(saa));
        saa.saa_sc_link = &scbus->sc_link;
-       saa.saa_targets = 2;
+       saa.saa_targets = 1;
        saa.saa_luns = sc->maxlun + 1;
 
        DPRINTF(UDMASS_USB, ("%s: umass_attach_bus: SCSI\n"
@@ -120,13 +119,13 @@ umass_atapi_attach(struct umass_softc *s
        struct umass_scsi_softc *scbus;
 
        scbus = umass_scsi_setup(sc);
-       scbus->sc_link.adapter_target = UMASS_SCSIID_HOST;
+       scbus->sc_link.adapter_target = SCSI_NO_ADAPTER_TARGET;
        scbus->sc_link.openings = 1;
        scbus->sc_link.flags |= SDEV_ATAPI;
 
        bzero(&saa, sizeof(saa));
        saa.saa_sc_link = &scbus->sc_link;
-       saa.saa_targets = 2;
+       saa.saa_targets = 1;
        saa.saa_luns = 1;
 
        DPRINTF(UDMASS_USB, ("%s: umass_attach_bus: ATAPI\n"

Reply via email to