summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2003-05-14 00:20:39 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2003-05-14 00:20:39 +0000
commitcafc243ebae5558778638ed6f6c70c9c9bbd86f4 (patch)
tree8cbf420519d09c3da1122dfc01777d9d3a734649
parentb4dd55d103207347b453f69c731250bd549e6b5b (diff)
add {b,c}devsw_lookup convenience functions.
move chrtoblk and blktochr into MI code. tested on several archs and ok deraadt@
-rw-r--r--sys/arch/alpha/alpha/conf.c41
-rw-r--r--sys/arch/hp300/hp300/conf.c41
-rw-r--r--sys/arch/hppa/hppa/conf.c38
-rw-r--r--sys/arch/i386/i386/conf.c41
-rw-r--r--sys/arch/mac68k/mac68k/conf.c38
-rw-r--r--sys/arch/macppc/macppc/conf.c41
-rw-r--r--sys/arch/mvme68k/mvme68k/conf.c41
-rw-r--r--sys/arch/mvme88k/mvme88k/conf.c41
-rw-r--r--sys/arch/mvmeppc/mvmeppc/conf.c41
-rw-r--r--sys/arch/sparc/sparc/conf.c41
-rw-r--r--sys/arch/sparc64/sparc64/conf.c41
-rw-r--r--sys/arch/vax/vax/conf.c36
-rw-r--r--sys/arch/vax/vax/machdep.c3
-rw-r--r--sys/kern/subr_xxx.c51
-rw-r--r--sys/sys/conf.h6
15 files changed, 91 insertions, 450 deletions
diff --git a/sys/arch/alpha/alpha/conf.c b/sys/arch/alpha/alpha/conf.c
index c53bafae1d5..7e6059f31ba 100644
--- a/sys/arch/alpha/alpha/conf.c
+++ b/sys/arch/alpha/alpha/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.45 2002/12/05 02:49:55 kjc Exp $ */
+/* $OpenBSD: conf.c,v 1.46 2003/05/14 00:20:37 tedu Exp $ */
/* $NetBSD: conf.c,v 1.16 1996/10/18 21:26:57 cgd Exp $ */
/*-
@@ -240,7 +240,7 @@ getnulldev()
return makedev(mem_no, 2);
}
-static int chrtoblktbl[] = {
+int chrtoblktbl[] = {
/* XXXX This needs to be dynamic for LKMs. */
/*VCHR*/ /*VBLK*/
/* 0 */ NODEV,
@@ -296,39 +296,4 @@ static int chrtoblktbl[] = {
/* 50 */ NODEV,
/* 51 */ NODEV,
};
-
-/*
- * Convert a character device number to a block device number.
- */
-dev_t
-chrtoblk(dev)
- dev_t dev;
-{
- int blkmaj;
-
- if (major(dev) >= nchrdev ||
- major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
- return (NODEV);
- blkmaj = chrtoblktbl[major(dev)];
- if (blkmaj == NODEV)
- return (NODEV);
- return (makedev(blkmaj, minor(dev)));
-}
-
-/*
- * Convert a block device number to a character device number.
- */
-dev_t
-blktochr(dev)
- dev_t dev;
-{
- int blkmaj = major(dev);
- int i;
-
- if (blkmaj >= nblkdev)
- return (NODEV);
- for (i = 0; i < sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]); i++)
- if (blkmaj == chrtoblktbl[i])
- return (makedev(i, minor(dev)));
- return (NODEV);
-}
+int nchrtoblktbl = sizeof(chrtoblktbl) / sizeof(chrtoblktbl[0]);
diff --git a/sys/arch/hp300/hp300/conf.c b/sys/arch/hp300/hp300/conf.c
index 7e156d5c201..1333c06260f 100644
--- a/sys/arch/hp300/hp300/conf.c
+++ b/sys/arch/hp300/hp300/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.31 2002/12/05 02:49:55 kjc Exp $ */
+/* $OpenBSD: conf.c,v 1.32 2003/05/14 00:20:37 tedu Exp $ */
/* $NetBSD: conf.c,v 1.39 1997/05/12 08:17:53 thorpej Exp $ */
/*-
@@ -233,7 +233,7 @@ getnulldev()
return makedev(mem_no, 2);
}
-static int chrtoblktbl[] = {
+int chrtoblktbl[] = {
/* XXXX This needs to be dynamic for LKMs. */
/*VCHR*/ /*VBLK*/
/* 0 */ NODEV,
@@ -272,42 +272,7 @@ static int chrtoblktbl[] = {
/* 33 */ NODEV,
/* 34 */ 8,
};
-
-/*
- * Convert a character device number to a block device number.
- */
-dev_t
-chrtoblk(dev)
- dev_t dev;
-{
- int blkmaj;
-
- if (major(dev) >= nchrdev ||
- major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
- return (NODEV);
- blkmaj = chrtoblktbl[major(dev)];
- if (blkmaj == NODEV)
- return (NODEV);
- return (makedev(blkmaj, minor(dev)));
-}
-
-/*
- * Convert a block device number to a character device number.
- */
-dev_t
-blktochr(dev)
- dev_t dev;
-{
- int blkmaj = major(dev);
- int i;
-
- if (blkmaj >= nblkdev)
- return (NODEV);
- for (i = 0; i < sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]); i++)
- if (blkmaj == chrtoblktbl[i])
- return (makedev(i, minor(dev)));
- return (NODEV);
-}
+int nchrtoblktbl = sizeof(chrtoblktbl) / sizeof(chrtoblktbl[0]);
/*
* This entire table could be autoconfig()ed but that would mean that
diff --git a/sys/arch/hppa/hppa/conf.c b/sys/arch/hppa/hppa/conf.c
index 22ac37c3537..131a43f1337 100644
--- a/sys/arch/hppa/hppa/conf.c
+++ b/sys/arch/hppa/hppa/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.25 2003/02/08 12:34:27 todd Exp $ */
+/* $OpenBSD: conf.c,v 1.26 2003/05/14 00:20:37 tedu Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
@@ -183,7 +183,7 @@ int mem_no = 2; /* major device number of memory special file */
*/
dev_t swapdev = makedev(1, 0);
-static int chrtoblktbl[] = {
+int chrtoblktbl[] = {
/* XXXX This needs to be dynamic for LKMs. */
/*VCHR*/ /*VBLK*/
/* 0 */ NODEV,
@@ -214,39 +214,7 @@ static int chrtoblktbl[] = {
/* 25 */ 7,
/* 25 */ 8,
};
-
-/*
- * Convert a character device number to a block device number.
- */
-dev_t
-chrtoblk(dev)
- dev_t dev;
-{
- int blkmaj;
- if (major(dev) >= nchrdev)
- return (NODEV);
- blkmaj = chrtoblktbl[major(dev)];
- if (blkmaj == NODEV)
- return (NODEV);
- return (makedev(blkmaj, minor(dev)));
-}
-
-/*
- * Convert a block device number to a character device number.
- */
-dev_t
-blktochr(dev)
- dev_t dev;
-{
- int blkmaj = major(dev);
- int i;
- if (blkmaj >= nblkdev)
- return (NODEV);
- for (i = 0; i < sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]); i++)
- if (blkmaj == chrtoblktbl[i])
- return (makedev(i, minor(dev)));
- return (NODEV);
-}
+int nchrtoblktbl = sizeof(chrtoblktbl) / sizeof(chrtoblktbl[0]);
/*
* Returns true if dev is /dev/zero.
diff --git a/sys/arch/i386/i386/conf.c b/sys/arch/i386/i386/conf.c
index b148df48c69..85189f95e66 100644
--- a/sys/arch/i386/i386/conf.c
+++ b/sys/arch/i386/i386/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.101 2002/12/05 02:49:55 kjc Exp $ */
+/* $OpenBSD: conf.c,v 1.102 2003/05/14 00:20:37 tedu Exp $ */
/* $NetBSD: conf.c,v 1.75 1996/05/03 19:40:20 christos Exp $ */
/*
@@ -356,7 +356,7 @@ getnulldev()
return makedev(mem_no, 2);
}
-static int chrtoblktbl[] = {
+int chrtoblktbl[] = {
/* XXXX This needs to be dynamic for LKMs. */
/*VCHR*/ /*VBLK*/
/* 0 */ NODEV,
@@ -415,42 +415,7 @@ static int chrtoblktbl[] = {
/* 53 */ NODEV,
/* 54 */ 19,
};
-
-/*
- * Convert a character device number to a block device number.
- */
-dev_t
-chrtoblk(dev)
- dev_t dev;
-{
- int blkmaj;
-
- if (major(dev) >= nchrdev ||
- major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
- return (NODEV);
- blkmaj = chrtoblktbl[major(dev)];
- if (blkmaj == NODEV)
- return (NODEV);
- return (makedev(blkmaj, minor(dev)));
-}
-
-/*
- * Convert a block device number to a character device number.
- */
-dev_t
-blktochr(dev)
- dev_t dev;
-{
- int blkmaj = major(dev);
- int i;
-
- if (blkmaj >= nblkdev)
- return (NODEV);
- for (i = 0; i < sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]); i++)
- if (blkmaj == chrtoblktbl[i])
- return (makedev(i, minor(dev)));
- return (NODEV);
-}
+int nchrtoblktbl = sizeof(chrtoblktbl) / sizeof(chrtoblktbl[0]);
/*
* In order to map BSD bdev numbers of disks to their BIOS equivalents
diff --git a/sys/arch/mac68k/mac68k/conf.c b/sys/arch/mac68k/mac68k/conf.c
index bffd02760ff..b9fa4d882ed 100644
--- a/sys/arch/mac68k/mac68k/conf.c
+++ b/sys/arch/mac68k/mac68k/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.31 2002/12/05 02:49:55 kjc Exp $ */
+/* $OpenBSD: conf.c,v 1.32 2003/05/14 00:20:37 tedu Exp $ */
/* $NetBSD: conf.c,v 1.41 1997/02/11 07:35:49 scottr Exp $ */
/*
@@ -214,7 +214,7 @@ getnulldev()
return makedev(mem_no, 2);
}
-static int chrtoblktab[] = {
+int chrtoblktab[] = {
/* XXXX This needs to be dynamic for LKMs. */
/*VCHR*/ /*VBLK*/
/* 0 */ NODEV,
@@ -239,39 +239,7 @@ static int chrtoblktab[] = {
/* 19 */ 8,
/* 20 */ 9,
};
-
-dev_t
-chrtoblk(dev)
- dev_t dev;
-{
- int blkmaj;
-
- if (major(dev) >= nchrdev ||
- major(dev) > sizeof(chrtoblktab)/sizeof(chrtoblktab[0]))
- return (NODEV);
- blkmaj = chrtoblktab[major(dev)];
- if (blkmaj == NODEV)
- return (NODEV);
- return (makedev(blkmaj, minor(dev)));
-}
-
-/*
- * Convert a character device number to a block device number.
- */
-dev_t
-blktochr(dev)
- dev_t dev;
-{
- int blkmaj = major(dev);
- int i;
-
- if (blkmaj >= nblkdev)
- return (NODEV);
- for (i = 0; i < sizeof(chrtoblktab)/sizeof(chrtoblktab[0]); i++)
- if (blkmaj == chrtoblktab[i])
- return (makedev(i, minor(dev)));
- return (NODEV);
-}
+int nchrtoblktbl = sizeof(chrtoblktbl) / sizeof(chrtoblktbl[0]);
#define itecnpollc nullcnpollc
cons_decl(ite);
diff --git a/sys/arch/macppc/macppc/conf.c b/sys/arch/macppc/macppc/conf.c
index 3bad99d4beb..30a3d334e31 100644
--- a/sys/arch/macppc/macppc/conf.c
+++ b/sys/arch/macppc/macppc/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.21 2002/12/05 02:49:55 kjc Exp $ */
+/* $OpenBSD: conf.c,v 1.22 2003/05/14 00:20:37 tedu Exp $ */
/*
* Copyright (c) 1997 Per Fogelstrom
@@ -272,7 +272,7 @@ getnulldev()
return makedev(mem_no, 2);
}
-static int chrtoblktbl[] = {
+int chrtoblktbl[] = {
/*VCHR*/ /*VBLK*/
/* 0 */ NODEV,
/* 1 */ NODEV,
@@ -330,42 +330,7 @@ static int chrtoblktbl[] = {
/* 53 */ NODEV,
/* 54 */ 19,
};
-
-/*
- * Return accompanying block dev for a char dev.
- */
-int
-chrtoblk(dev)
- dev_t dev;
-{
- int blkmaj;
-
- if (major(dev) >= nchrdev ||
- major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
- return (NODEV);
- blkmaj = chrtoblktbl[major(dev)];
- if (blkmaj == NODEV)
- return (NODEV);
- return (makedev(blkmaj, minor(dev)));
-}
-
-/*
- * Convert a character device number to a block device number.
- */
-dev_t
-blktochr(dev)
- dev_t dev;
-{
- int blkmaj = major(dev);
- int i;
-
- if (blkmaj >= nblkdev)
- return (NODEV);
- for (i = 0; i < sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]); i++)
- if (blkmaj == chrtoblktbl[i])
- return (makedev(i, minor(dev)));
- return (NODEV);
-}
+int nchrtoblktbl = sizeof(chrtoblktbl) / sizeof(chrtoblktbl[0]);
#include <dev/cons.h>
#include "vgafb_pci.h"
diff --git a/sys/arch/mvme68k/mvme68k/conf.c b/sys/arch/mvme68k/mvme68k/conf.c
index 55d3c2d2bc8..1cebc436f8e 100644
--- a/sys/arch/mvme68k/mvme68k/conf.c
+++ b/sys/arch/mvme68k/mvme68k/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.31 2002/12/05 02:49:55 kjc Exp $ */
+/* $OpenBSD: conf.c,v 1.32 2003/05/14 00:20:37 tedu Exp $ */
/*-
* Copyright (c) 1995 Theo de Raadt
@@ -268,7 +268,7 @@ getnulldev()
return makedev(mem_no, 2);
}
-static int chrtoblktbl[] = {
+int chrtoblktbl[] = {
/* XXXX This needs to be dynamic for LKMs. */
/*VCHR*/ /*VBLK*/
/* 0 */ NODEV,
@@ -299,42 +299,7 @@ static int chrtoblktbl[] = {
/* 25 */ NODEV,
/* 26 */ 10, /* XD disk */
};
-
-/*
- * Convert a character device number to a block device number.
- */
-dev_t
-chrtoblk(dev)
- dev_t dev;
-{
- int blkmaj;
-
- if (major(dev) >= nchrdev ||
- major(dev) >= sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
- return (NODEV);
- blkmaj = chrtoblktbl[major(dev)];
- if (blkmaj == NODEV)
- return (NODEV);
- return (makedev(blkmaj, minor(dev)));
-}
-
-/*
- * Convert a character device number to a block device number.
- */
-dev_t
-blktochr(dev)
- dev_t dev;
-{
- int blkmaj = major(dev);
- int i;
-
- if (blkmaj >= nblkdev)
- return (NODEV);
- for (i = 0; i < sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]); i++)
- if (blkmaj == chrtoblktbl[i])
- return (makedev(i, minor(dev)));
- return (NODEV);
-}
+int nchrtoblktbl = sizeof(chrtoblktbl) / sizeof(chrtoblktbl[0]);
/*
* This entire table could be autoconfig()ed but that would mean that
diff --git a/sys/arch/mvme88k/mvme88k/conf.c b/sys/arch/mvme88k/mvme88k/conf.c
index c1bcc8341b1..6989305e7c7 100644
--- a/sys/arch/mvme88k/mvme88k/conf.c
+++ b/sys/arch/mvme88k/mvme88k/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.24 2002/12/05 02:49:55 kjc Exp $ */
+/* $OpenBSD: conf.c,v 1.25 2003/05/14 00:20:37 tedu Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
@@ -246,7 +246,7 @@ getnulldev()
return makedev(mem_no, 2);
}
-static int chrtoblktbl[] = {
+int chrtoblktbl[] = {
/* XXXX This needs to be dynamic for LKMs. */
/*VCHR*/ /*VBLK*/
/* 0 */ NODEV,
@@ -277,42 +277,7 @@ static int chrtoblktbl[] = {
/* 25 */ NODEV,
/* 26 */ 10, /* XD disk */
};
-
-/*
- * Convert a character device number to a block device number.
- */
-dev_t
-chrtoblk(dev)
- dev_t dev;
-{
- int blkmaj;
-
- if (major(dev) >= nchrdev ||
- major(dev) >= sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
- return (NODEV);
- blkmaj = chrtoblktbl[major(dev)];
- if (blkmaj == NODEV)
- return (NODEV);
- return (makedev(blkmaj, minor(dev)));
-}
-
-/*
- * Convert a character device number to a block device number.
- */
-dev_t
-blktochr(dev)
- dev_t dev;
-{
- int blkmaj = major(dev);
- int i;
-
- if (blkmaj >= nblkdev)
- return (NODEV);
- for (i = 0; i < sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]); i++)
- if (blkmaj == chrtoblktbl[i])
- return (makedev(i, minor(dev)));
- return (NODEV);
-}
+int nchrtoblktbl = sizeof(chrtoblktbl) / sizeof(chrtoblktbl[0]);
/*
* This entire table could be autoconfig()ed but that would mean that
diff --git a/sys/arch/mvmeppc/mvmeppc/conf.c b/sys/arch/mvmeppc/mvmeppc/conf.c
index 8e0100965f9..ec9a7b65c53 100644
--- a/sys/arch/mvmeppc/mvmeppc/conf.c
+++ b/sys/arch/mvmeppc/mvmeppc/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.14 2002/12/05 02:49:55 kjc Exp $ */
+/* $OpenBSD: conf.c,v 1.15 2003/05/14 00:20:37 tedu Exp $ */
/*
* Copyright (c) 1997 Per Fogelstrom
@@ -238,7 +238,7 @@ getnulldev()
return makedev(mem_no, 2);
}
-static int chrtoblktbl[] = {
+int chrtoblktbl[] = {
/*VCHR*/ /*VBLK*/
/* 0 */ NODEV,
/* 1 */ NODEV,
@@ -296,42 +296,7 @@ static int chrtoblktbl[] = {
/* 53 */ NODEV,
/* 54 */ 19,
};
-
-/*
- * Return accompanying block dev for a char dev.
- */
-int
-chrtoblk(dev)
- dev_t dev;
-{
- int blkmaj;
-
- if (major(dev) >= nchrdev ||
- major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
- return (NODEV);
- blkmaj = chrtoblktbl[major(dev)];
- if (blkmaj == NODEV)
- return (NODEV);
- return (makedev(blkmaj, minor(dev)));
-}
-
-/*
- * Convert a character device number to a block device number.
- */
-dev_t
-blktochr(dev)
- dev_t dev;
-{
- int blkmaj = major(dev);
- int i;
-
- if (blkmaj >= nblkdev)
- return (NODEV);
- for (i = 0; i < sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]); i++)
- if (blkmaj == chrtoblktbl[i])
- return (makedev(i, minor(dev)));
- return (NODEV);
-}
+int nchrtoblktbl = sizeof(chrtoblktbl) / sizeof(chrtoblktbl[0]);
#include <dev/cons.h>
diff --git a/sys/arch/sparc/sparc/conf.c b/sys/arch/sparc/sparc/conf.c
index 5e68aff6dd6..dee3953b7ed 100644
--- a/sys/arch/sparc/sparc/conf.c
+++ b/sys/arch/sparc/sparc/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.36 2003/04/13 22:55:52 miod Exp $ */
+/* $OpenBSD: conf.c,v 1.37 2003/05/14 00:20:37 tedu Exp $ */
/* $NetBSD: conf.c,v 1.40 1996/04/11 19:20:03 thorpej Exp $ */
/*
@@ -306,7 +306,7 @@ getnulldev()
return makedev(mem_no, 2);
}
-static int chrtoblktbl[] = {
+int chrtoblktbl[] = {
/* XXXX This needs to be dynamic for LKMs. */
/*VCHR*/ /*VBLK*/
/* 0 */ NODEV,
@@ -434,39 +434,4 @@ static int chrtoblktbl[] = {
/*122 */ NODEV,
/*123 */ 25,
};
-
-/*
- * Routine to convert from character to block device number.
- */
-int
-chrtoblk(dev)
- dev_t dev;
-{
- int blkmaj;
-
- if (major(dev) >= nchrdev ||
- major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
- return (NODEV);
- blkmaj = chrtoblktbl[major(dev)];
- if (blkmaj == NODEV)
- return (NODEV);
- return (makedev(blkmaj, minor(dev)));
-}
-
-/*
- * Convert a character device number to a block device number.
- */
-dev_t
-blktochr(dev)
- dev_t dev;
-{
- int blkmaj = major(dev);
- int i;
-
- if (blkmaj >= nblkdev)
- return (NODEV);
- for (i = 0; i < sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]); i++)
- if (blkmaj == chrtoblktbl[i])
- return (makedev(i, minor(dev)));
- return (NODEV);
-}
+int nchrtoblktbl = sizeof(chrtoblktbl) / sizeof(chrtoblktbl[0]);
diff --git a/sys/arch/sparc64/sparc64/conf.c b/sys/arch/sparc64/sparc64/conf.c
index 4deb5505b3e..0ea10d4c678 100644
--- a/sys/arch/sparc64/sparc64/conf.c
+++ b/sys/arch/sparc64/sparc64/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.33 2002/12/05 02:49:55 kjc Exp $ */
+/* $OpenBSD: conf.c,v 1.34 2003/05/14 00:20:37 tedu Exp $ */
/* $NetBSD: conf.c,v 1.17 2001/03/26 12:33:26 lukem Exp $ */
/*
@@ -337,7 +337,7 @@ getnulldev(void)
return makedev(mem_no, 2);
}
-static int chrtoblktbl[] = {
+int chrtoblktbl[] = {
/* XXXX This needs to be dynamic for LKMs. */
/*VCHR*/ /*VBLK*/
/* 0 */ NODEV,
@@ -464,39 +464,4 @@ static int chrtoblktbl[] = {
/*121 */ 25,
/*122 */ NODEV,
};
-
-/*
- * Routine to convert from character to block device number.
- */
-dev_t
-chrtoblk(dev)
- dev_t dev;
-{
- int blkmaj;
-
- if (major(dev) >= nchrdev)
- return (NODEV);
- blkmaj = chrtoblktbl[major(dev)];
- if (blkmaj == NODEV)
- return (NODEV);
- return (makedev(blkmaj, minor(dev)));
-}
-
-/*
- * Convert a character device number to a block device number.
- */
-dev_t
-blktochr(dev)
- dev_t dev;
-{
- int blkmaj = major(dev);
- int i;
-
- if (blkmaj >= nblkdev)
- return (NODEV);
- for (i = 0; i < sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]); i++)
- if (blkmaj == chrtoblktbl[i])
- return (makedev(i, minor(dev)));
- return (NODEV);
-}
-
+int nchrtoblktbl = sizeof(chrtoblktbl) / sizeof(chrtoblktbl[0]);
diff --git a/sys/arch/vax/vax/conf.c b/sys/arch/vax/vax/conf.c
index 08f720e02eb..d2236e6c163 100644
--- a/sys/arch/vax/vax/conf.c
+++ b/sys/arch/vax/vax/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.38 2002/12/05 02:49:55 kjc Exp $ */
+/* $OpenBSD: conf.c,v 1.39 2003/05/14 00:20:37 tedu Exp $ */
/* $NetBSD: conf.c,v 1.44 1999/10/27 16:38:54 ragge Exp $ */
/*-
@@ -535,39 +535,7 @@ int chrtoblktbl[] = {
25, /* 73 */
NODEV, /* 74 */
};
-
-dev_t
-chrtoblk(dev)
- dev_t dev;
-{
- int blkmaj;
-
- if (major(dev) >= nchrdev ||
- major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
- return (NODEV);
- blkmaj = chrtoblktbl[major(dev)];
- if (blkmaj == NODEV)
- return (NODEV);
- return (makedev(blkmaj, minor(dev)));
-}
-
-/*
- * Convert a character device number to a block device number.
- */
-dev_t
-blktochr(dev)
- dev_t dev;
-{
- int blkmaj = major(dev);
- int i;
-
- if (blkmaj >= nblkdev)
- return (NODEV);
- for (i = 0; i < sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]); i++)
- if (blkmaj == chrtoblktbl[i])
- return (makedev(i, minor(dev)));
- return (NODEV);
-}
+int nchrtoblktbl = sizeof(chrtoblktbl) / sizeof(chrtoblktbl[0]);
/*
* Returns true if dev is /dev/mem or /dev/kmem.
diff --git a/sys/arch/vax/vax/machdep.c b/sys/arch/vax/vax/machdep.c
index 759350dfc43..b21f9841ca8 100644
--- a/sys/arch/vax/vax/machdep.c
+++ b/sys/arch/vax/vax/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.65 2003/04/16 16:54:17 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.66 2003/05/14 00:20:37 tedu Exp $ */
/* $NetBSD: machdep.c,v 1.108 2000/09/13 15:00:23 thorpej Exp $ */
/*
@@ -139,7 +139,6 @@ int bufpages = 0;
#endif
int bufcachepercent = BUFCACHEPERCENT;
-extern int *chrtoblktbl;
extern int virtual_avail, virtual_end;
/*
* We do these external declarations here, maybe they should be done
diff --git a/sys/kern/subr_xxx.c b/sys/kern/subr_xxx.c
index ee6115e5461..1c243610ff0 100644
--- a/sys/kern/subr_xxx.c
+++ b/sys/kern/subr_xxx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_xxx.c,v 1.6 1997/11/06 05:58:20 csapuntz Exp $ */
+/* $OpenBSD: subr_xxx.c,v 1.7 2003/05/14 00:20:38 tedu Exp $ */
/* $NetBSD: subr_xxx.c,v 1.10 1996/02/04 02:16:51 christos Exp $ */
/*
@@ -42,6 +42,8 @@
*/
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/conf.h>
#include <machine/cpu.h>
@@ -111,3 +113,50 @@ nullop(v)
return (0);
}
+
+struct bdevsw *
+bdevsw_lookup(dev_t dev)
+{
+ return (&bdevsw[major(dev)]);
+}
+
+struct cdevsw *
+cdevsw_lookup(dev_t dev)
+{
+ return (&cdevsw[major(dev)]);
+}
+
+/*
+ * Convert a character device number to a block device number.
+ */
+dev_t
+chrtoblk(dev)
+ dev_t dev;
+{
+ int blkmaj;
+
+ if (major(dev) >= nchrdev || major(dev) >= nchrtoblktbl)
+ return (NODEV);
+ blkmaj = chrtoblktbl[major(dev)];
+ if (blkmaj == NODEV)
+ return (NODEV);
+ return (makedev(blkmaj, minor(dev)));
+}
+
+/*
+ * Convert a block device number to a character device number.
+ */
+dev_t
+blktochr(dev)
+ dev_t dev;
+{
+ int blkmaj = major(dev);
+ int i;
+
+ if (blkmaj >= nblkdev)
+ return (NODEV);
+ for (i = 0; i < nchrtoblktbl; i++)
+ if (blkmaj == chrtoblktbl[i])
+ return (makedev(i, minor(dev)));
+ return (NODEV);
+}
diff --git a/sys/sys/conf.h b/sys/sys/conf.h
index 73ac1bb39e3..da255380d83 100644
--- a/sys/sys/conf.h
+++ b/sys/sys/conf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.h,v 1.67 2002/11/08 19:00:37 mickey Exp $ */
+/* $OpenBSD: conf.h,v 1.68 2003/05/14 00:20:38 tedu Exp $ */
/* $NetBSD: conf.h,v 1.33 1996/05/03 20:03:32 christos Exp $ */
/*-
@@ -499,7 +499,11 @@ struct swdevt {
#ifdef _KERNEL
extern struct swdevt swdevt[];
+extern int chrtoblktbl[];
+extern int nchrtoblktbl;
+struct bdevsw *bdevsw_lookup(dev_t);
+struct cdevsw *cdevsw_lookup(dev_t);
int chrtoblk(dev_t);
int blktochr(dev_t);
int iskmemdev(dev_t);