diff -Nur /usr/ports/x11/nvidia-driver/Makefile nvidia-driver/Makefile
--- /usr/ports/x11/nvidia-driver/Makefile	Mon Jun 21 15:16:04 2004
+++ nvidia-driver/Makefile	Wed Jul  7 07:21:44 2004
@@ -26,10 +26,6 @@
 
 .include <bsd.port.pre.mk>
 
-.if ${OSVERSION} >= 502117
-BROKEN=		"Does not compile on FreeBSD >= 5.x"
-.endif
-
 # XXX Should use ${PKG_INFO} XXX
 #
 XSERVVERSION!=	/usr/sbin/pkg_info -O x11-servers/XFree86-4-Server 2>/dev/null | ${GREP} Server- || true
diff -Nur /usr/ports/x11/nvidia-driver/files/patch-src::nv-freebsd.h nvidia-driver/files/patch-src::nv-freebsd.h
--- /usr/ports/x11/nvidia-driver/files/patch-src::nv-freebsd.h	Wed Feb 25 23:35:12 2004
+++ nvidia-driver/files/patch-src::nv-freebsd.h	Wed Jul  7 07:56:41 2004
@@ -1,6 +1,18 @@
---- src/nv-freebsd.h.orig	Wed Feb 25 18:55:35 2004
-+++ src/nv-freebsd.h	Wed Feb 25 18:55:49 2004
-@@ -217,7 +217,9 @@
+--- src/nv-freebsd.h.orig	Thu May 29 02:21:53 2003
++++ src/nv-freebsd.h	Wed Jul  7 07:56:17 2004
+@@ -196,7 +196,11 @@
+     void *irq_ih;
+     int   irq_rid;
+ 
++#if __FreeBSD_version >= 502117
++    struct cdev *cdev;
++#else
+     dev_t cdev;
++#endif
+     nv_state_t *nv_state;
+ 
+     struct sysctl_ctx_list sysctl_ctx;
+@@ -217,7 +221,9 @@
  } nvidia_softc_t;
  
  
@@ -10,3 +22,30 @@
  #define CDEV_CTL_MINOR  255
  
  extern devclass_t nvidia_devclass;
+@@ -310,14 +316,26 @@
+ int    nvidia_set_primary     (struct nv_ioctl_primary_card *);
+ int    nvidia_get_card_info   (struct nv_ioctl_card_info *);
+ int    nvidia_get_api_version (struct nv_ioctl_rm_api_version *);
++#if __FreeBSD_version >= 502117
++int    nvidia_handle_ioctl    (struct cdev *, u_long, caddr_t, int, d_thread_t *);
++#else
+ int    nvidia_handle_ioctl    (dev_t, u_long, caddr_t, int, d_thread_t *);
++#endif
+ 
+ 
+ /* device helpers */
+ int    nvidia_open_ctl       (void);
+ int    nvidia_open_dev       (struct nvidia_softc *);
++#if __FreeBSD_version >= 502117
++int    nvidia_close_ctl      (struct cdev *, d_thread_t *);
++#else
+ int    nvidia_close_ctl      (dev_t, d_thread_t *);
++#endif
++#if __FreeBSD_version >= 502117
++int    nvidia_close_dev      (struct nvidia_softc *, struct cdev *, d_thread_t *);
++#else
+ int    nvidia_close_dev      (struct nvidia_softc *, dev_t, d_thread_t *);
++#endif
+ int    nvidia_mmap_dev       (struct nvidia_softc *, vm_offset_t, vm_offset_t *);
+ 
+ #endif /* __NV_FREEBSD_H__ */
diff -Nur /usr/ports/x11/nvidia-driver/files/patch-src::nvidia_ctl.c nvidia-driver/files/patch-src::nvidia_ctl.c
--- /usr/ports/x11/nvidia-driver/files/patch-src::nvidia_ctl.c	Mon Mar  8 11:43:26 2004
+++ nvidia-driver/files/patch-src::nvidia_ctl.c	Wed Jul  7 07:37:33 2004
@@ -1,6 +1,6 @@
---- src/nvidia_ctl.c.old	Sun Feb 22 13:05:46 2004
-+++ src/nvidia_ctl.c	Sun Feb 22 13:07:25 2004
-@@ -43,7 +43,12 @@
+--- src/nvidia_ctl.c.orig	Thu May 29 02:21:52 2003
++++ src/nvidia_ctl.c	Wed Jul  7 07:34:51 2004
+@@ -43,17 +43,30 @@
      .d_ioctl =     nvidia_ctl_ioctl,
      .d_poll =      nvidia_ctl_poll,
      .d_name =      "nvidiactl",
@@ -13,3 +13,57 @@
 +#endif 
  #endif
  };
