diff options
| author | christos <christos@NetBSD.org> | 2013-05-29 00:47:48 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2013-05-29 00:47:48 +0000 |
| commit | 836e07dff3959fbb9fdc3dff54e1841c6c31b150 (patch) | |
| tree | 522bc0b47fd021095b525fddbc3a9e3217235097 /sys/dev | |
| parent | 8dd01b636de4f8864c078763a86c871c5b999be5 (diff) | |
phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/ata/wd.c | 62 | ||||
| -rw-r--r-- | sys/dev/cgd.c | 6 | ||||
| -rw-r--r-- | sys/dev/dksubr.c | 45 | ||||
| -rw-r--r-- | sys/dev/dkvar.h | 6 | ||||
| -rw-r--r-- | sys/dev/dkwedge/dk.c | 39 | ||||
| -rw-r--r-- | sys/dev/dm/device-mapper.c | 30 | ||||
| -rw-r--r-- | sys/dev/isa/fd.c | 63 | ||||
| -rw-r--r-- | sys/dev/ld.c | 51 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_netbsdkintf.c | 47 | ||||
| -rw-r--r-- | sys/dev/scsipi/cd.c | 39 | ||||
| -rw-r--r-- | sys/dev/scsipi/sd.c | 51 | ||||
| -rw-r--r-- | sys/dev/vnd.c | 55 |
12 files changed, 137 insertions, 357 deletions
diff --git a/sys/dev/ata/wd.c b/sys/dev/ata/wd.c index f3bfff1acae..33cc2931c74 100644 --- a/sys/dev/ata/wd.c +++ b/sys/dev/ata/wd.c @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.402 2013/01/09 22:03:49 riastradh Exp $ */ +/* $NetBSD: wd.c,v 1.403 2013/05/29 00:47:48 christos Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.402 2013/01/09 22:03:49 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.403 2013/05/29 00:47:48 christos Exp $"); #include "opt_ata.h" @@ -1727,56 +1727,22 @@ bad144intern(struct wd_softc *wd) static void wd_params_to_properties(struct wd_softc *wd, struct ataparams *params) { - prop_dictionary_t disk_info, odisk_info, geom; - const char *cp; + struct disk_geom *dg = &wd->sc_dk.dk_geom; - disk_info = prop_dictionary_create(); + memset(dg, 0, sizeof(*dg)); - if (strcmp(wd->sc_params.atap_model, "ST506") == 0) - cp = "ST506"; - else { - /* XXX Should have a case for ATA here, too. */ - cp = "ESDI"; - } - prop_dictionary_set_cstring_nocopy(disk_info, "type", cp); - - geom = prop_dictionary_create(); - - prop_dictionary_set_uint64(geom, "sectors-per-unit", wd->sc_capacity); - - prop_dictionary_set_uint32(geom, "sector-size", - DEV_BSIZE /* XXX 512? */); - - prop_dictionary_set_uint16(geom, "sectors-per-track", - wd->sc_params.atap_sectors); - - prop_dictionary_set_uint16(geom, "tracks-per-cylinder", - wd->sc_params.atap_heads); + dg->dg_secperunit = wd->sc_capacity; + dg->dg_secsize = DEV_BSIZE /* XXX 512? */; + dg->dg_nsectors = wd->sc_params.atap_sectors; + dg->dg_ntracks = wd->sc_params.atap_heads; + if ((wd->sc_flags & WDF_LBA) == 0) + dg->dg_ncylinders = wd->sc_params.atap_cylinders; - if (wd->sc_flags & WDF_LBA) - prop_dictionary_set_uint64(geom, "cylinders-per-unit", - wd->sc_capacity / - (wd->sc_params.atap_heads * - wd->sc_params.atap_sectors)); - else - prop_dictionary_set_uint16(geom, "cylinders-per-unit", - wd->sc_params.atap_cylinders); - - prop_dictionary_set(disk_info, "geometry", geom); - prop_object_release(geom); - - prop_dictionary_set(device_properties(wd->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. - */ + /* XXX Should have a case for ATA here, too. */ + const char *cp = strcmp(wd->sc_params.atap_model, "ST506") ? + "ST506" : "ESDI"; - odisk_info = wd->sc_dk.dk_info; - wd->sc_dk.dk_info = disk_info; - if (odisk_info) - prop_object_release(odisk_info); + disk_set_info(wd->sc_dev, &wd->sc_dk, cp); } int diff --git a/sys/dev/cgd.c b/sys/dev/cgd.c index fc407a494d6..21d14764b10 100644 --- a/sys/dev/cgd.c +++ b/sys/dev/cgd.c @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.78 2012/12/05 02:23:20 christos Exp $ */ +/* $NetBSD: cgd.c,v 1.79 2013/05/29 00:47:48 christos Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.78 2012/12/05 02:23:20 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.79 2013/05/29 00:47:48 christos Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -694,7 +694,7 @@ cgd_ioctl_set(struct cgd_softc *cs, void *data, struct lwp *l) cs->sc_dksc.sc_flags |= DKF_INITED; - dk_set_properties(di, &cs->sc_dksc); + dk_set_geometry(di, &cs->sc_dksc); /* Attach the disk. */ disk_attach(&cs->sc_dksc.sc_dkdev); diff --git a/sys/dev/dksubr.c b/sys/dev/dksubr.c index e353ae32477..b3530349e6a 100644 --- a/sys/dev/dksubr.c +++ b/sys/dev/dksubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: dksubr.c,v 1.45 2012/05/29 10:20:33 elric Exp $ */ +/* $NetBSD: dksubr.c,v 1.46 2013/05/29 00:47:48 christos Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.45 2012/05/29 10:20:33 elric Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.46 2013/05/29 00:47:48 christos Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -627,43 +627,20 @@ dk_makedisklabel(struct dk_intf *di, struct dk_softc *dksc) } void -dk_set_properties(struct dk_intf *di, struct dk_softc *dksc) +dk_set_geometry(struct dk_intf *di, struct dk_softc *dksc) { - prop_dictionary_t disk_info, odisk_info, geom; + struct disk_geom *dg = &dksc->sc_dkdev.dk_geom; - disk_info = prop_dictionary_create(); + memset(dg, 0, sizeof(*dg)); - geom = prop_dictionary_create(); + dg->dg_secperunit = dksc->sc_size; + dg->dg_secsize = dksc->sc_geom.pdg_secsize; + dg->dg_nsectors = dksc->sc_geom.pdg_nsectors; + dg->dg_ntracks = dksc->sc_geom.pdg_ntracks; + dg->dg_ncylinders = dksc->sc_geom.pdg_ncylinders; - prop_dictionary_set_uint64(geom, "sectors-per-unit", dksc->sc_size); + disk_set_info(dksc->sc_dev, &dksc->sc_dkdev, NULL); - prop_dictionary_set_uint32(geom, "sector-size", - dksc->sc_geom.pdg_secsize); - - prop_dictionary_set_uint16(geom, "sectors-per-track", - dksc->sc_geom.pdg_nsectors); - - prop_dictionary_set_uint16(geom, "tracks-per-cylinder", - dksc->sc_geom.pdg_ntracks); - - prop_dictionary_set_uint64(geom, "cylinders-per-unit", - dksc->sc_geom.pdg_ncylinders); - - prop_dictionary_set(disk_info, "geometry", geom); - prop_object_release(geom); - - prop_dictionary_set(device_properties(dksc->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 = dksc->sc_dkdev.dk_info; - dksc->sc_dkdev.dk_info = disk_info; - if (odisk_info) - prop_object_release(odisk_info); } /* This function is taken from ccd.c:1.76 --rcd */ diff --git a/sys/dev/dkvar.h b/sys/dev/dkvar.h index a22eb903b78..7cb7a2e3f52 100644 --- a/sys/dev/dkvar.h +++ b/sys/dev/dkvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: dkvar.h,v 1.16 2012/05/25 10:53:46 elric Exp $ */ +/* $NetBSD: dkvar.h,v 1.17 2013/05/29 00:47:48 christos Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -32,6 +32,7 @@ struct pathbuf; /* from namei.h */ +/* XXX: GC */ struct dk_geom { u_int32_t pdg_secsize; u_int32_t pdg_nsectors; @@ -112,6 +113,7 @@ int dk_dump(struct dk_intf *, struct dk_softc *, dev_t, void dk_getdisklabel(struct dk_intf *, struct dk_softc *, dev_t); void dk_getdefaultlabel(struct dk_intf *, struct dk_softc *, struct disklabel *); -void dk_set_properties(struct dk_intf *, struct dk_softc *); +/* XXX: GC use disk_set_info() */ +void dk_set_geometry(struct dk_intf *, struct dk_softc *); int dk_lookup(struct pathbuf *, struct lwp *, struct vnode **); diff --git a/sys/dev/dkwedge/dk.c b/sys/dev/dkwedge/dk.c index 6cb44adb25a..87f94086d38 100644 --- a/sys/dev/dkwedge/dk.c +++ b/sys/dev/dkwedge/dk.c @@ -1,4 +1,4 @@ -/* $NetBSD: dk.c,v 1.65 2012/10/27 17:18:15 chs Exp $ */ +/* $NetBSD: dk.c,v 1.66 2013/05/29 00:47:48 christos Exp $ */ /*- * Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.65 2012/10/27 17:18:15 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.66 2013/05/29 00:47:48 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_dkwedge.h" @@ -228,35 +228,18 @@ dkwedge_array_expand(void) static void dkgetproperties(struct disk *disk, struct dkwedge_info *dkw) { - prop_dictionary_t disk_info, odisk_info, geom; + struct disk_geom *dg = &disk->dk_geom; - disk_info = prop_dictionary_create(); + memset(dg, 0, sizeof(*dg)); - prop_dictionary_set_cstring_nocopy(disk_info, "type", "ESDI"); + dg->dg_secperunit = dkw->dkw_size >> disk->dk_blkshift; + dg->dg_secsize = DEV_BSIZE << disk->dk_blkshift; + dg->dg_nsectors = 32; + dg->dg_ntracks = 64; + /* XXX: why is that dkw->dkw_size instead of secperunit?!?! */ + dg->dg_ncylinders = dkw->dkw_size / (dg->dg_nsectors * dg->dg_ntracks); - geom = prop_dictionary_create(); - - prop_dictionary_set_uint64(geom, "sectors-per-unit", - dkw->dkw_size >> disk->dk_blkshift); - - prop_dictionary_set_uint32(geom, "sector-size", - DEV_BSIZE << disk->dk_blkshift); - - prop_dictionary_set_uint32(geom, "sectors-per-track", 32); - - prop_dictionary_set_uint32(geom, "tracks-per-cylinder", 64); - - prop_dictionary_set_uint32(geom, "cylinders-per-unit", dkw->dkw_size / 2048); - - prop_dictionary_set(disk_info, "geometry", geom); - prop_object_release(geom); - - odisk_info = disk->dk_info; - - disk->dk_info = disk_info; - - if (odisk_info != NULL) - prop_object_release(odisk_info); + disk_set_info(NULL, disk, "ESDI"); } /* diff --git a/sys/dev/dm/device-mapper.c b/sys/dev/dm/device-mapper.c index 16f938b47a7..397416973bf 100644 --- a/sys/dev/dm/device-mapper.c +++ b/sys/dev/dm/device-mapper.c @@ -1,4 +1,4 @@ -/* $NetBSD: device-mapper.c,v 1.29 2012/03/13 18:40:30 elad Exp $ */ +/* $NetBSD: device-mapper.c,v 1.30 2013/05/29 00:47:48 christos Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -673,28 +673,20 @@ dmminphys(struct buf *bp) void dmgetproperties(struct disk *disk, dm_table_head_t *head) { - prop_dictionary_t disk_info, odisk_info, geom; uint64_t numsec; unsigned secsize; dm_table_disksize(head, &numsec, &secsize); - disk_info = prop_dictionary_create(); - geom = prop_dictionary_create(); - - prop_dictionary_set_cstring_nocopy(disk_info, "type", "ESDI"); - prop_dictionary_set_uint64(geom, "sectors-per-unit", numsec); - prop_dictionary_set_uint32(geom, "sector-size", secsize); - prop_dictionary_set_uint32(geom, "sectors-per-track", 32); - prop_dictionary_set_uint32(geom, "tracks-per-cylinder", 64); - prop_dictionary_set_uint32(geom, "cylinders-per-unit", numsec / 2048); - prop_dictionary_set(disk_info, "geometry", geom); - prop_object_release(geom); - - odisk_info = disk->dk_info; - disk->dk_info = disk_info; - - if (odisk_info != NULL) - prop_object_release(odisk_info); + + struct disk_geom *dg = &disk->dk_geom; + + memset(dg, 0, sizeof(*dg)); + dg->dg_secperunit = numsec; + dg->dg_secsize = secsize; + dg->dg_nsectors = 32; + dg->dg_ntracks = 64; + + disk_set_info(NULL, disk, "ESDI"); disk_blocksize(disk, secsize); } diff --git a/sys/dev/isa/fd.c b/sys/dev/isa/fd.c index c511fdbe3ec..eb2ad9e0604 100644 --- a/sys/dev/isa/fd.c +++ b/sys/dev/isa/fd.c @@ -1,4 +1,4 @@ -/* $NetBSD: fd.c,v 1.100 2012/02/02 19:43:04 tls Exp $ */ +/* $NetBSD: fd.c,v 1.101 2013/05/29 00:47:48 christos Exp $ */ /*- * Copyright (c) 1998, 2003, 2008 The NetBSD Foundation, Inc. @@ -81,7 +81,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.100 2012/02/02 19:43:04 tls Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.101 2013/05/29 00:47:48 christos Exp $"); #include "opt_ddb.h" @@ -252,7 +252,7 @@ void fdcretry(struct fdc_softc *fdc); void fdfinish(struct fd_softc *fd, struct buf *bp); static const struct fd_type *fd_dev_to_type(struct fd_softc *, dev_t); int fdformat(dev_t, struct ne7_fd_formb *, struct lwp *); -static void fd_set_properties(struct fd_softc *fd); +static void fd_set_geometry(struct fd_softc *fd); void fd_mountroot_hook(device_t); @@ -572,7 +572,7 @@ fdattach(device_t parent, device_t self, void *aux) rnd_attach_source(&fd->rnd_source, device_xname(fd->sc_dev), RND_TYPE_DISK, 0); - fd_set_properties(fd); + fd_set_geometry(fd); if (!pmf_device_register(self, NULL, NULL)) aprint_error_dev(self, "cannot set power mgmt handler\n"); @@ -600,7 +600,7 @@ fddetach(device_t self, int flags) pmf_device_deregister(self); #if 0 /* XXX need to undo at detach? */ - fd_set_properties(fd); + fd_set_geometry(fd); #endif rnd_detach_source(&fd->rnd_source); @@ -917,7 +917,7 @@ fdopen(dev_t dev, int flags, int mode, struct lwp *l) fd->sc_cylin = -1; fd->sc_flags |= FD_OPEN; - fd_set_properties(fd); + fd_set_geometry(fd); return 0; } @@ -1651,11 +1651,9 @@ fd_mountroot_hook(device_t dev) } static void -fd_set_properties(struct fd_softc *fd) +fd_set_geometry(struct fd_softc *fd) { - prop_dictionary_t disk_info, odisk_info, geom; const struct fd_type *fdt; - int secsize; fdt = fd->sc_type; if (fdt == NULL) { @@ -1664,49 +1662,22 @@ fd_set_properties(struct fd_softc *fd) return; } - disk_info = prop_dictionary_create(); - - geom = prop_dictionary_create(); - - prop_dictionary_set_uint64(geom, "sectors-per-unit", - fdt->size); + struct disk_geom *dg = &fd->sc_dk.dk_geom; + memset(dg, 0, sizeof(*dg)); + dg->dg_secperunit = fdt->size; + dg->dg_nsectors = fdt->sectrac; switch (fdt->secsize) { case 2: - secsize = 512; + dg->dg_secsize = 512; break; case 3: - secsize = 1024; + dg->dg_secsize = 1024; break; default: - secsize = 0; + break; } - - 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->cyls); - - 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; - fd->sc_dk.dk_info = disk_info; - if (odisk_info) - prop_object_release(odisk_info); + dg->dg_ntracks = fdt->heads; + dg->dg_ncylinders = fdt->cyls; + disk_set_info(fd->sc_dev, &fd->sc_dk, NULL); } diff --git a/sys/dev/ld.c b/sys/dev/ld.c index 05607ba75cb..95d2a904233 100644 --- a/sys/dev/ld.c +++ b/sys/dev/ld.c @@ -1,4 +1,4 @@ -/* $NetBSD: ld.c,v 1.70 2012/10/27 17:18:14 chs Exp $ */ +/* $NetBSD: ld.c,v 1.71 2013/05/29 00:47:48 christos Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.70 2012/10/27 17:18:14 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.71 2013/05/29 00:47:48 christos Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -66,7 +66,7 @@ static void ldminphys(struct buf *bp); static bool ld_suspend(device_t, const pmf_qual_t *); static bool ld_shutdown(device_t, int); static void ldstart(struct ld_softc *, struct buf *); -static void ld_set_properties(struct ld_softc *); +static void ld_set_geometry(struct ld_softc *); static void ld_config_interrupts (device_t); static int ldlastclose(device_t); @@ -143,7 +143,7 @@ ldattach(struct ld_softc *sc) sc->sc_nsectors, sc->sc_secsize, sc->sc_secperunit); sc->sc_disksize512 = sc->sc_secperunit * sc->sc_secsize / DEV_BSIZE; - ld_set_properties(sc); + ld_set_geometry(sc); /* Attach the device into the rnd source list. */ rnd_attach_source(&sc->sc_rnd_source, device_xname(sc->sc_dv), @@ -889,44 +889,19 @@ ldminphys(struct buf *bp) } static void -ld_set_properties(struct ld_softc *ld) +ld_set_geometry(struct ld_softc *ld) { - prop_dictionary_t disk_info, odisk_info, geom; + struct disk_geom *dg = &ld->sc_dk.dk_geom; - disk_info = prop_dictionary_create(); + memset(dg, 0, sizeof(*dg)); - geom = prop_dictionary_create(); + dg->dg_secperunit = ld->sc_secperunit; + dg->dg_secsize = ld->sc_secsize; + dg->dg_nsectors = ld->sc_nsectors; + dg->dg_ntracks = ld->sc_nheads; + dg->dg_ncylinders = ld->sc_ncylinders; - prop_dictionary_set_uint64(geom, "sectors-per-unit", - ld->sc_secperunit); - - prop_dictionary_set_uint32(geom, "sector-size", - ld->sc_secsize); - - prop_dictionary_set_uint16(geom, "sectors-per-track", - ld->sc_nsectors); - - prop_dictionary_set_uint16(geom, "tracks-per-cylinder", - ld->sc_nheads); - - prop_dictionary_set_uint64(geom, "cylinders-per-unit", - ld->sc_ncylinders); - - prop_dictionary_set(disk_info, "geometry", geom); - prop_object_release(geom); - - prop_dictionary_set(device_properties(ld->sc_dv), - "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 = ld->sc_dk.dk_info; - ld->sc_dk.dk_info = disk_info; - if (odisk_info) - prop_object_release(odisk_info); + disk_set_info(ld->sc_dv, &ld->sc_dk, NULL); } static void diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c index b6ab5c503d1..fc15d1abd97 100644 --- a/sys/dev/raidframe/rf_netbsdkintf.c +++ b/sys/dev/raidframe/rf_netbsdkintf.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_netbsdkintf.c,v 1.303 2013/05/23 14:15:52 christos Exp $ */ +/* $NetBSD: rf_netbsdkintf.c,v 1.304 2013/05/29 00:47:49 christos Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc. @@ -101,7 +101,7 @@ ***********************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.303 2013/05/23 14:15:52 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.304 2013/05/29 00:47:49 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -280,7 +280,7 @@ static void raidunlock(struct raid_softc *); static int raid_detach_unlocked(struct raid_softc *); static void rf_markalldirty(RF_Raid_t *); -static void rf_set_properties(struct raid_softc *, RF_Raid_t *); +static void rf_set_geometry(struct raid_softc *, RF_Raid_t *); void rf_ReconThread(struct rf_recon_req *); void rf_RewriteParityThread(RF_Raid_t *raidPtr); @@ -1961,7 +1961,7 @@ raidinit(struct raid_softc *rs) dkwedge_discover(&rs->sc_dkdev); - rf_set_properties(rs, raidPtr); + rf_set_geometry(rs, raidPtr); } #if (RF_INCLUDE_PARITY_DECLUSTERING_DS > 0) @@ -3859,33 +3859,18 @@ raid_detach(device_t self, int flags) } static void -rf_set_properties(struct raid_softc *rs, RF_Raid_t *raidPtr) -{ - prop_dictionary_t disk_info, odisk_info, geom; - disk_info = prop_dictionary_create(); - geom = prop_dictionary_create(); - prop_dictionary_set_uint64(geom, "sectors-per-unit", - raidPtr->totalSectors); - prop_dictionary_set_uint32(geom, "sector-size", - raidPtr->bytesPerSector); - - prop_dictionary_set_uint16(geom, "sectors-per-track", - raidPtr->Layout.dataSectorsPerStripe); - prop_dictionary_set_uint16(geom, "tracks-per-cylinder", - 4 * raidPtr->numCol); - - prop_dictionary_set_uint64(geom, "cylinders-per-unit", - raidPtr->totalSectors / (raidPtr->Layout.dataSectorsPerStripe * - (4 * raidPtr->numCol))); - - prop_dictionary_set(disk_info, "geometry", geom); - prop_object_release(geom); - prop_dictionary_set(device_properties(rs->sc_dev), - "disk-info", disk_info); - odisk_info = rs->sc_dkdev.dk_info; - rs->sc_dkdev.dk_info = disk_info; - if (odisk_info) - prop_object_release(odisk_info); +rf_set_geometry(struct raid_softc *rs, RF_Raid_t *raidPtr) +{ + struct disk_geom *dg = &rs->sc_dkdev.dk_geom; + + memset(dg, 0, sizeof(*dg)); + + dg->dg_secperunit = raidPtr->totalSectors; + dg->dg_secsize = raidPtr->bytesPerSector; + dg->dg_nsectors = raidPtr->Layout.dataSectorsPerStripe; + dg->dg_ntracks = 4 * raidPtr->numCol; + + disk_set_info(rs->sc_dev, &rs->sc_dkdev, NULL); } /* diff --git a/sys/dev/scsipi/cd.c b/sys/dev/scsipi/cd.c index c4296926fcd..346f6c0b4de 100644 --- a/sys/dev/scsipi/cd.c +++ b/sys/dev/scsipi/cd.c @@ -1,4 +1,4 @@ -/* $NetBSD: cd.c,v 1.310 2013/03/15 16:16:12 martin Exp $ */ +/* $NetBSD: cd.c,v 1.311 2013/05/29 00:47:49 christos Exp $ */ /*- * Copyright (c) 1998, 2001, 2003, 2004, 2005, 2008 The NetBSD Foundation, @@ -50,7 +50,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.310 2013/03/15 16:16:12 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.311 2013/05/29 00:47:49 christos Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -174,7 +174,7 @@ static int mmc_gettrackinfo(struct scsipi_periph *, struct mmc_trackinfo *); static int mmc_do_op(struct scsipi_periph *, struct mmc_op *); static int mmc_setup_writeparams(struct scsipi_periph *, struct mmc_writeparams *); -static void cd_set_properties(struct cd_softc *); +static void cd_set_geometry(struct cd_softc *); CFATTACH_DECL3_NEW(cd, sizeof(struct cd_softc), cdmatch, cdattach, cddetach, NULL, NULL, NULL, DVF_DETACH_SHUTDOWN); @@ -448,7 +448,7 @@ cdopen(dev_t dev, int flag, int fmt, struct lwp *l) cdgetdisklabel(cd); SC_DEBUG(periph, SCSIPI_DB3, ("Disklabel fabricated ")); - cd_set_properties(cd); + cd_set_geometry(cd); } } @@ -3906,33 +3906,14 @@ mmc_setup_writeparams(struct scsipi_periph *periph, } static void -cd_set_properties(struct cd_softc *cd) +cd_set_geometry(struct cd_softc *cd) { - prop_dictionary_t disk_info, odisk_info, geom; + struct disk_geom *dg = &cd->sc_dk.dk_geom; - disk_info = prop_dictionary_create(); + memset(dg, 0, sizeof(*dg)); - geom = prop_dictionary_create(); + dg->dg_secperunit = cd->params.disksize; + dg->dg_secsize = cd->params.blksize; - prop_dictionary_set_uint64(geom, "sectors-per-unit", - cd->params.disksize); - - prop_dictionary_set_uint32(geom, "sector-size", - cd->params.blksize); - - prop_dictionary_set(disk_info, "geometry", geom); - prop_object_release(geom); - - prop_dictionary_set(device_properties(cd->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 = cd->sc_dk.dk_info; - cd->sc_dk.dk_info = disk_info; - if (odisk_info) - prop_object_release(odisk_info); + disk_set_info(cd->sc_dev, &cd->sc_dk, NULL); } diff --git a/sys/dev/scsipi/sd.c b/sys/dev/scsipi/sd.c index 6f43755e833..aed0adf63bf 100644 --- a/sys/dev/scsipi/sd.c +++ b/sys/dev/scsipi/sd.c @@ -1,4 +1,4 @@ -/* $NetBSD: sd.c,v 1.299 2013/04/16 21:01:09 jakllsch Exp $ */ +/* $NetBSD: sd.c,v 1.300 2013/05/29 00:47:49 christos Exp $ */ /*- * Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc. @@ -47,7 +47,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.299 2013/04/16 21:01:09 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.300 2013/05/29 00:47:49 christos Exp $"); #include "opt_scsi.h" @@ -125,7 +125,7 @@ static int sd_setcache(struct sd_softc *, int); static int sdmatch(device_t, cfdata_t, void *); static void sdattach(device_t, device_t, void *); static int sddetach(device_t, int); -static void sd_set_properties(struct sd_softc *); +static void sd_set_geometry(struct sd_softc *); CFATTACH_DECL3_NEW(sd, sizeof(struct sd_softc), sdmatch, sdattach, sddetach, NULL, NULL, NULL, DVF_DETACH_SHUTDOWN); @@ -2160,7 +2160,7 @@ page0: dp->rot_rate = 3600; setprops: - sd_set_properties(sd); + sd_set_geometry(sd); return (SDGP_RESULT_OK); } @@ -2298,42 +2298,17 @@ sd_setcache(struct sd_softc *sd, int bits) } static void -sd_set_properties(struct sd_softc *sd) +sd_set_geometry(struct sd_softc *sd) { - prop_dictionary_t disk_info, odisk_info, geom; + struct disk_geom *dg = &sd->sc_dk.dk_geom; - disk_info = prop_dictionary_create(); + memset(dg, 0, sizeof(*dg)); - geom = prop_dictionary_create(); + dg->dg_secperunit = sd->params.disksize; + dg->dg_secsize = sd->params.blksize; + dg->dg_nsectors = sd->params.sectors; + dg->dg_ntracks = sd->params.heads; + dg->dg_ncylinders = sd->params.cyls; - prop_dictionary_set_uint64(geom, "sectors-per-unit", - sd->params.disksize); - - prop_dictionary_set_uint32(geom, "sector-size", - sd->params.blksize); - - prop_dictionary_set_uint16(geom, "sectors-per-track", - sd->params.sectors); - - prop_dictionary_set_uint16(geom, "tracks-per-cylinder", - sd->params.heads); - - prop_dictionary_set_uint64(geom, "cylinders-per-unit", - sd->params.cyls); - - prop_dictionary_set(disk_info, "geometry", geom); - prop_object_release(geom); - - prop_dictionary_set(device_properties(sd->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 = sd->sc_dk.dk_info; - sd->sc_dk.dk_info = disk_info; - if (odisk_info) - prop_object_release(odisk_info); + disk_set_info(sd->sc_dev, &sd->sc_dk, NULL); } diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c index 851587b3fcd..8686ccfb16d 100644 --- a/sys/dev/vnd.c +++ b/sys/dev/vnd.c @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.221 2012/06/09 06:20:45 mlelstv Exp $ */ +/* $NetBSD: vnd.c,v 1.222 2013/05/29 00:47:48 christos Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.221 2012/06/09 06:20:45 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.222 2013/05/29 00:47:48 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -127,8 +127,6 @@ __KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.221 2012/06/09 06:20:45 mlelstv Exp $"); #include <dev/dkvar.h> #include <dev/vndvar.h> -#include <prop/proplib.h> - #if defined(VNDDEBUG) && !defined(DEBUG) #define DEBUG #endif @@ -187,7 +185,7 @@ static void handle_with_rdwr(struct vnd_softc *, const struct buf *, struct buf *); static void handle_with_strategy(struct vnd_softc *, const struct buf *, struct buf *); -static void vnd_set_properties(struct vnd_softc *); +static void vnd_set_geometry(struct vnd_softc *); static dev_type_open(vndopen); static dev_type_close(vndclose); @@ -1296,7 +1294,7 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) vnd->sc_geom.vng_ncylinders = vnd->sc_size; } - vnd_set_properties(vnd); + vnd_set_geometry(vnd); if (vio->vnd_flags & VNDIOF_READONLY) { vnd->sc_flags |= VNF_READONLY; @@ -1998,45 +1996,20 @@ vnd_free(void *aux, void *ptr) #endif /* VND_COMPRESSION */ static void -vnd_set_properties(struct vnd_softc *vnd) +vnd_set_geometry(struct vnd_softc *vnd) { - prop_dictionary_t disk_info, odisk_info, geom; - - disk_info = prop_dictionary_create(); - - geom = prop_dictionary_create(); - - prop_dictionary_set_uint64(geom, "sectors-per-unit", - vnd->sc_geom.vng_nsectors * vnd->sc_geom.vng_ntracks * - vnd->sc_geom.vng_ncylinders); - - prop_dictionary_set_uint32(geom, "sector-size", - vnd->sc_geom.vng_secsize); - - prop_dictionary_set_uint16(geom, "sectors-per-track", - vnd->sc_geom.vng_nsectors); + struct disk_geom *dg = &vnd->sc_dkdev.dk_geom; - prop_dictionary_set_uint16(geom, "tracks-per-cylinder", - vnd->sc_geom.vng_ntracks); + memset(dg, 0, sizeof(*dg)); - prop_dictionary_set_uint64(geom, "cylinders-per-unit", - vnd->sc_geom.vng_ncylinders); - - prop_dictionary_set(disk_info, "geometry", geom); - prop_object_release(geom); - - prop_dictionary_set(device_properties(vnd->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. - */ + dg->dg_secperunit = vnd->sc_geom.vng_nsectors * + vnd->sc_geom.vng_ntracks * vnd->sc_geom.vng_ncylinders; + dg->dg_secsize = vnd->sc_geom.vng_secsize; + dg->dg_nsectors = vnd->sc_geom.vng_nsectors; + dg->dg_ntracks = vnd->sc_geom.vng_ntracks; + dg->dg_ncylinders = vnd->sc_geom.vng_ncylinders; - odisk_info = vnd->sc_dkdev.dk_info; - vnd->sc_dkdev.dk_info = disk_info; - if (odisk_info) - prop_object_release(odisk_info); + disk_set_info(vnd->sc_dev, &vnd->sc_dkdev, NULL); } #ifdef _MODULE |
