Module Name:    src
Committed By:   uwe
Date:           Sun Apr  5 02:14:41 UTC 2009

Modified Files:
        src/sys/dev/hpc: hpcfb.c

Log Message:
Register with pmf(9).  Thus we register with both dopowerhooks(9) and
pmf(9), but they are mutually exclusive (apm(4) vs apmdev(4)).

Express pmf(9) hooks in terms of dopowerhooks(9) hook - the reverse
would be more natural, but pmf hook signature is hidden behind
PMF_FN_ARGS/PMF_FN_CALL, so just go the least intrusive way for now.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/dev/hpc/hpcfb.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/dev/hpc/hpcfb.c
diff -u src/sys/dev/hpc/hpcfb.c:1.49 src/sys/dev/hpc/hpcfb.c:1.50
--- src/sys/dev/hpc/hpcfb.c:1.49	Sun Apr  5 01:48:47 2009
+++ src/sys/dev/hpc/hpcfb.c	Sun Apr  5 02:14:41 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: hpcfb.c,v 1.49 2009/04/05 01:48:47 uwe Exp $	*/
+/*	$NetBSD: hpcfb.c,v 1.50 2009/04/05 02:14:41 uwe Exp $	*/
 
 /*-
  * Copyright (c) 1999
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hpcfb.c,v 1.49 2009/04/05 01:48:47 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hpcfb.c,v 1.50 2009/04/05 02:14:41 uwe Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_hpcfb.h"
@@ -195,10 +195,14 @@
 static int	hpcfb_show_screen(void *, void *, int,
 		    void (*) (void *, int, int), void *);
 static void     hpcfb_pollc(void *, int);
-static void	hpcfb_power(int, void *);
 static void	hpcfb_cmap_reorder(struct hpcfb_fbconf *,
 		    struct hpcfb_devconfig *);
 
+static void	hpcfb_power(int, void *);
+static bool	hpcfb_suspend(device_t PMF_FN_PROTO);
+static bool	hpcfb_resume(device_t PMF_FN_PROTO);
+
+
 void    hpcfb_cursor(void *, int, int, int);
 int     hpcfb_mapchar(void *, int, unsigned int *);
 void    hpcfb_putchar(void *, int, int, u_int, long);
@@ -318,12 +322,6 @@
 	sc->sc_mapping = 0; /* XXX */
 	callout_init(&sc->sc_switch_callout, 0);
 
-	/* Add a power hook to power management */
-	sc->sc_powerhook = powerhook_establish(device_xname(sc->sc_dev),
-	    hpcfb_power, sc);
-	if (sc->sc_powerhook == NULL)
-		aprint_error_dev(sc->sc_dev, "WARNING: unable to establish power hook\n");
-
 	wa.console = hpcfbconsole;
 	wa.scrdata = &hpcfb_screenlist;
 	wa.accessops = &hpcfb_accessops;
@@ -345,6 +343,20 @@
 		    "hpcfb scroll support disabled\n");
 	}
 #endif /* HPCFB_JUMP */
+
+	/*
+	 * apmdev(4) uses dopowerhooks(9), apm(4) uses pmf(9), and the
+	 * two apm drivers are mutually exclusive.  Register power
+	 * hooks with both.
+	 */
+	sc->sc_powerhook = powerhook_establish(device_xname(sc->sc_dev),
+	    hpcfb_power, sc);
+	if (sc->sc_powerhook == NULL)
+		aprint_error_dev(self,
+				 "WARNING: unable to establish power hook\n");
+
+	if (!pmf_device_register(self, hpcfb_suspend, hpcfb_resume))
+		aprint_error_dev(self, "unable to establish power handler\n");
 }
 
 #ifdef HPCFB_JUMP
@@ -659,6 +671,24 @@
 	}
 }
 
+static bool
+hpcfb_suspend(device_t self PMF_FN_ARGS)
+{
+	struct hpcfb_softc *sc = device_private(self);
+
+	hpcfb_power(PWR_SOFTSUSPEND, sc);
+	return true;
+}
+
+static bool
+hpcfb_resume(device_t self PMF_FN_ARGS)
+{
+	struct hpcfb_softc *sc = device_private(self);
+
+	hpcfb_power(PWR_SOFTRESUME, sc);
+	return true;
+}
+
 void
 hpcfb_refresh_screen(struct hpcfb_softc *sc)
 {

Reply via email to