Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/hpc Replace powerhook_establish(9) with pmf(9).



details:   https://anonhg.NetBSD.org/src/rev/d5dc5db42c7b
branches:  trunk
changeset: 756769:d5dc5db42c7b
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sun Aug 01 02:47:43 2010 +0000

description:
Replace powerhook_establish(9) with pmf(9).

diffstat:

 sys/dev/hpc/bivideo.c |  31 ++++++++++++++++++++++++-------
 1 files changed, 24 insertions(+), 7 deletions(-)

diffs (73 lines):

diff -r 123044314ee7 -r d5dc5db42c7b sys/dev/hpc/bivideo.c
--- a/sys/dev/hpc/bivideo.c     Sun Aug 01 02:43:12 2010 +0000
+++ b/sys/dev/hpc/bivideo.c     Sun Aug 01 02:47:43 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bivideo.c,v 1.30 2009/05/12 14:22:39 cegger Exp $      */
+/*     $NetBSD: bivideo.c,v 1.31 2010/08/01 02:47:43 tsutsui Exp $     */
 
 /*-
  * Copyright (c) 1999-2001
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bivideo.c,v 1.30 2009/05/12 14:22:39 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bivideo.c,v 1.31 2010/08/01 02:47:43 tsutsui Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_hpcfb.h"
@@ -88,7 +88,6 @@
        struct device           sc_dev;
        struct hpcfb_fbconf     sc_fbconf;
        struct hpcfb_dspconf    sc_dspconf;
-       void                    *sc_powerhook;  /* power management hook */
        int                     sc_powerstate;
 #define PWRSTAT_SUSPEND                (1<<0)
 #define PWRSTAT_VIDEOOFF       (1<<1)
@@ -110,6 +109,8 @@
 static int bivideo_init(struct hpcfb_fbconf *);
 static void bivideo_power(int, void *);
 static void bivideo_update_powerstate(struct bivideo_softc *, int);
+static bool bivideo_suspend(device_t, const pmf_qual_t *);
+static bool bivideo_resume(device_t, const pmf_qual_t *);
 void   bivideo_init_backlight(struct bivideo_softc *, int);
 void   bivideo_init_brightness(struct bivideo_softc *, int);
 void   bivideo_init_contrast(struct bivideo_softc *, int);
@@ -178,10 +179,8 @@
 
        /* Add a suspend hook to power saving */
        sc->sc_powerstate = 0;
-       sc->sc_powerhook = powerhook_establish(device_xname(&sc->sc_dev),
-           bivideo_power, sc);
-       if (sc->sc_powerhook == NULL)
-               aprint_error_dev(&sc->sc_dev, "WARNING: unable to establish power hook\n");
+       if (!pmf_device_register(self, bivideo_suspend, bivideo_resume))
+               aprint_error_dev(self, "unable to establish power handler\n");
 
        /* initialize backlight brightness and lcd contrast */
        sc->sc_lcd_inited = 0;
@@ -372,6 +371,24 @@
                             (sc->sc_powerstate & PWRSTAT_BACKLIGHT)));
 }
 
+static bool
+bivideo_suspend(device_t self, const pmf_qual_t *qual)
+{
+       struct bivideo_softc *sc = device_private(self);
+
+       bivideo_power(PWR_SUSPEND, sc);
+       return true;
+}
+
+static bool
+bivideo_resume(device_t self, const pmf_qual_t *qual)
+{
+       struct bivideo_softc *sc = device_private(self);
+
+       bivideo_power(PWR_RESUME, sc);
+       return true;
+}
+
 int
 bivideo_ioctl(void *v, u_long cmd, void *data, int flag, struct lwp *l)
 {



Home | Main Index | Thread Index | Old Index