summaryrefslogtreecommitdiff
path: root/sys/dev/raidframe
diff options
context:
space:
mode:
authorgehenna <gehenna@NetBSD.org>2002-09-06 13:18:43 +0000
committergehenna <gehenna@NetBSD.org>2002-09-06 13:18:43 +0000
commit77a6b82b27fa24d81a68a73afb1c4158bfb664ba (patch)
tree66b96267c2ac1e49569dd04156f250bd1f8bec0f /sys/dev/raidframe
parent69b9a24021dfa75acf84545a423d9eee0b3995d5 (diff)
Merge the gehenna-devsw branch into the trunk.
This merge changes the device switch tables from static array to dynamically generated by config(8). - All device switches is defined as a constant structure in device drivers. - The new grammer ``device-major'' is introduced to ``files''. device-major <prefix> char <num> [block <num>] [<rules>] - All device major numbers must be listed up in port dependent majors.<arch> by using this grammer. - Added the new naming convention. The name of the device switch must be <prefix>_[bc]devsw for auto-generation of device switch tables. - The backward compatibility of loading block/character device switch by LKM framework is broken. This is necessary to convert from block/character device major to device name in runtime and vice versa. - The restriction to assign device major by LKM is completely removed. We don't need to reserve LKM entries for dynamic loading of device switch. - In compile time, device major numbers list is packed into the kernel and the LKM framework will refer it to assign device major number dynamically.
Diffstat (limited to 'sys/dev/raidframe')
-rw-r--r--sys/dev/raidframe/rf_netbsdkintf.c56
1 files changed, 35 insertions, 21 deletions
diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c
index 043ddbe77b4..ee456a4fa89 100644
--- a/sys/dev/raidframe/rf_netbsdkintf.c
+++ b/sys/dev/raidframe/rf_netbsdkintf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_netbsdkintf.c,v 1.129 2002/08/07 20:45:39 oster Exp $ */
+/* $NetBSD: rf_netbsdkintf.c,v 1.130 2002/09/06 13:18:43 gehenna Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -114,7 +114,7 @@
***********************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.129 2002/08/07 20:45:39 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.130 2002/09/06 13:18:43 gehenna Exp $");
#include <sys/param.h>
#include <sys/errno.h>
@@ -180,14 +180,25 @@ static void InitBP(struct buf * bp, struct vnode *, unsigned rw_flag,
static void raidinit(RF_Raid_t *);
void raidattach(int);
-int raidsize(dev_t);
-int raidopen(dev_t, int, int, struct proc *);
-int raidclose(dev_t, int, int, struct proc *);
-int raidioctl(dev_t, u_long, caddr_t, int, struct proc *);
-int raidwrite(dev_t, struct uio *, int);
-int raidread(dev_t, struct uio *, int);
-void raidstrategy(struct buf *);
-int raiddump(dev_t, daddr_t, caddr_t, size_t);
+
+dev_type_open(raidopen);
+dev_type_close(raidclose);
+dev_type_read(raidread);
+dev_type_write(raidwrite);
+dev_type_ioctl(raidioctl);
+dev_type_strategy(raidstrategy);
+dev_type_dump(raiddump);
+dev_type_size(raidsize);
+
+const struct bdevsw raid_bdevsw = {
+ raidopen, raidclose, raidstrategy, raidioctl,
+ raiddump, raidsize, D_DISK
+};
+
+const struct cdevsw raid_cdevsw = {
+ raidopen, raidclose, raidread, raidwrite, raidioctl,
+ nostop, notty, nopoll, nommap, D_DISK
+};
/*
* Pilfered from ccd.c
@@ -2209,6 +2220,7 @@ raidread_component_label(dev, b_vp, clabel)
RF_ComponentLabel_t *clabel;
{
struct buf *bp;
+ const struct bdevsw *bdev;
int error;
/* XXX should probably ensure that we don't try to do this if
@@ -2230,7 +2242,10 @@ raidread_component_label(dev, b_vp, clabel)
bp->b_flags |= B_READ;
bp->b_resid = RF_COMPONENT_INFO_SIZE / DEV_BSIZE;
- (*bdevsw[major(bp->b_dev)].d_strategy)(bp);
+ bdev = bdevsw_lookup(bp->b_dev);
+ if (bdev == NULL)
+ return (ENXIO);
+ (*bdev->d_strategy)(bp);
error = biowait(bp);
@@ -2257,6 +2272,7 @@ raidwrite_component_label(dev, b_vp, clabel)
RF_ComponentLabel_t *clabel;
{
struct buf *bp;
+ const struct bdevsw *bdev;
int error;
/* get a block of the appropriate size... */
@@ -2273,7 +2289,10 @@ raidwrite_component_label(dev, b_vp, clabel)
memcpy(bp->b_data, clabel, sizeof(RF_ComponentLabel_t));
- (*bdevsw[major(bp->b_dev)].d_strategy)(bp);
+ bdev = bdevsw_lookup(bp->b_dev);
+ if (bdev == NULL)
+ return (ENXIO);
+ (*bdev->d_strategy)(bp);
error = biowait(bp);
brelse(bp);
if (error) {
@@ -2658,12 +2677,11 @@ rf_mountroot_hook(dev)
RF_AutoConfig_t *
rf_find_raid_components()
{
- struct devnametobdevmaj *dtobdm;
struct vnode *vp;
struct disklabel label;
struct device *dv;
- char *cd_name;
dev_t dev;
+ int bmajor;
int error;
int i;
int good_one;
@@ -2704,15 +2722,11 @@ rf_find_raid_components()
}
/* need to find the device_name_to_block_device_major stuff */
- cd_name = dv->dv_cfdata->cf_driver->cd_name;
- dtobdm = dev_name2blk;
- while (dtobdm->d_name && strcmp(dtobdm->d_name, cd_name)) {
- dtobdm++;
- }
+ bmajor = devsw_name2blk(dv->dv_xname, NULL, 0);
/* get a vnode for the raw partition of this disk */
- dev = MAKEDISKDEV(dtobdm->d_maj, dv->dv_unit, RAW_PART);
+ dev = MAKEDISKDEV(bmajor, dv->dv_unit, RAW_PART);
if (bdevvp(dev, &vp))
panic("RAID can't alloc vnode");
@@ -2748,7 +2762,7 @@ rf_find_raid_components()
if (label.d_partitions[i].p_fstype != FS_RAID)
continue;
- dev = MAKEDISKDEV(dtobdm->d_maj, dv->dv_unit, i);
+ dev = MAKEDISKDEV(bmajor, dv->dv_unit, i);
if (bdevvp(dev, &vp))
panic("RAID can't alloc vnode");