Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Implement the scsipi_getgeom method and guess th...



details:   https://anonhg.NetBSD.org/src/rev/68e99c72d88a
branches:  trunk
changeset: 486951:68e99c72d88a
user:      augustss <augustss%NetBSD.org@localhost>
date:      Wed May 31 09:17:13 2000 +0000

description:
Implement the scsipi_getgeom method and guess the geometry of floppies
based on the number of sectors.

diffstat:

 sys/dev/usb/umass.c |  38 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 37 insertions(+), 1 deletions(-)

diffs (73 lines):

diff -r 5374ab913f0c -r 68e99c72d88a sys/dev/usb/umass.c
--- a/sys/dev/usb/umass.c       Wed May 31 09:15:48 2000 +0000
+++ b/sys/dev/usb/umass.c       Wed May 31 09:17:13 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: umass.c,v 1.35 2000/05/30 01:12:51 augustss Exp $      */
+/*     $NetBSD: umass.c,v 1.36 2000/05/31 09:17:13 augustss Exp $      */
 /*-
  * Copyright (c) 1999 MAEKAWA Masahide <bishop%rr.iij4u.or.jp@localhost>,
  *                   Nick Hibma <n_hibma%freebsd.org@localhost>
@@ -145,6 +145,8 @@
 #include <dev/scsipi/scsi_changer.h>
 
 #include <dev/ata/atavar.h>    /* XXX */
+#include <sys/disk.h>          /* XXX */
+#include <dev/scsipi/sdvar.h>  /* XXX */
 #endif
 
 #ifdef UMASS_DEBUG
@@ -589,6 +591,9 @@
 Static void umass_scsipi_minphys __P((struct buf *bp));
 Static int umass_scsipi_ioctl __P((struct scsipi_link *, u_long,
                                   caddr_t, int, struct proc *));
+Static int umass_scsipi_getgeom __P((struct scsipi_link *link,
+                             struct disk_parms *, u_long sectors));
+
 Static void umass_scsipi_cb    __P((struct umass_softc *sc, void *priv,
                                     int residue, int status));
 Static void umass_scsipi_sense_cb __P((struct umass_softc *sc, void *priv,
@@ -1050,6 +1055,7 @@
        sc->sc_adapter.scsipi_cmd = umass_scsipi_cmd;
        sc->sc_adapter.scsipi_minphys = umass_scsipi_minphys;
        sc->sc_adapter.scsipi_ioctl = umass_scsipi_ioctl;
+       sc->sc_adapter.scsipi_getgeom = umass_scsipi_getgeom;
        
        /*
         * fill in the prototype scsipi_link.
@@ -3200,6 +3206,36 @@
        }
 }
 
+Static int
+umass_scsipi_getgeom(sc_link, dp, sectors)
+       struct scsipi_link *sc_link;
+       struct disk_parms *dp;
+       u_long sectors;
+{
+       struct umass_softc *sc = sc_link->adapter_softc;
+
+       /* If it's not a floppy, we don't know what to do. */
+       if (!(sc->proto & PROTO_UFI))
+               return (0);
+
+       switch (sectors) {
+       case 1440:
+               /* Most likely a single density 3.5" floppy. */
+               dp->heads = 2;
+               dp->sectors = 9;
+               dp->cyls = 80;
+               return (1);
+       case 2880:
+               /* Most likely a double density 3.5" floppy. */
+               dp->heads = 2;
+               dp->sectors = 18;
+               dp->cyls = 80;
+               return (1);
+       default:
+               return (0);
+       }
+}
+
 Static void
 umass_scsipi_cb(struct umass_softc *sc, void *priv, int residue, int status)
 {



Home | Main Index | Thread Index | Old Index