+ 
++#if __FreeBSD_version >= 502117
++static struct cdev    *nvidia_ctl_cdev;
++#else
+ static dev_t          nvidia_ctl_cdev;
++#endif
+ static nvidia_softc_t nvidia_ctl_sc;
+ static int            nvidia_count = 0;
+ 
+ int nvidia_ctl_open(
++#if __FreeBSD_version >= 502117
++    struct cdev *dev,
++#else
+     dev_t dev,
++#endif
+     int oflags,
+     int devtype,
+     d_thread_t *td
+@@ -70,7 +83,11 @@
+ }
+ 
+ int nvidia_ctl_close(
++#if __FreeBSD_version >= 502117
++    struct cdev *dev,
++#else
+     dev_t dev,
++#endif
+     int fflag,
+     int devtype,
+     d_thread_t *td
+@@ -87,7 +104,11 @@
+ }
+ 
+ int nvidia_ctl_ioctl(
++#if __FreeBSD_version >= 502117
++    struct cdev *dev,
++#else
+     dev_t dev,
++#endif
+     u_long cmd,
+     caddr_t data,
+     int fflag,
+@@ -161,7 +182,11 @@
+ }
+ 
+ int nvidia_ctl_poll(
++#if __FreeBSD_version >= 502117
++    struct cdev *dev,
++#else
+     dev_t dev,
++#endif
+     int events,
+     d_thread_t *td
+ )
diff -Nur /usr/ports/x11/nvidia-driver/files/patch-src::nvidia_dev.c nvidia-driver/files/patch-src::nvidia_dev.c
--- /usr/ports/x11/nvidia-driver/files/patch-src::nvidia_dev.c	Wed Feb 25 23:35:12 2004
+++ nvidia-driver/files/patch-src::nvidia_dev.c	Wed Jul  7 07:37:42 2004
@@ -1,6 +1,6 @@
---- src/nvidia_dev.c.old	Wed May 28 12:51:52 2003
-+++ src/nvidia_dev.c	Sun Feb 22 13:36:25 2004
-@@ -45,7 +45,12 @@
+--- src/nvidia_dev.c.orig	Thu May 29 02:21:52 2003
++++ src/nvidia_dev.c	Wed Jul  7 07:37:20 2004
+@@ -45,13 +45,22 @@
      .d_poll =      nvidia_dev_poll,
      .d_mmap =      nvidia_dev_mmap,
      .d_name =      "nvidia",
@@ -13,3 +13,61 @@
 +#endif
  #endif
  };
+ 
+ int nvidia_dev_open(
++#if __FreeBSD_version >= 502117
++    struct cdev *dev,
++#else
+     dev_t dev,
++#endif
+     int oflags,
+     int devtype,
+     d_thread_t *td
+@@ -83,7 +92,11 @@
+ }
+ 
+ int nvidia_dev_close(
++#if __FreeBSD_version >= 502117
++    struct cdev *dev,
++#else
+     dev_t dev,
++#endif
+     int fflag,
+     int devtype,
+     d_thread_t *td
+@@ -106,7 +119,11 @@
+ }
+ 
+ int nvidia_dev_ioctl(
++#if __FreeBSD_version >= 502117
++    struct cdev *dev,
++#else
+     dev_t dev,
++#endif
+     u_long cmd,
+     caddr_t data,
+     int fflag,
+@@ -130,7 +147,11 @@
+ }
+ 
+ int nvidia_dev_poll(
++#if __FreeBSD_version >= 502117
++    struct cdev *dev,
++#else
+     dev_t dev,
++#endif
+     int events,
+     d_thread_t *td
+ )
+@@ -144,7 +165,11 @@
+ }
+ 
+ int nvidia_dev_mmap(
++#if __FreeBSD_version >= 502117
++    struct cdev *dev,
++#else
+     dev_t dev,
++#endif
+     vm_offset_t offset,
+ #if __FreeBSD_version >= 500102
+     vm_offset_t *address,
diff -Nur /usr/ports/x11/nvidia-driver/files/patch-src::nvidia_subr.c nvidia-driver/files/patch-src::nvidia_subr.c
--- /usr/ports/x11/nvidia-driver/files/patch-src::nvidia_subr.c	Thu Jan  1 09:30:00 1970
+++ nvidia-driver/files/patch-src::nvidia_subr.c	Wed Jul  7 07:52:06 2004
@@ -0,0 +1,38 @@
+--- src/nvidia_subr.c.orig	Thu May 29 02:21:52 2003
++++ src/nvidia_subr.c	Wed Jul  7 07:50:11 2004
+@@ -293,7 +293,11 @@
+ #define __IOC_NR(cmd) ((cmd) & 0xff)
+ 
+ int nvidia_handle_ioctl(
++#if __FreeBSD_version >= 502117
++    struct cdev *dev,
++#else
+     dev_t dev,
++#endif
+     u_long cmd,
+     caddr_t data,
+     int fflag,
+@@ -337,7 +341,11 @@
+ }
+ 
+ int nvidia_close_ctl(
++#if __FreeBSD_version >= 502117
++    struct cdev *dev,
++#else
+     dev_t dev,
++#endif
+     d_thread_t *td
+ )
+ {
+@@ -390,7 +398,11 @@
+ 
+ int nvidia_close_dev(
+     struct nvidia_softc *sc,
++#if __FreeBSD_version >= 502117
++    struct cdev *dev,
++#else
+     dev_t dev,
++#endif
+     d_thread_t *td
+ )
+ {
