Module Name:    src
Committed By:   riastradh
Date:           Mon Aug 27 06:54:08 UTC 2018

Modified Files:
        src/sys/external/bsd/drm2/dist/drm: drm_drv.c
        src/sys/external/bsd/drm2/dist/include/drm: drmP.h

Log Message:
Massage drm_drv.c into usability.

- expose drm_minor_lock/drm_minors_idr for drm_init in drm_module.c
- ifdef out Linux driver attachment goo


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/drm2/dist/drm/drm_drv.c
cvs rdiff -u -r1.20 -r1.21 src/sys/external/bsd/drm2/dist/include/drm/drmP.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/dist/drm/drm_drv.c
diff -u src/sys/external/bsd/drm2/dist/drm/drm_drv.c:1.4 src/sys/external/bsd/drm2/dist/drm/drm_drv.c:1.5
--- src/sys/external/bsd/drm2/dist/drm/drm_drv.c:1.4	Mon Aug 27 06:53:46 2018
+++ src/sys/external/bsd/drm2/dist/drm/drm_drv.c	Mon Aug 27 06:54:08 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_drv.c,v 1.4 2018/08/27 06:53:46 riastradh Exp $	*/
+/*	$NetBSD: drm_drv.c,v 1.5 2018/08/27 06:54:08 riastradh Exp $	*/
 
 /*
  * Created: Fri Jan 19 10:48:35 2001 by [email protected]
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.4 2018/08/27 06:53:46 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.5 2018/08/27 06:54:08 riastradh Exp $");
 
 #include <linux/err.h>
 #include <linux/export.h>
@@ -59,11 +59,12 @@ MODULE_PARM_DESC(timestamp_monotonic, "U
 module_param_named(debug, drm_debug, int, 0600);
 
 #ifdef __NetBSD__
-static spinlock_t drm_minor_lock;
+spinlock_t drm_minor_lock;
+struct idr drm_minors_idr;
 #else
 static DEFINE_SPINLOCK(drm_minor_lock);
-#endif
 static struct idr drm_minors_idr;
+#endif
 
 #ifndef __NetBSD__
 static struct dentry *drm_debugfs_root;
@@ -329,7 +330,9 @@ static void drm_minor_free(struct drm_de
 	if (!minor)
 		return;
 
+#ifndef __NetBSD__
 	put_device(minor->kdev);
+#endif
 
 	spin_lock_irqsave(&drm_minor_lock, flags);
 	idr_remove(&drm_minors_idr, minor->index);
@@ -386,7 +389,11 @@ static void drm_minor_unregister(struct 
 	unsigned long flags;
 
 	minor = *drm_minor_get_slot(dev, type);
+#ifdef __NetBSD__
+	if (!minor)
+#else
 	if (!minor || !device_is_registered(minor->kdev))
+#endif
 		return;
 
 	/* replace @minor with NULL so lookups will fail from now on */
@@ -394,9 +401,11 @@ static void drm_minor_unregister(struct 
 	idr_replace(&drm_minors_idr, NULL, minor->index);
 	spin_unlock_irqrestore(&drm_minor_lock, flags);
 
+#ifndef __NetBSD__
 	device_del(minor->kdev);
 	dev_set_drvdata(minor->kdev, NULL); /* safety belt */
 	drm_debugfs_cleanup(minor);
+#endif
 }
 
 /**
@@ -913,6 +922,8 @@ int drm_dev_set_unique(struct drm_device
 }
 EXPORT_SYMBOL(drm_dev_set_unique);
 
+#ifndef __NetBSD__
+
 /*
  * DRM Core
  * The DRM core module initializes all global DRM objects and makes them
@@ -1023,3 +1034,5 @@ static void __exit drm_core_exit(void)
 
 module_init(drm_core_init);
 module_exit(drm_core_exit);
+
+#endif

Index: src/sys/external/bsd/drm2/dist/include/drm/drmP.h
diff -u src/sys/external/bsd/drm2/dist/include/drm/drmP.h:1.20 src/sys/external/bsd/drm2/dist/include/drm/drmP.h:1.21
--- src/sys/external/bsd/drm2/dist/include/drm/drmP.h:1.20	Mon Aug 27 06:50:58 2018
+++ src/sys/external/bsd/drm2/dist/include/drm/drmP.h	Mon Aug 27 06:54:08 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: drmP.h,v 1.20 2018/08/27 06:50:58 riastradh Exp $	*/
+/*	$NetBSD: drmP.h,v 1.21 2018/08/27 06:54:08 riastradh Exp $	*/
 
 /*
  * Internal Header for the Direct Rendering Manager
@@ -986,6 +986,8 @@ static inline bool drm_is_primary_client
 extern int drm_ioctl_permit(u32 flags, struct drm_file *file_priv);
 #ifdef __NetBSD__
 extern int drm_ioctl(struct file *, unsigned long, void *);
+extern struct spinlock drm_minor_lock;
+extern struct idr drm_minors_idr;
 #else
 extern long drm_ioctl(struct file *filp,
 		      unsigned int cmd, unsigned long arg);

Reply via email to