Module Name:    src
Committed By:   jmcneill
Date:           Fri Feb 18 02:00:36 UTC 2011

Modified Files:
        src/sys/external/bsd/drm/dist/bsd-core: via_drv.c
        src/sys/modules/viadrm: Makefile
Added Files:
        src/sys/modules/viadrm: viadrm.ioconf

Log Message:
get rid of #ifdef __FreeBSD__ sections
use ioconf & add a module dependency on "drm"


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/external/bsd/drm/dist/bsd-core/via_drv.c
cvs rdiff -u -r1.1 -r1.2 src/sys/modules/viadrm/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/modules/viadrm/viadrm.ioconf

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/drm/dist/bsd-core/via_drv.c
diff -u src/sys/external/bsd/drm/dist/bsd-core/via_drv.c:1.6 src/sys/external/bsd/drm/dist/bsd-core/via_drv.c:1.7
--- src/sys/external/bsd/drm/dist/bsd-core/via_drv.c:1.6	Sun Dec  6 22:51:25 2009
+++ src/sys/external/bsd/drm/dist/bsd-core/via_drv.c	Fri Feb 18 02:00:36 2011
@@ -39,12 +39,13 @@
 	viadrv_PCI_IDS
 };
 
-static void via_configure(struct drm_device *dev)
+static void
+via_configure(struct drm_device *dev)
 {
 	dev->driver->driver_features =
 	    DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_IRQ;
 
-	dev->driver->buf_priv_size	= 1;
+	dev->driver->buf_priv_size	= sizeof(drm_via_private_t);
 	dev->driver->load		= via_driver_load;
 	dev->driver->unload		= via_driver_unload;
 	dev->driver->context_ctor	= via_init_context;
@@ -69,60 +70,6 @@
 	dev->driver->patchlevel		= VIA_DRM_DRIVER_PATCHLEVEL;
 }
 
-#if defined(__FreeBSD__)
-static int
-via_probe(device_t kdev)
-{
-	return drm_probe(kdev, via_pciidlist);
-}
-
-static int
-via_attach(device_t kdev)
-{
-	struct drm_device *dev = device_get_softc(kdev);
-
-	dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER,
-	    M_WAITOK | M_ZERO);
-
-	via_configure(dev);
-
-	return drm_attach(kdev, via_pciidlist);
-}
-
-static int
-via_detach(device_t kdev)
-{
-	struct drm_device *dev = device_get_softc(kdev);
-	int ret;
-
-	ret = drm_detach(kdev);
-
-	free(dev->driver, DRM_MEM_DRIVER);
-
-	return ret;
-}
-
-static device_method_t via_methods[] = {
-	/* Device interface */
-	DEVMETHOD(device_probe,		via_probe),
-	DEVMETHOD(device_attach,	via_attach),
-	DEVMETHOD(device_detach,	via_detach),
-
-	{ 0, 0 }
-};
-
-static driver_t via_driver = {
-	"drm",
-	via_methods,
-	sizeof(struct drm_device)
-};
-
-extern devclass_t drm_devclass;
-DRIVER_MODULE(via, pci, via_driver, drm_devclass, 0, 0);
-MODULE_DEPEND(via, drm, 1, 1, 1);
-
-#elif defined(__NetBSD__)
-
 static int
 viadrm_probe(device_t parent, cfdata_t match, void *aux)
 {
@@ -158,62 +105,31 @@
 CFATTACH_DECL_NEW(viadrm, sizeof(struct drm_device),
     viadrm_probe, viadrm_attach, viadrm_detach, NULL);
 
-#ifdef _MODULE
-
-MODULE(MODULE_CLASS_DRIVER, viadrm, NULL);
+MODULE(MODULE_CLASS_DRIVER, viadrm, "drm");
 
-CFDRIVER_DECL(viadrm, DV_DULL, NULL);
-extern struct cfattach viadrm_ca;
-static int drmloc[] = { -1 };
-static struct cfparent drmparent = {
-	"drm", "vga", DVUNIT_ANY
-};
-static struct cfdata viadrm_cfdata[] = {
-	{
-		.cf_name = "viadrm",
-		.cf_atname = "viadrm",
-		.cf_unit = 0,
-		.cf_fstate = FSTATE_STAR,
-		.cf_loc = drmloc,
-		.cf_flags = 0,
-		.cf_pspec = &drmparent,
-	},
-	{ NULL }
-};
+#ifdef _MODULE
+#include "ioconf.c"
+#endif
 
 static int
 viadrm_modcmd(modcmd_t cmd, void *arg)
 {
-	int err;
+	int err = 0;
 
 	switch (cmd) {
 	case MODULE_CMD_INIT:
-		err = config_cfdriver_attach(&viadrm_cd);
-		if (err)
-			return err;
-		err = config_cfattach_attach("viadrm", &viadrm_ca);
-		if (err) {
-			config_cfdriver_detach(&viadrm_cd);
-			return err;
-		}
-		err = config_cfdata_attach(viadrm_cfdata, 1);
-		if (err) {
-			config_cfattach_detach("viadrm", &viadrm_ca);
-			config_cfdriver_detach(&viadrm_cd);
-			return err;
-		}
-		return 0;
+#ifdef _MODULE
+		err = config_init_component(cfdriver_ioconf_viadrm,
+		    cfattach_ioconf_viadrm, cfdata_ioconf_viadrm);
+#endif
+		return err;
 	case MODULE_CMD_FINI:
-		err = config_cfdata_detach(viadrm_cfdata);
-		if (err)
-			return err;
-		config_cfattach_detach("viadrm", &viadrm_ca);
-		config_cfdriver_detach(&viadrm_cd);
-		return 0;
+#ifdef _MODULE
+		err = config_fini_component(cfdriver_ioconf_viadrm,
+		    cfattach_ioconf_viadrm, cfdata_ioconf_viadrm);
+#endif
+		return err;
 	default:
 		return ENOTTY;
 	}
 }
-#endif /* _MODULE */
-
-#endif

Index: src/sys/modules/viadrm/Makefile
diff -u src/sys/modules/viadrm/Makefile:1.1 src/sys/modules/viadrm/Makefile:1.2
--- src/sys/modules/viadrm/Makefile:1.1	Sun Sep 27 12:44:05 2009
+++ src/sys/modules/viadrm/Makefile	Fri Feb 18 02:00:36 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1 2009/09/27 12:44:05 jmcneill Exp $
+# $NetBSD: Makefile,v 1.2 2011/02/18 02:00:36 jmcneill Exp $
 
 .include "../Makefile.inc"
 
@@ -6,6 +6,7 @@
 .PATH:	${S}/external/bsd/drm/dist/shared-core
 
 KMOD=   viadrm
+IOCONF=	viadrm.ioconf
 
 SRCS=	via_drv.c
 SRCS+=	via_dma.c

Added files:

Index: src/sys/modules/viadrm/viadrm.ioconf
diff -u /dev/null src/sys/modules/viadrm/viadrm.ioconf:1.1
--- /dev/null	Fri Feb 18 02:00:37 2011
+++ src/sys/modules/viadrm/viadrm.ioconf	Fri Feb 18 02:00:36 2011
@@ -0,0 +1,9 @@
+#	$NetBSD: viadrm.ioconf,v 1.1 2011/02/18 02:00:36 jmcneill Exp $
+
+ioconf viadrm
+
+include "conf/files"
+
+pseudo-root drm*
+
+viadrm* at drm?

Reply via email to