Author: marius
Date: Sun Jan 27 22:59:59 2013
New Revision: 246005
URL: http://svnweb.freebsd.org/changeset/base/246005

Log:
  MFC: r244990
  
  - Fix !SMP build.
  - Replace incorrect function names in printf(9) strings with __func__.
  - Make xctrl_shutdown_reasons table const.
  - Use nitems() rather than rolling an own version.
  - Use DEVMETHOD_END.
  - Use NULL rather than 0 for pointers.

Modified:
  stable/9/sys/dev/xen/control/control.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/xen/control/control.c
==============================================================================
--- stable/9/sys/dev/xen/control/control.c      Sun Jan 27 22:50:39 2013        
(r246004)
+++ stable/9/sys/dev/xen/control/control.c      Sun Jan 27 22:59:59 2013        
(r246005)
@@ -125,7 +125,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/smp.h>
 #endif
 
-
 #include <geom/geom.h>
 
 #include <machine/_inttypes.h>
@@ -145,8 +144,6 @@ __FBSDID("$FreeBSD$");
 
 #include <xen/xenbus/xenbusvar.h>
 
-#define NUM_ELEMENTS(x) (sizeof(x) / sizeof(*(x)))
-
 /*--------------------------- Forward Declarations --------------------------*/
 /** Function signature for shutdown event handlers. */
 typedef        void (xctrl_shutdown_handler_t)(void);
@@ -165,7 +162,7 @@ struct xctrl_shutdown_reason {
 };
 
 /** Lookup table for shutdown event name to handler. */
-static struct xctrl_shutdown_reason xctrl_shutdown_reasons[] = {
+static const struct xctrl_shutdown_reason xctrl_shutdown_reasons[] = {
        { "poweroff", xctrl_poweroff },
        { "reboot",   xctrl_reboot   },
        { "suspend",  xctrl_suspend  },
@@ -198,7 +195,6 @@ extern void xencons_resume(void);
 static void
 xctrl_suspend()
 {
-       u_int cpuid;
        int i, j, k, fpp;
        unsigned long max_pfn, start_info_mfn;
 
@@ -207,6 +203,8 @@ xctrl_suspend()
 #ifdef SMP
        struct thread *td;
        cpuset_t map;
+       u_int cpuid;
+
        /*
         * Bind us to CPU 0 and stop any other VCPUs.
         */
@@ -231,7 +229,7 @@ xctrl_suspend()
        mtx_lock(&Giant);
        if (DEVICE_SUSPEND(root_bus) != 0) {
                mtx_unlock(&Giant);
-               printf("xen_suspend: device_suspend failed\n");
+               printf("%s: device_suspend failed\n", __func__);
 #ifdef SMP
                if (!CPU_EMPTY(&map))
                        restart_cpus(map);
@@ -343,9 +341,9 @@ xctrl_suspend()
         * drivers need this.
         */
        mtx_lock(&Giant);
-       if (DEVICE_SUSPEND(root_bus)) {
+       if (DEVICE_SUSPEND(root_bus) != 0) {
                mtx_unlock(&Giant);
-               printf("xen_suspend: device_suspend failed\n");
+               printf("%s: device_suspend failed\n", __func__);
                return;
        }
        mtx_unlock(&Giant);
@@ -396,8 +394,8 @@ xctrl_halt()
 static void
 xctrl_on_watch_event(struct xs_watch *watch, const char **vec, unsigned int 
len)
 {
-       struct xctrl_shutdown_reason *reason;
-       struct xctrl_shutdown_reason *last_reason;
+       const struct xctrl_shutdown_reason *reason;
+       const struct xctrl_shutdown_reason *last_reason;
        char *result;
        int   error;
        int   result_len;
@@ -408,7 +406,7 @@ xctrl_on_watch_event(struct xs_watch *wa
                return;
 
        reason = xctrl_shutdown_reasons;
-       last_reason = reason + NUM_ELEMENTS(xctrl_shutdown_reasons);
+       last_reason = reason + nitems(xctrl_shutdown_reasons);
        while (reason < last_reason) {
 
                if (!strcmp(result, reason->name)) {
@@ -511,10 +509,10 @@ static device_method_t xctrl_methods[] =
        DEVMETHOD(device_attach,        xctrl_attach), 
        DEVMETHOD(device_detach,        xctrl_detach), 
  
-       { 0, 0 } 
+       DEVMETHOD_END
 }; 
 
 DEFINE_CLASS_0(xctrl, xctrl_driver, xctrl_methods, sizeof(struct xctrl_softc));
 devclass_t xctrl_devclass; 
  
-DRIVER_MODULE(xctrl, xenstore, xctrl_driver, xctrl_devclass, 0, 0);
+DRIVER_MODULE(xctrl, xenstore, xctrl_driver, xctrl_devclass, NULL, NULL);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to