Module Name:    src
Committed By:   uebayasi
Date:           Sat Aug 28 16:27:02 UTC 2010

Modified Files:
        src/sys/dev [uebayasi-xip]: xmd.c

Log Message:
Hook cdev read.  Kill unused code.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/dev/xmd.c

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

Modified files:

Index: src/sys/dev/xmd.c
diff -u src/sys/dev/xmd.c:1.1.2.3 src/sys/dev/xmd.c:1.1.2.4
--- src/sys/dev/xmd.c:1.1.2.3	Fri Aug 20 07:03:40 2010
+++ src/sys/dev/xmd.c	Sat Aug 28 16:27:02 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: xmd.c,v 1.1.2.3 2010/08/20 07:03:40 uebayasi Exp $	*/
+/*	$NetBSD: xmd.c,v 1.1.2.4 2010/08/28 16:27:02 uebayasi Exp $	*/
 
 /*-
  * Copyright (c) 2010 Tsubai Masanari.  All rights reserved.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xmd.c,v 1.1.2.3 2010/08/20 07:03:40 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xmd.c,v 1.1.2.4 2010/08/28 16:27:02 uebayasi Exp $");
 
 #include "opt_xip.h"
 #include "opt_xmd.h"
@@ -71,6 +71,7 @@
 static dev_type_open(xmd_open);
 static dev_type_close(xmd_close);
 static dev_type_ioctl(xmd_ioctl);
+static dev_type_read(xmd_read);
 static dev_type_mmap(xmd_mmap);
 static dev_type_strategy(xmd_strategy);
 static dev_type_size(xmd_size);
@@ -81,7 +82,7 @@
 };
 
 struct cdevsw xmd_cdevsw = {
-	nullopen, nullclose, nullread, nowrite, xmd_ioctl,
+	xmd_open, xmd_close, xmd_read, nowrite, xmd_ioctl,
 	nostop, notty, nopoll, xmd_mmap, nokqfilter, D_DISK | D_MPSAFE
 };
 
@@ -89,8 +90,6 @@
 CFATTACH_DECL3_NEW(xmd, sizeof(struct xmd_softc),
     NULL, xmd_attach, xmd_detach, NULL, NULL, NULL, DVF_DETACH_SHUTDOWN);
 
-static struct dkdriver xmddkdriver = { xmd_strategy, NULL };
-
 const char md_root_image[XMD_ROOT_SIZE << DEV_BSHIFT] __aligned(PAGE_SIZE) =
     "|This is the root ramdisk!\n";
 const size_t md_root_size = XMD_ROOT_SIZE << DEV_BSHIFT;
@@ -132,9 +131,7 @@
 	sc->sc_phys = xmd_machdep_physload(sc->sc_addr, sc->sc_size);
 #endif
 
-	bufq_alloc(&sc->sc_buflist, "fcfs", 0);
-
-	disk_init(&sc->sc_dkdev, device_xname(self), &xmddkdriver);
+	disk_init(&sc->sc_dkdev, device_xname(self), NULL);
 	disk_attach(&sc->sc_dkdev);
 
 	if (!pmf_device_register(self, NULL, NULL))
@@ -161,7 +158,11 @@
 	pmf_device_deregister(self);
 	disk_detach(&sc->sc_dkdev);
 	disk_destroy(&sc->sc_dkdev);
-	bufq_free(sc->sc_buflist);
+
+#ifdef XIP
+	xmd_machdep_physunload(sc->sc_phys);
+#endif
+
 	return 0;
 }
 
@@ -236,6 +237,19 @@
 	return error;
 }
 
+static int
+xmd_read(dev_t dev, struct uio *uio, int flags)
+{
+	struct xmd_softc *sc;
+
+	sc = device_lookup_private(&xmd_cd, DISKUNIT(dev));
+
+	if (sc == NULL)
+		return ENXIO;
+
+	return physio(xmd_strategy, NULL, dev, B_READ, minphys, uio);
+}
+
 paddr_t
 xmd_mmap(dev_t dev, off_t off, int prot)
 {

Reply via email to