Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/8732290b7773
branches:  gehenna-devsw
changeset: 527071:8732290b7773
user:      gehenna <gehenna%NetBSD.org@localhost>
date:      Thu May 16 11:40:53 2002 +0000

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

diffstat:

 sys/dev/scsipi/cd.c |  30 ++++++++++++++++++++++--------
 sys/dev/scsipi/sd.c |  30 ++++++++++++++++++++++--------
 sys/dev/scsipi/st.c |  29 +++++++++++++++++++++--------
 3 files changed, 65 insertions(+), 24 deletions(-)

diffs (173 lines):

diff -r e15d0a0b40d3 -r 8732290b7773 sys/dev/scsipi/cd.c
--- a/sys/dev/scsipi/cd.c       Thu May 16 11:38:52 2002 +0000
+++ b/sys/dev/scsipi/cd.c       Thu May 16 11:40:53 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd.c,v 1.162 2002/05/05 15:16:31 bouyer Exp $  */
+/*     $NetBSD: cd.c,v 1.162.2.1 2002/05/16 11:40:53 gehenna Exp $     */
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.162 2002/05/05 15:16:31 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.162.2.1 2002/05/16 11:40:53 gehenna Exp $");
 
 #include "rnd.h"
 
@@ -139,6 +139,24 @@
 
 extern struct cfdriver cd_cd;
 
+dev_type_open(cdopen);
+dev_type_close(cdclose);
+dev_type_read(cdread);
+dev_type_write(cdwrite);
+dev_type_ioctl(cdioctl);
+dev_type_strategy(cdstrategy);
+dev_type_dump(cddump);
+dev_type_size(cdsize);
+
+const struct bdevsw cd_bdevsw = {
+       cdopen, cdclose, cdstrategy, cdioctl, cddump, cdsize, D_DISK
+};
+
+const struct cdevsw cd_cdevsw = {
+       cdopen, cdclose, cdread, cdwrite, cdioctl,
+       nostop, notty, nopoll, nommap, D_DISK
+};
+
 struct dkdriver cddkdriver = { cdstrategy };
 
 const struct scsipi_periphsw cd_switch = {
@@ -231,12 +249,8 @@
        int s, bmaj, cmaj, i, mn;
 
        /* locate the major number */
-       for (bmaj = 0; bmaj <= nblkdev; bmaj++)
-               if (bdevsw[bmaj].d_open == cdopen)
-                       break;
-       for (cmaj = 0; cmaj <= nchrdev; cmaj++)
-               if (cdevsw[cmaj].d_open == cdopen)
-                       break;
+       bmaj = bdevsw_lookup_major(&cd_bdevsw);
+       cmaj = cdevsw_lookup_major(&cd_cdevsw);
 
        s = splbio();
 
diff -r e15d0a0b40d3 -r 8732290b7773 sys/dev/scsipi/sd.c
--- a/sys/dev/scsipi/sd.c       Thu May 16 11:38:52 2002 +0000
+++ b/sys/dev/scsipi/sd.c       Thu May 16 11:40:53 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sd.c,v 1.183 2002/05/15 13:01:27 bouyer Exp $  */
+/*     $NetBSD: sd.c,v 1.183.2.1 2002/05/16 11:40:54 gehenna Exp $     */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.183 2002/05/15 13:01:27 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.183.2.1 2002/05/16 11:40:54 gehenna Exp $");
 
 #include "opt_scsi.h"
 #include "rnd.h"
@@ -109,6 +109,24 @@
 
 extern struct cfdriver sd_cd;
 
+dev_type_open(sdopen);
+dev_type_close(sdclose);
+dev_type_read(sdread);
+dev_type_write(sdwrite);
+dev_type_ioctl(sdioctl);
+dev_type_strategy(sdstrategy);
+dev_type_dump(sddump);
+dev_type_size(sdsize);
+
+const struct bdevsw sd_bdevsw = {
+       sdopen, sdclose, sdstrategy, sdioctl, sddump, sdsize, D_DISK
+};
+
+const struct cdevsw sd_cdevsw = {
+       sdopen, sdclose, sdread, sdwrite, sdioctl,
+       nostop, notty, nopoll, nommap, D_DISK
+};
+
 struct dkdriver sddkdriver = { sdstrategy };
 
 const struct scsipi_periphsw sd_switch = {
@@ -259,12 +277,8 @@
        int s, bmaj, cmaj, i, mn;
 
        /* locate the major number */
-       for (bmaj = 0; bmaj <= nblkdev; bmaj++)
-               if (bdevsw[bmaj].d_open == sdopen)
-                       break;
-       for (cmaj = 0; cmaj <= nchrdev; cmaj++)
-               if (cdevsw[cmaj].d_open == sdopen)
-                       break;
+       bmaj = bdevsw_lookup_major(&sd_bdevsw);
+       cmaj = cdevsw_lookup_major(&sd_cdevsw);
 
        s = splbio();
 
diff -r e15d0a0b40d3 -r 8732290b7773 sys/dev/scsipi/st.c
--- a/sys/dev/scsipi/st.c       Thu May 16 11:38:52 2002 +0000
+++ b/sys/dev/scsipi/st.c       Thu May 16 11:40:53 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: st.c,v 1.155 2002/05/05 15:16:31 bouyer Exp $ */
+/*     $NetBSD: st.c,v 1.155.2.1 2002/05/16 11:40:54 gehenna Exp $ */
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -56,7 +56,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: st.c,v 1.155 2002/05/05 15:16:31 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: st.c,v 1.155.2.1 2002/05/16 11:40:54 gehenna Exp $");
 
 #include "opt_scsi.h"
 
@@ -99,6 +99,23 @@
 #define                ST_MOUNT_DELAY          0
 #endif
 
+dev_type_open(stopen);
+dev_type_close(stclose);
+dev_type_read(stread);
+dev_type_write(stwrite);
+dev_type_ioctl(stioctl);
+dev_type_strategy(ststrategy);
+dev_type_dump(stdump);
+
+const struct bdevsw st_bdevsw = {
+       stopen, stclose, ststrategy, stioctl, stdump, nosize, D_TAPE
+};
+
+const struct cdevsw st_cdevsw = {
+       stopen, stclose, stread, stwrite, stioctl,
+       nostop, notty, nopoll, nommap, D_TAPE
+};
+
 /*
  * Define various devices that we know mis-behave in some way,
  * and note how they are bad, so we can correct for them
@@ -417,12 +434,8 @@
        int s, bmaj, cmaj, mn;
 
        /* locate the major number */
-       for (bmaj = 0; bmaj <= nblkdev; bmaj++)
-               if (bdevsw[bmaj].d_open == stopen)
-                       break;
-       for (cmaj = 0; cmaj <= nchrdev; cmaj++)
-               if (cdevsw[cmaj].d_open == stopen)
-                       break;
+       bmaj = bdevsw_lookup_major(&st_bdevsw);
+       cmaj = cdevsw_lookup_major(&st_cdevsw);
 
        s = splbio();
 



Home | Main Index | Thread Index | Old Index