Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/gehenna-devsw]: src/sys/dev Add the block/character device switches.



details:   https://anonhg.NetBSD.org/src/rev/e4819d1f2847
branches:  gehenna-devsw
changeset: 527060:e4819d1f2847
user:      gehenna <gehenna%NetBSD.org@localhost>
date:      Thu May 16 04:53:05 2002 +0000

description:
Add the block/character device switches.
Replace the direct-access to devsw table with calling devsw API.

diffstat:

 sys/dev/ld.c |  30 ++++++++++++++++++++++--------
 1 files changed, 22 insertions(+), 8 deletions(-)

diffs (58 lines):

diff -r 1832f2162dd2 -r e4819d1f2847 sys/dev/ld.c
--- a/sys/dev/ld.c      Thu May 16 04:52:05 2002 +0000
+++ b/sys/dev/ld.c      Thu May 16 04:53:05 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ld.c,v 1.13 2002/05/08 15:49:07 drochner Exp $ */
+/*     $NetBSD: ld.c,v 1.13.2.1 2002/05/16 04:53:05 gehenna Exp $      */
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.13 2002/05/08 15:49:07 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.13.2.1 2002/05/16 04:53:05 gehenna Exp $");
 
 #include "rnd.h"
 
@@ -78,6 +78,24 @@
 
 extern struct  cfdriver ld_cd;
 
+dev_type_open(ldopen);
+dev_type_close(ldclose);
+dev_type_read(ldread);
+dev_type_write(ldwrite);
+dev_type_ioctl(ldioctl);
+dev_type_strategy(ldstrategy);
+dev_type_dump(lddump);
+dev_type_size(ldsize);
+
+const struct bdevsw ld_bdevsw = {
+       ldopen, ldclose, ldstrategy, ldioctl, lddump, ldsize, D_DISK
+};
+
+const struct cdevsw ld_cdevsw = {
+       ldopen, ldclose, ldread, ldwrite, ldioctl,
+       nostop, notty, nopoll, nommap, D_DISK
+};
+
 static struct  dkdriver lddkdriver = { ldstrategy };
 static void    *ld_sdh;
 
@@ -185,12 +203,8 @@
                        printf("%s: not drained\n", sc->sc_dv.dv_xname);
 
        /* Locate the major numbers. */
-       for (bmaj = 0; bmaj <= nblkdev; bmaj++)
-               if (bdevsw[bmaj].d_open == ldopen)
-                       break;
-       for (cmaj = 0; cmaj <= nchrdev; cmaj++)
-               if (cdevsw[cmaj].d_open == ldopen)
-                       break;
+       bmaj = bdevsw_lookup_major(&ld_bdevsw);
+       cmaj = cdevsw_lookup_major(&ld_cdevsw);
 
        /* Kill off any queued buffers. */
        s = splbio();



Home | Main Index | Thread Index | Old Index