Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-6]: src/sys/dev/scsipi Pull up following revision(s) (requested b...



details:   https://anonhg.NetBSD.org/src/rev/4a2dad6160f2
branches:  netbsd-6
changeset: 773855:4a2dad6160f2
user:      riz <riz%NetBSD.org@localhost>
date:      Fri Mar 02 16:34:47 2012 +0000

description:
Pull up following revision(s) (requested by mbalmer in ticket #65):
        sys/dev/scsipi/ss_scanjet.c: revision 1.52
        sys/dev/scsipi/ss.c: revision 1.81
        sys/dev/scsipi/ssvar.h: revision 1.19
        sys/dev/scsipi/ss_mustek.c: revision 1.41
Convert to device_t, aka softc/device_t split, and clean up a bit the code.

diffstat:

 sys/dev/scsipi/ss.c         |  123 +++++++++++++++++++++--------------------
 sys/dev/scsipi/ss_mustek.c  |  100 ++++++++++++++-------------------
 sys/dev/scsipi/ss_scanjet.c |  128 +++++++++++++++++++------------------------
 sys/dev/scsipi/ssvar.h      |    6 +-
 4 files changed, 164 insertions(+), 193 deletions(-)

diffs (truncated from 1012 to 300 lines):

diff -r f2faadcc0654 -r 4a2dad6160f2 sys/dev/scsipi/ss.c
--- a/sys/dev/scsipi/ss.c       Fri Mar 02 16:33:39 2012 +0000
+++ b/sys/dev/scsipi/ss.c       Fri Mar 02 16:34:47 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ss.c,v 1.80 2009/12/06 22:48:17 dyoung Exp $   */
+/*     $NetBSD: ss.c,v 1.80.18.1 2012/03/02 16:34:47 riz Exp $ */
 
 /*
  * Copyright (c) 1995 Kenneth Stailey.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ss.c,v 1.80 2009/12/06 22:48:17 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ss.c,v 1.80.18.1 2012/03/02 16:34:47 riz Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -72,8 +72,14 @@
 static void    ssattach(device_t, device_t, void *);
 static int     ssdetach(device_t self, int flags);
 
-CFATTACH_DECL(ss, sizeof(struct ss_softc),
-    ssmatch, ssattach, ssdetach, NULL);
+CFATTACH_DECL_NEW(
+       ss,
+       sizeof(struct ss_softc),
+       ssmatch,
+       ssattach,
+       ssdetach,
+       NULL
+);
 
 extern struct cfdriver ss_cd;
 
@@ -121,8 +127,7 @@
 };
 
 static int
-ssmatch(device_t parent, cfdata_t match,
-    void *aux)
+ssmatch(device_t parent, cfdata_t match, void *aux)
 {
        struct scsipibus_attach_args *sa = aux;
        int priority;
@@ -130,7 +135,7 @@
        (void)scsipi_inqmatch(&sa->sa_inqbuf,
            ss_patterns, sizeof(ss_patterns) / sizeof(ss_patterns[0]),
            sizeof(ss_patterns[0]), &priority);
-       return (priority);
+       return priority;
 }
 
 /*
@@ -147,21 +152,18 @@
        struct scsipi_periph *periph = sa->sa_periph;
 
        SC_DEBUG(periph, SCSIPI_DB2, ("ssattach: "));
+       ss->sc_dev = self;
 
        ss->flags |= SSF_AUTOCONF;
 
-       /*
-        * Store information needed to contact our base driver
-        */
+       /* Store information needed to contact our base driver */
        ss->sc_periph = periph;
-       periph->periph_dev = &ss->sc_dev;
+       periph->periph_dev = ss->sc_dev;
        periph->periph_switch = &ss_switch;
 
        printf("\n");
 
-       /*
-        * Set up the buf queue for this device
-        */
+       /* Set up the buf queue for this device */
        bufq_alloc(&ss->buf_queue, "fcfs", 0);
 
        callout_init(&ss->sc_callout, 0);
@@ -176,10 +178,11 @@
        if (memcmp(sa->sa_inqbuf.vendor, "HP      ", 8) == 0 &&
            memcmp(sa->sa_inqbuf.product, "ScanJet 5300C", 13) != 0)
                scanjet_attach(ss, sa);
+#if 0
        if (ss->special == NULL) {
                /* XXX add code to restart a SCSI2 scanner, if any */
        }
-
+#endif
        ss->flags &= ~SSF_AUTOCONF;
 }
 
@@ -211,7 +214,7 @@
        mn = SSUNIT(device_unit(self));
        vdevgone(cmaj, mn, mn+SSNMINOR-1, VCHR);
 
-       return (0);
+       return 0;
 }
 
 /*
@@ -230,26 +233,27 @@
        unit = SSUNIT(dev);
        ss = device_lookup_private(&ss_cd, unit);
        if (ss == NULL)
-               return (ENXIO);
+               return ENXIO;
 
-       if (!device_is_active(&ss->sc_dev))
-               return (ENODEV);
+       if (!device_is_active(ss->sc_dev))
+               return ENODEV;
 
        ssmode = SSMODE(dev);
 
        periph = ss->sc_periph;
        adapt = periph->periph_channel->chan_adapter;
 
-       SC_DEBUG(periph, SCSIPI_DB1, ("open: dev=0x%"PRIx64" (unit %d (of %d))\n", dev,
-           unit, ss_cd.cd_ndevs));
+       SC_DEBUG(periph, SCSIPI_DB1,
+           ("open: dev=0x%"PRIx64" (unit %d (of %d))\n", dev, unit,
+           ss_cd.cd_ndevs));
 
        if (periph->periph_flags & PERIPH_OPEN) {
-               aprint_error_dev(&ss->sc_dev, "already open\n");
-               return (EBUSY);
+               aprint_error_dev(ss->sc_dev, "already open\n");
+               return EBUSY;
        }
 
        if ((error = scsipi_adapter_addref(adapt)) != 0)
-               return (error);
+               return error;
 
        /*
         * Catch any unit attention errors.
@@ -272,15 +276,15 @@
         * This mode does NOT ALLOW I/O, only ioctls
         */
        if (ssmode == MODE_CONTROL)
