Source-Changes-HG archive

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

[src/trunk]: src/sys phase 1 of disk geometry cleanup:



details:   https://anonhg.NetBSD.org/src/rev/1e9e68f2c6e8
branches:  trunk
changeset: 787000:1e9e68f2c6e8
user:      christos <christos%NetBSD.org@localhost>
date:      Wed May 29 00:47:48 2013 +0000

description:
phase 1 of disk geometry cleanup:
        - centralize the geometry -> plist code so that we don't have
          n useless copies of it.

diffstat:

 sys/arch/emips/ebus/ace_ebus.c     |  58 +++++--------------------
 sys/arch/emips/ebus/flash_ebus.c   |  56 ++++++------------------
 sys/arch/sparc64/dev/fdc.c         |  80 ++++++++++++-----------------------
 sys/arch/xen/xen/xbd_xenbus.c      |  39 +++++------------
 sys/dev/ata/wd.c                   |  62 ++++++---------------------
 sys/dev/cgd.c                      |   6 +-
 sys/dev/dksubr.c                   |  45 ++++---------------
 sys/dev/dkvar.h                    |   6 +-
 sys/dev/dkwedge/dk.c               |  39 ++++------------
 sys/dev/dm/device-mapper.c         |  26 ++++-------
 sys/dev/isa/fd.c                   |  63 +++++++--------------------
 sys/dev/ld.c                       |  51 +++++----------------
 sys/dev/raidframe/rf_netbsdkintf.c |  45 ++++++-------------
 sys/dev/scsipi/cd.c                |  45 +++++--------------
 sys/dev/scsipi/sd.c                |  51 +++++----------------
 sys/dev/vnd.c                      |  55 ++++++------------------
 sys/kern/subr_disk.c               |  85 +++++++++++++++++++++++++++++++++++++-
 sys/sys/param.h                    |   4 +-
 18 files changed, 289 insertions(+), 527 deletions(-)

diffs (truncated from 1394 to 300 lines):

diff -r ba9702412721 -r 1e9e68f2c6e8 sys/arch/emips/ebus/ace_ebus.c
--- a/sys/arch/emips/ebus/ace_ebus.c    Wed May 29 00:23:31 2013 +0000
+++ b/sys/arch/emips/ebus/ace_ebus.c    Wed May 29 00:47:48 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ace_ebus.c,v 1.5 2012/10/27 17:17:45 chs Exp $ */
+/*     $NetBSD: ace_ebus.c,v 1.6 2013/05/29 00:47:48 christos Exp $    */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ace_ebus.c,v 1.5 2012/10/27 17:17:45 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ace_ebus.c,v 1.6 2013/05/29 00:47:48 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -198,7 +198,7 @@
 int     aceactivate(device_t, enum devact);
 
 void  acedone(struct ace_softc *);
-static void ace_params_to_properties(struct ace_softc *ace);
+static void ace_set_geometry(struct ace_softc *ace);
 
 CFATTACH_DECL_NEW(ace_ebus, sizeof(struct ace_softc),
     ace_ebus_match, ace_ebus_attach, acedetach, aceactivate);
@@ -968,7 +968,7 @@
                                        DBGME(DEBUG_PROBE,
                                            printf("Sysace::sc_capacity x%qx\n",
                                            sc->sc_capacity));
