summaryrefslogtreecommitdiff
path: root/sys/dev/ld.c
diff options
context:
space:
mode:
authortron <tron@NetBSD.org>2008-09-09 12:45:39 +0000
committertron <tron@NetBSD.org>2008-09-09 12:45:39 +0000
commit362b2f2b14c1ef4eb878a8ef1853bb3a55ea2446 (patch)
tree318c44a3ab8ecf2b2b2be52204c6cff93110ee81 /sys/dev/ld.c
parent5f566e7cf34e427dfa6e8c3738b25b5c3b86ddd0 (diff)
Complete device_t/softc split for the ld(4) attachments. This should
prevent crashes while attaching a drive. Patch supplied by Juan RP in PR kern/39468.
Diffstat (limited to 'sys/dev/ld.c')
-rw-r--r--sys/dev/ld.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/sys/dev/ld.c b/sys/dev/ld.c
index 0dc73ec21e3..492f0b47b76 100644
--- a/sys/dev/ld.c
+++ b/sys/dev/ld.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ld.c,v 1.62 2008/08/11 06:43:37 simonb Exp $ */
+/* $NetBSD: ld.c,v 1.63 2008/09/09 12:45:39 tron 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.62 2008/08/11 06:43:37 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.63 2008/09/09 12:45:39 tron Exp $");
#include "rnd.h"
@@ -102,12 +102,12 @@ ldattach(struct ld_softc *sc)
mutex_init(&sc->sc_mutex, MUTEX_DEFAULT, IPL_VM);
if ((sc->sc_flags & LDF_ENABLED) == 0) {
- aprint_normal_dev(&sc->sc_dv, "disabled\n");
+ aprint_normal_dev(sc->sc_dv, "disabled\n");
return;
}
/* Initialise and attach the disk structure. */
- disk_init(&sc->sc_dk, device_xname(&sc->sc_dv), &lddkdriver);
+ disk_init(&sc->sc_dk, device_xname(sc->sc_dv), &lddkdriver);
disk_attach(&sc->sc_dk);
if (sc->sc_maxxfer > MAXPHYS)
@@ -139,7 +139,8 @@ ldattach(struct ld_softc *sc)
format_bytes(tbuf, sizeof(tbuf), sc->sc_secperunit *
sc->sc_secsize);
- aprint_normal_dev(&sc->sc_dv, "%s, %d cyl, %d head, %d sec, %d bytes/sect x %"PRIu64" sectors\n",
+ aprint_normal_dev(sc->sc_dv, "%s, %d cyl, %d head, %d sec, "
+ "%d bytes/sect x %"PRIu64" sectors\n",
tbuf, sc->sc_ncylinders, sc->sc_nheads,
sc->sc_nsectors, sc->sc_secsize, sc->sc_secperunit);
@@ -147,19 +148,19 @@ ldattach(struct ld_softc *sc)
#if NRND > 0
/* Attach the device into the rnd source list. */
- rnd_attach_source(&sc->sc_rnd_source, device_xname(&sc->sc_dv),
+ rnd_attach_source(&sc->sc_rnd_source, device_xname(sc->sc_dv),
RND_TYPE_DISK, 0);
#endif
/* Register with PMF */
- if (!pmf_device_register1(&sc->sc_dv, NULL, NULL, ld_shutdown))
- aprint_error_dev(&sc->sc_dv,
+ if (!pmf_device_register1(sc->sc_dv, NULL, NULL, ld_shutdown))
+ aprint_error_dev(sc->sc_dv,
"couldn't establish power handler\n");
bufq_alloc(&sc->sc_bufq, BUFQ_DISK_DEFAULT_STRAT, BUFQ_SORT_RAWBLOCK);
/* Discover wedges on this disk. */
- config_interrupts(&sc->sc_dv, ld_config_interrupts);
+ config_interrupts(sc->sc_dv, ld_config_interrupts);
}
int
@@ -210,7 +211,7 @@ ldenddetach(struct ld_softc *sc)
/* Wait for commands queued with the hardware to complete. */
if (sc->sc_queuecnt != 0)
if (tsleep(&sc->sc_queuecnt, PRIBIO, "lddtch", 30 * hz))
- printf("%s: not drained\n", device_xname(&sc->sc_dv));
+ printf("%s: not drained\n", device_xname(sc->sc_dv));
/* Locate the major numbers. */
bmaj = bdevsw_lookup_major(&ld_bdevsw);
@@ -225,7 +226,7 @@ ldenddetach(struct ld_softc *sc)
/* Nuke the vnodes for any open instances. */
for (i = 0; i < MAXPARTITIONS; i++) {
- mn = DISKMINOR(device_unit(&sc->sc_dv), i);
+ mn = DISKMINOR(device_unit(sc->sc_dv), i);
vdevgone(bmaj, mn, mn, VBLK);
vdevgone(cmaj, mn, mn, VCHR);
}
@@ -243,7 +244,7 @@ ldenddetach(struct ld_softc *sc)
#endif
/* Deregister with PMF */
- pmf_device_deregister(&sc->sc_dv);
+ pmf_device_deregister(sc->sc_dv);
/*
* XXX We can't really flush the cache here, beceause the
@@ -346,7 +347,7 @@ ldclose(dev_t dev, int flags, int fmt, struct lwp *l)
if (sc->sc_dk.dk_openmask == 0) {
if (sc->sc_flush != NULL && (*sc->sc_flush)(sc, 0) != 0)
- aprint_error_dev(&sc->sc_dv, "unable to flush cache\n");
+ aprint_error_dev(sc->sc_dv, "unable to flush cache\n");
if ((sc->sc_flags & LDF_KLABEL) == 0)
sc->sc_flags &= ~LDF_VLABEL;
}
@@ -500,7 +501,7 @@ ldioctl(dev_t dev, u_long cmd, void *addr, int32_t flag, struct lwp *l)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
- strlcpy(dkw->dkw_parent, device_xname(&sc->sc_dv),
+ strlcpy(dkw->dkw_parent, device_xname(sc->sc_dv),
sizeof(dkw->dkw_parent));
return (dkwedge_add(dkw));
}
@@ -513,7 +514,7 @@ ldioctl(dev_t dev, u_long cmd, void *addr, int32_t flag, struct lwp *l)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
- strlcpy(dkw->dkw_parent, device_xname(&sc->sc_dv),
+ strlcpy(dkw->dkw_parent, device_xname(sc->sc_dv),
sizeof(dkw->dkw_parent));
return (dkwedge_del(dkw));
}
@@ -755,10 +756,10 @@ ldgetdisklabel(struct ld_softc *sc)
ldgetdefaultlabel(sc, sc->sc_dk.dk_label);
/* Call the generic disklabel extraction routine. */
- errstring = readdisklabel(MAKEDISKDEV(0, device_unit(&sc->sc_dv),
+ errstring = readdisklabel(MAKEDISKDEV(0, device_unit(sc->sc_dv),
RAW_PART), ldstrategy, sc->sc_dk.dk_label, sc->sc_dk.dk_cpulabel);
if (errstring != NULL)
- printf("%s: %s\n", device_xname(&sc->sc_dv), errstring);
+ printf("%s: %s\n", device_xname(sc->sc_dv), errstring);
/* In-core label now valid. */
sc->sc_flags |= LDF_VLABEL;
@@ -899,7 +900,7 @@ ld_set_properties(struct ld_softc *ld)
prop_dictionary_set(disk_info, "geometry", geom);
prop_object_release(geom);
- prop_dictionary_set(device_properties(&ld->sc_dv),
+ prop_dictionary_set(device_properties(ld->sc_dv),
"disk-info", disk_info);
/*