-               return (0);
+               return 0;
 
        SC_DEBUG(periph, SCSIPI_DB2, ("open complete\n"));
-       return (0);
+       return 0;
 
 bad:
        scsipi_adapter_delref(adapt);
        periph->periph_flags &= ~PERIPH_OPEN;
-       return (error);
+       return error;
 }
 
 /*
@@ -302,10 +306,13 @@
                        /* call special handler to rewind/abort scan */
                        error = (ss->special->rewind_scanner)(ss);
                        if (error)
-                               return (error);
-               } else {
+                               return error;
+               }
+#if 0
+               else {
                        /* XXX add code to restart a SCSI2 scanner, if any */
                }
+#endif
                ss->sio.scan_window_size = 0;
                ss->flags &= ~SSF_TRIGGERED;
        }
@@ -315,7 +322,7 @@
        scsipi_adapter_delref(adapt);
        periph->periph_flags &= ~PERIPH_OPEN;
 
-       return (0);
+       return 0;
 }
 
 /*
@@ -353,8 +360,8 @@
        struct ss_softc *ss = device_lookup_private(&ss_cd, SSUNIT(dev));
        int error;
 
-       if (!device_is_active(&ss->sc_dev))
-               return (ENODEV);
+       if (!device_is_active(ss->sc_dev))
+               return ENODEV;
 
        /* if the scanner has not yet been started, do it now */
        if (!(ss->flags & SSF_TRIGGERED)) {
@@ -366,7 +373,7 @@
                ss->flags |= SSF_TRIGGERED;
        }
 
-       return (physio(ssstrategy, NULL, dev, B_READ, ssminphys, uio));
+       return physio(ssstrategy, NULL, dev, B_READ, ssminphys, uio);
 }
 
 /*
@@ -382,12 +389,11 @@
        int s;
 
        SC_DEBUG(ss->sc_periph, SCSIPI_DB1,
-           ("ssstrategy %d bytes @ blk %" PRId64 "\n", bp->b_bcount, bp->b_blkno));
+           ("ssstrategy %d bytes @ blk %" PRId64 "\n", bp->b_bcount,
+           bp->b_blkno));
 
-       /*
-        * If the device has been made invalid, error out
-        */
-       if (!device_is_active(&ss->sc_dev)) {
+       /* If the device has been made invalid, error out */
+       if (!device_is_active(ss->sc_dev)) {
                if (periph->periph_flags & PERIPH_OPEN)
                        bp->b_error = EIO;
                else
@@ -404,9 +410,7 @@
        if (bp->b_bcount > ss->sio.scan_window_size)
                bp->b_bcount = ss->sio.scan_window_size;
 
-       /*
-        * If it's a null transfer, return immediatly
-        */
+       /* If it's a null transfer, return immediatly */
        if (bp->b_bcount == 0)
                goto done;
 
@@ -429,9 +433,7 @@
        splx(s);
        return;
 done:
-       /*
-        * Correctly set the buf to indicate a completed xfer
-        */
+       /* Correctly set the buf to indicate a completed xfer */
        bp->b_resid = bp->b_bcount;
        biodone(bp);
 }
@@ -453,7 +455,7 @@
 static void
 ssstart(struct scsipi_periph *periph)
 {
-       struct ss_softc *ss = (void *)periph->periph_dev;
+       struct ss_softc *ss = device_private(periph->periph_dev);
        struct buf *bp;
 
        SC_DEBUG(periph, SCSIPI_DB2, ("ssstart "));
@@ -475,12 +477,14 @@
                if ((bp = bufq_peek(ss->buf_queue)) == NULL)
                        return;
 
-               if (ss->special && ss->special->read) {
+               if (ss->special && ss->special->read)
                        (ss->special->read)(ss, bp);
+#if 0
                } else {
                        /* generic scsi2 scanner read */
                        /* XXX add code for SCSI2 scanner read */
                }
+#endif
        }
 }
 
@@ -516,8 +520,8 @@
        int error = 0;
        struct scan_io *sio;
 
-       if (!device_is_active(&ss->sc_dev))
-               return (ENODEV);
+       if (!device_is_active(ss->sc_dev))
+               return ENODEV;
 
        switch (cmd) {
        case SCIOCGET:
@@ -525,11 +529,10 @@
                        /* call special handler */
                        error = (ss->special->get_params)(ss);
                        if (error)
-                               return (error);
-               } else {
+                               return error;
+               } else
                        /* XXX add code for SCSI2 scanner, if any */
-                       return (EOPNOTSUPP);
-               }
+                       return EOPNOTSUPP;
                memcpy(addr, &ss->sio, sizeof(struct scan_io));
                break;
        case SCIOCSET:
@@ -539,21 +542,20 @@
                        /* call special handler */
                        error = (ss->special->set_params)(ss, sio);
                        if (error)
-                               return (error);
-               } else {
+                               return error;
+               } else



Home | Main Index | Thread Index | Old Index