Author: glebius
Date: Thu Sep 27 10:30:11 2012
New Revision: 240990
URL: http://svn.freebsd.org/changeset/base/240990

Log:
  Fix several build failures for !COMPAT_FREEBSD32 and
  !COMPAT_FREEBSD* kernels introduced by r240981.
  
  Pointy hat to:        sobomax

Modified:
  head/sys/dev/pci/pci_user.c

Modified: head/sys/dev/pci/pci_user.c
==============================================================================
--- head/sys/dev/pci/pci_user.c Thu Sep 27 09:00:22 2012        (r240989)
+++ head/sys/dev/pci/pci_user.c Thu Sep 27 10:30:11 2012        (r240990)
@@ -266,7 +266,7 @@ struct pci_conf_io32 {
 };
 
 #define        PCIOCGETCONF_OLD32      _IOWR('p', 1, struct pci_conf_io32)
-#endif
+#endif /* COMPAT_FREEBSD32 */
 
 #define        PCIOCGETCONF_OLD        _IOWR('p', 1, struct pci_conf_io)
 #define        PCIOCREAD_OLD           _IOWR('p', 2, struct pci_io_old)
@@ -338,6 +338,7 @@ pci_conf_match_old(struct pci_match_conf
        return(1);
 }
 
+#ifdef COMPAT_FREEBSD32
 static int
 pci_conf_match_old32(struct pci_match_conf_old32 *matches, int num_matches,
     struct pci_conf *match_buf)
@@ -400,8 +401,8 @@ pci_conf_match_old32(struct pci_match_co
 
        return(1);
 }
-
-#endif
+#endif /* COMPAT_FREEBSD32 */
+#endif /* PRE7_COMPAT */
 
 static int
 pci_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread 
*td)
@@ -410,7 +411,7 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
        void *confdata;
        const char *name;
        struct devlist *devlist_head;
-       struct pci_conf_io *cio;
+       struct pci_conf_io *cio = NULL;
        struct pci_devinfo *dinfo;
        struct pci_io *io;
        struct pci_bar_io *bio;
@@ -420,20 +421,16 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
        int error, ionum, i, num_patterns;
 #ifdef PRE7_COMPAT
 #ifdef COMPAT_FREEBSD32
-       struct pci_conf_io32 *cio32;
+       struct pci_conf_io32 *cio32 = NULL;
+       struct pci_conf_old32 conf_old32;
+       struct pci_match_conf_old32 *pattern_buf_old32;
 #endif
        struct pci_conf_old conf_old;
-       struct pci_conf_old32 conf_old32;
        struct pci_io iodata;
        struct pci_io_old *io_old;
        struct pci_match_conf_old *pattern_buf_old;
-       struct pci_match_conf_old32 *pattern_buf_old32;
 
-       cio = NULL;
-       cio32 = NULL;
        io_old = NULL;
-       pattern_buf_old = NULL;
-       pattern_buf_old32 = NULL;
 
        if (!(flag & FWRITE) && cmd != PCIOCGETBAR &&
            cmd != PCIOCGETCONF && cmd != PCIOCGETCONF_OLD)
@@ -445,6 +442,7 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
 
        switch(cmd) {
 #ifdef PRE7_COMPAT
+#ifdef COMPAT_FREEBSD32
        case PCIOCGETCONF_OLD32:
                cio32 = (struct pci_conf_io32 *)data;
                cio = malloc(sizeof(struct pci_conf_io), M_TEMP, M_WAITOK);
@@ -458,14 +456,24 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
                cio->generation = cio32->generation;
                cio->status = cio32->status;
                cio32->num_matches = 0;
-               /* FALLTHROUGH */
+               break;
+#endif
+       case PCIOCGETCONF_OLD:
+#endif
+       case PCIOCGETCONF:
+               cio = (struct pci_conf_io *)data;
+       }
 