-                                       ace_params_to_properties(sc);
+                                       ace_set_geometry(sc);
                                } else {
                                        DBGME(DEBUG_ERRORS,
                                            printf("Sysace::Bad card signature?"
@@ -1462,7 +1462,7 @@
  * Rest of code lifted with mods from the dev\ata\wd.c driver
  */
 
-/*     $NetBSD: ace_ebus.c,v 1.5 2012/10/27 17:17:45 chs Exp $ */
+/*     $NetBSD: ace_ebus.c,v 1.6 2013/05/29 00:47:48 christos Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -2464,48 +2464,16 @@
 #endif
 
 static void
-ace_params_to_properties(struct ace_softc *ace)
+ace_set_geometry(struct ace_softc *ace)
 {
-       prop_dictionary_t disk_info, odisk_info, geom;
-       const char *cp;
-
-       disk_info = prop_dictionary_create();
-
-       cp = ST506;
+       struct disk_geom *dg = &ace->sc_dk.dk_geom;
 
-       prop_dictionary_set_cstring_nocopy(disk_info, "type", cp);
-
-       geom = prop_dictionary_create();
-
-       prop_dictionary_set_uint64(geom, "sectors-per-unit", ace->sc_capacity);
-
-       prop_dictionary_set_uint32(geom, "sector-size",
-           DEV_BSIZE /* XXX 512? */);
-
-       prop_dictionary_set_uint16(geom, "sectors-per-track",
-           ace->sc_params.CurrentSectorsPerTrack);
+       memset(dg, 0, sizeof(*dg));
 
-       prop_dictionary_set_uint16(geom, "tracks-per-cylinder",
-           ace->sc_params.CurrentNumberOfHeads);
-
-       prop_dictionary_set_uint64(geom, "cylinders-per-unit",
-           ace->sc_capacity /
-           (ace->sc_params.CurrentNumberOfHeads *
-            ace->sc_params.CurrentSectorsPerTrack));
-
-       prop_dictionary_set(disk_info, "geometry", geom);
-       prop_object_release(geom);
+       dg->dg_secperunit = ace->sc_capacity;
+       dg->dg_secsize = DEV_BSIZE /* XXX 512? */;
+       dg->dg_nsectors = ace->sc_params.CurrentSectorsPerTrack;
+       dg->dg_ntracks = ace->sc_params.CurrentNumberOfHeads;
 
-       prop_dictionary_set(device_properties(ace->sc_dev),
-           "disk-info", disk_info);
-
-       /*
-        * Don't release disk_info here; we keep a reference to it.
-        * disk_detach() will release it when we go away.
-        */
-
-       odisk_info = ace->sc_dk.dk_info;
-       ace->sc_dk.dk_info = disk_info;
-       if (odisk_info)
-               prop_object_release(odisk_info);
+       disk_set_info(sc->sc_dev, &sc->sc_dk, ST506);
 }
diff -r ba9702412721 -r 1e9e68f2c6e8 sys/arch/emips/ebus/flash_ebus.c
--- a/sys/arch/emips/ebus/flash_ebus.c  Wed May 29 00:23:31 2013 +0000
+++ b/sys/arch/emips/ebus/flash_ebus.c  Wed May 29 00:47:48 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: flash_ebus.c,v 1.5 2012/10/27 17:17:45 chs Exp $       */
+/*     $NetBSD: flash_ebus.c,v 1.6 2013/05/29 00:47:48 christos Exp $  */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: flash_ebus.c,v 1.5 2012/10/27 17:17:45 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: flash_ebus.c,v 1.6 2013/05/29 00:47:48 christos Exp $");
 
 /* Driver for the Intel 28F320/640/128 (J3A150) StrataFlash memory device
  * Extended to include the Intel JS28F256P30T95.
@@ -1302,7 +1302,7 @@
 /* Rest of code lifted with mods from the dev\ata\wd.c driver
  */
 
-/*     $NetBSD: flash_ebus.c,v 1.5 2012/10/27 17:17:45 chs Exp $ */
+/*     $NetBSD: flash_ebus.c,v 1.6 2013/05/29 00:47:48 christos Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -1414,7 +1414,7 @@
 int   eflashactivate(device_t, enum devact);
 
 void  eflashdone(struct eflash_softc *);
-static void eflash_params_to_properties(struct eflash_softc *sc);
+static void eflash_set_geometry(struct eflash_softc *sc);
 
 struct dkdriver eflashdkdriver = { eflashstrategy, minphys };
 
@@ -1447,7 +1447,7 @@
            device_xname(self), pbuf, 1, 1, sc->sc_capacity,
            DEV_BSIZE, (unsigned long long)sc->sc_capacity);
 
-    eflash_params_to_properties(sc);
+    eflash_set_geometry(sc);
 
        /*
         * Attach the disk structure. We fill in dk_info later.
@@ -2293,45 +2293,17 @@
 #endif
 
 static void
-eflash_params_to_properties(struct eflash_softc *sc)
+eflash_set_geometry(struct eflash_softc *sc)
 {
-       prop_dictionary_t disk_info, odisk_info, geom;
-       const char *cp;
-
-       disk_info = prop_dictionary_create();
-
-    cp = ST506;
+       struct disk_geom *dg = &sc->sc_dk.dk_geom;
 
-       prop_dictionary_set_cstring_nocopy(disk_info, "type", cp);
-
-       geom = prop_dictionary_create();
-
-       prop_dictionary_set_uint64(geom, "sectors-per-unit", sc->sc_capacity);
-
-       prop_dictionary_set_uint32(geom, "sector-size",
-                                  DEV_BSIZE /* XXX 512? */);
-
-       prop_dictionary_set_uint16(geom, "sectors-per-track",
-                                  sc->sc_capacity);
+       memset(dg, 0, sizeof(*dg));
 
