Module Name: src
Committed By: jnemeth
Date: Mon May 25 19:22:54 UTC 2009
Modified Files:
src/sys/arch/sparc/dev: fd.c
Log Message:
Convert shutdownhook_establish() to pmf_device_register1().
XXX This should be done as part of an overall plan to support
power management and device detachment. However, in order to do
that, I would first have to invent sbus_intr_disestablish(). This
is being done at this time in order to aid in the effort to eliminate
shutdownhook_establish().
This was based on the sys/arch/sparc64/fd.c change. Thanks to jdc@
for testing this version.
To generate a diff of this commit:
cvs rdiff -u -r1.145 -r1.146 src/sys/arch/sparc/dev/fd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/sparc/dev/fd.c
diff -u src/sys/arch/sparc/dev/fd.c:1.145 src/sys/arch/sparc/dev/fd.c:1.146
--- src/sys/arch/sparc/dev/fd.c:1.145 Wed Mar 18 16:00:14 2009
+++ src/sys/arch/sparc/dev/fd.c Mon May 25 19:22:53 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: fd.c,v 1.145 2009/03/18 16:00:14 cegger Exp $ */
+/* $NetBSD: fd.c,v 1.146 2009/05/25 19:22:53 jnemeth Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.145 2009/03/18 16:00:14 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.146 2009/05/25 19:22:53 jnemeth Exp $");
#include "opt_ddb.h"
#include "opt_md.h"
@@ -282,8 +282,6 @@
int sc_cylin; /* where we think the head is */
int sc_opts; /* user-set options */
- void *sc_sdhook; /* shutdownhook cookie */
-
TAILQ_ENTRY(fd_softc) sc_drivechain;
int sc_ops; /* I/O ops since last switch */
struct bufq_state *sc_q;/* pending I/O requests */
@@ -293,6 +291,8 @@
/* floppy driver configuration */
int fdmatch(struct device *, struct cfdata *, void *);
void fdattach(struct device *, struct device *, void *);
+bool fdshutdown(device_t, int);
+bool fdsuspend(device_t PMF_FN_PROTO);
CFATTACH_DECL(fd, sizeof(struct fd_softc),
fdmatch, fdattach, NULL, NULL);
@@ -791,9 +791,25 @@
mountroothook_establish(fd_mountroot_hook, &fd->sc_dv);
/* Make sure the drive motor gets turned off at shutdown time. */
- fd->sc_sdhook = shutdownhook_establish(fd_motor_off, fd);
+ if (!pmf_device_register1(self, fdsuspend, NULL, fdshutdown))
+ aprint_error_dev(self, "couldn't establish power handler\n");
+}
+
+bool fdshutdown(device_t self, int how)
+{
+ struct fd_softc *fd = device_private(self);
+
+ fd_motor_off(fd);
+ return true;
}
+bool fdsuspend(device_t self PMF_FN_ARGS)
+{
+
+ return fdshutdown(self, boothowto);
+}
+
+
inline struct fd_type *
fd_dev_to_type(struct fd_softc *fd, dev_t dev)
{