+       switch(cmd) {
+#ifdef PRE7_COMPAT
+#ifdef COMPAT_FREEBSD32
+       case PCIOCGETCONF_OLD32:
+               pattern_buf_old32 = NULL;
+#endif
        case PCIOCGETCONF_OLD:
-               /* FALLTHROUGH */
+               pattern_buf_old = NULL;
 #endif
        case PCIOCGETCONF:
-               if (cio == NULL)
-                       cio = (struct pci_conf_io *)data;
 
                pattern_buf = NULL;
                num_patterns = 0;
@@ -566,19 +574,21 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
                         * Allocate a buffer to hold the patterns.
                         */
 #ifdef PRE7_COMPAT
+#ifdef COMPAT_FREEBSD32
                        if (cmd == PCIOCGETCONF_OLD32) {
                                pattern_buf_old32 = malloc(cio->pat_buf_len,
                                    M_TEMP, M_WAITOK);
                                error = copyin(cio->patterns,
                                    pattern_buf_old32, cio->pat_buf_len);
                        } else
+#endif /* COMPAT_FREEBSD32 */
                        if (cmd == PCIOCGETCONF_OLD) {
                                pattern_buf_old = malloc(cio->pat_buf_len,
                                    M_TEMP, M_WAITOK);
                                error = copyin(cio->patterns,
                                    pattern_buf_old, cio->pat_buf_len);
                        } else
-#endif
+#endif /* PRE7_COMPAT */
                        {
                                pattern_buf = malloc(cio->pat_buf_len, M_TEMP,
                                    M_WAITOK);
@@ -629,11 +639,14 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
                        }
 
 #ifdef PRE7_COMPAT
-                       if ((cmd == PCIOCGETCONF_OLD32 &&
-                           (pattern_buf_old32 == NULL ||
-                           pci_conf_match_old32(pattern_buf_old32,
-                           num_patterns, &dinfo->conf) == 0)) ||
-                           (cmd == PCIOCGETCONF_OLD &&
+                       if (
+#ifdef COMPAT_FREEBSD32
+                           (cmd == PCIOCGETCONF_OLD32 &&
+                           (pattern_buf_old32 == NULL ||
+                           pci_conf_match_old32(pattern_buf_old32,
+                           num_patterns, &dinfo->conf) == 0)) ||
+#endif
+                           (cmd == PCIOCGETCONF_OLD &&
                            (pattern_buf_old == NULL ||
                            pci_conf_match_old(pattern_buf_old, num_patterns,
                            &dinfo->conf) == 0)) ||
@@ -658,6 +671,7 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
                                        break;
 
 #ifdef PRE7_COMPAT
+#ifdef COMPAT_FREEBSD32
                                if (cmd == PCIOCGETCONF_OLD32) {
                                        conf_old32.pc_sel.pc_bus =
                                            dinfo->conf.pc_sel.pc_bus;
@@ -690,6 +704,7 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
                                            (u_int32_t)dinfo->conf.pd_unit;
                                        confdata = &conf_old32;
                                } else
+#endif /* COMPAT_FREEBSD32 */
                                if (cmd == PCIOCGETCONF_OLD) {
                                        conf_old.pc_sel.pc_bus =
                                            dinfo->conf.pc_sel.pc_bus;
@@ -722,7 +737,7 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
                                            dinfo->conf.pd_unit;
                                        confdata = &conf_old;
                                } else
-#endif
+#endif /* PRE7_COMPAT */
                                        confdata = &dinfo->conf;
                                /* Only if we can copy it out do we count it. */
                                if (!(error = copyout(confdata,
@@ -756,25 +771,23 @@ pci_ioctl(struct cdev *dev, u_long cmd, 
                        cio->status = PCI_GETCONF_MORE_DEVS;
 
 getconfexit:
+#ifdef PRE7_COMPAT
 #ifdef COMPAT_FREEBSD32
                if (cmd == PCIOCGETCONF_OLD32) {
                        cio32->status = cio->status;
                        cio32->generation = cio->generation;
                        cio32->offset = cio->offset;
                        cio32->num_matches = cio->num_matches;
-                       if (cio != NULL)
-                               free(cio, M_TEMP);
-               }
+                       free(cio, M_TEMP);
+               }
+               if (pattern_buf_old32 != NULL)
+                       free(pattern_buf_old32, M_TEMP);
 #endif
-
-               if (pattern_buf != NULL)
-                       free(pattern_buf, M_TEMP);
-#ifdef PRE7_COMPAT
-               if (pattern_buf_old32 != NULL)
-                       free(pattern_buf_old32, M_TEMP);
                if (pattern_buf_old != NULL)
                        free(pattern_buf_old, M_TEMP);
 #endif
+               if (pattern_buf != NULL)
+                       free(pattern_buf, M_TEMP);
 
                break;
 
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to