-       prop_dictionary_set_uint16(geom, "tracks-per-cylinder", 1);
-
-    prop_dictionary_set_uint64(geom, "cylinders-per-unit", sc->sc_capacity);
-
-       prop_dictionary_set(disk_info, "geometry", geom);
-       prop_object_release(geom);
-
-       prop_dictionary_set(device_properties(sc->sc_dev),
-                           "disk-info", disk_info);
+       dg->dg_secperunit = sc->sc_capacity;
+       dg->dg_secsize = DEV_BSIZE /* XXX 512? */;
+       dg->dg_nsectors = sc->sc_capacity;
+       dg->dg_ntracks = 1;
+       dg->dg_ncylinders = sc->sc_capacity;
 
-       /*
-        * Don't release disk_info here; we keep a reference to it.
-        * disk_detach() will release it when we go away.
-        */
-
-       odisk_info = sc->sc_dk.dk_info;
-       sc->sc_dk.dk_info = disk_info;
-       if (odisk_info)
-               prop_object_release(odisk_info);
+       disk_set_info(sc->sc_dev, &sc->sc_dk, ST506);
 }
-
diff -r ba9702412721 -r 1e9e68f2c6e8 sys/arch/sparc64/dev/fdc.c
--- a/sys/arch/sparc64/dev/fdc.c        Wed May 29 00:23:31 2013 +0000
+++ b/sys/arch/sparc64/dev/fdc.c        Wed May 29 00:47:48 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fdc.c,v 1.36 2011/08/08 14:49:06 jakllsch Exp $        */
+/*     $NetBSD: fdc.c,v 1.37 2013/05/29 00:47:48 christos Exp $        */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdc.c,v 1.36 2011/08/08 14:49:06 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdc.c,v 1.37 2013/05/29 00:47:48 christos Exp $");
 
 #include "opt_ddb.h"
 #include "opt_md.h"
@@ -383,7 +383,7 @@
                bus_addr_t,
                bus_size_t,
                bus_space_handle_t);
-static void    fd_set_properties(struct fd_softc *);
+static void    fd_set_geometry(struct fd_softc *);
 
 #ifdef MEMORY_DISK_HOOKS
 int    fd_read_md_image(size_t *, void **);
@@ -971,7 +971,7 @@
         */
        mountroothook_establish(fd_mountroot_hook, fd->sc_dev);
 
-       fd_set_properties(fd);
+       fd_set_geometry(fd);
 
        /* Make sure the drive motor gets turned off at shutdown time. */
        if (!pmf_device_register1(self, fdsuspend, NULL, fdshutdown))
@@ -2564,57 +2564,33 @@
 #endif /* MEMORY_DISK_HOOKS */
 
 static void
-fd_set_properties(struct fd_softc *fd)
+fd_set_geometry(struct fd_softc *fd)
 {
-       prop_dictionary_t disk_info, odisk_info, geom;
-       struct fd_type *fdt;
-       int secsize;
-
-       fdt = fd->sc_deftype;
-
-       disk_info = prop_dictionary_create();
-
-       geom = prop_dictionary_create();
+       const struct fd_type *fdt;
 
-       prop_dictionary_set_uint64(geom, "sectors-per-unit",
-           fdt->size);
-
-       switch (fdt->secsize) {
-       case 2:
-               secsize = 512;
-               break;
-       case 3:
-               secsize = 1024;
-               break;
-       default:
-               secsize = 0;
+       fdt = fd->sc_type;
+       if (fdt == NULL) {
+               fdt = fd->sc_deftype;
+               if (fdt == NULL)
+                       return;
        }
 
-       prop_dictionary_set_uint32(geom, "sector-size",
-           secsize);
-
-       prop_dictionary_set_uint16(geom, "sectors-per-track",
-           fdt->sectrac);
-
-       prop_dictionary_set_uint16(geom, "tracks-per-cylinder",
-           fdt->heads);
-
-       prop_dictionary_set_uint64(geom, "cylinders-per-unit",
-           fdt->cylinders);
+       struct disk_geom *dg = &fd->sc_dkdev.dk_geom;
 
-       prop_dictionary_set(disk_info, "geometry", geom);
-       prop_object_release(geom);
-
-       prop_dictionary_set(device_properties(fd->sc_dev),
-           "disk-info", disk_info);
-
-       /*
-        * Don't release disk_info here; we keep a reference to it.
-        * disk_detach() will release it when we go away.
-        */
-
-       odisk_info = fd->sc_dk.dk_info;



Home | Main Index | Thread Index | Old Index