Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/gehenna-devsw]: src/sys/uvm Replace the direct-access to devsw table wit...
details: https://anonhg.NetBSD.org/src/rev/a812b3237aa8
branches: gehenna-devsw
changeset: 527030:a812b3237aa8
user: gehenna <gehenna%NetBSD.org@localhost>
date: Thu May 16 03:45:49 2002 +0000
description:
Replace the direct-access to devsw table with calling devsw APIs.
diffstat:
sys/uvm/uvm_device.c | 22 +++++++++++++++-------
sys/uvm/uvm_vnode.c | 26 ++++++++++++++++++--------
2 files changed, 33 insertions(+), 15 deletions(-)
diffs (125 lines):
diff -r 922fd92dbcfa -r a812b3237aa8 sys/uvm/uvm_device.c
--- a/sys/uvm/uvm_device.c Thu May 16 03:43:24 2002 +0000
+++ b/sys/uvm/uvm_device.c Thu May 16 03:45:49 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_device.c,v 1.40 2002/02/28 21:00:23 christos Exp $ */
+/* $NetBSD: uvm_device.c,v 1.40.8.1 2002/05/16 03:45:49 gehenna Exp $ */
/*
*
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_device.c,v 1.40 2002/02/28 21:00:23 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_device.c,v 1.40.8.1 2002/05/16 03:45:49 gehenna Exp $");
#include "opt_uvmhist.h"
@@ -120,6 +120,7 @@
{
dev_t device = *((dev_t *)arg);
struct uvm_device *udv, *lcv;
+ const struct cdevsw *cdev;
dev_type_mmap((*mapfn));
UVMHIST_FUNC("udv_attach"); UVMHIST_CALLED(maphist);
@@ -130,10 +131,11 @@
* before we do anything, ensure this device supports mmap
*/
- mapfn = cdevsw[major(device)].d_mmap;
- if (mapfn == NULL ||
- mapfn == (dev_type_mmap((*))) enodev ||
- mapfn == (dev_type_mmap((*))) nullop)
+ cdev = cdevsw_lookup(device);
+ if (cdev == NULL)
+ return (NULL);
+ mapfn = cdev->d_mmap;
+ if (mapfn == NULL || mapfn == nommap || mapfn == nullmmap)
return(NULL);
/*
@@ -365,6 +367,7 @@
struct vm_map_entry *entry = ufi->entry;
struct uvm_object *uobj = entry->object.uvm_obj;
struct uvm_device *udv = (struct uvm_device *)uobj;
+ const struct cdevsw *cdev;
vaddr_t curr_va;
off_t curr_offset;
paddr_t paddr, mdpgno;
@@ -392,7 +395,12 @@
*/
device = udv->u_device;
- mapfn = cdevsw[major(device)].d_mmap;
+ cdev = cdevsw_lookup(device);
+ if (cdev == NULL) {
+ uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap, uobj, NULL);
+ return (EIO);
+ }
+ mapfn = cdev->d_mmap;
/*
* now we must determine the offset in udv to use and the VA to
diff -r 922fd92dbcfa -r a812b3237aa8 sys/uvm/uvm_vnode.c
--- a/sys/uvm/uvm_vnode.c Thu May 16 03:43:24 2002 +0000
+++ b/sys/uvm/uvm_vnode.c Thu May 16 03:45:49 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_vnode.c,v 1.57 2001/12/31 07:00:15 chs Exp $ */
+/* $NetBSD: uvm_vnode.c,v 1.57.8.1 2002/05/16 03:45:49 gehenna Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_vnode.c,v 1.57 2001/12/31 07:00:15 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_vnode.c,v 1.57.8.1 2002/05/16 03:45:49 gehenna Exp $");
#include "fs_nfs.h"
#include "opt_uvmhist.h"
@@ -125,6 +125,7 @@
struct vnode *vp = arg;
struct uvm_object *uobj = &vp->v_uobj;
struct vattr vattr;
+ const struct bdevsw *bdev;
int result;
struct partinfo pi;
voff_t used_vnode_size;
@@ -150,10 +151,14 @@
/*
* if we're mapping a BLK device, make sure it is a disk.
*/
- if (vp->v_type == VBLK && bdevsw[major(vp->v_rdev)].d_type != D_DISK) {
- simple_unlock(&uobj->vmobjlock);
- UVMHIST_LOG(maphist,"<- done (VBLK not D_DISK!)", 0,0,0,0);
- return(NULL);
+ if (vp->v_type == VBLK) {
+ bdev = bdevsw_lookup(vp->v_rdev);
+ if (bdev == NULL || bdev->d_type != D_DISK) {
+ simple_unlock(&uobj->vmobjlock);
+ UVMHIST_LOG(maphist,"<- done (VBLK not D_DISK!)",
+ 0,0,0,0);
+ return(NULL);
+ }
}
KASSERT(vp->v_type == VREG || vp->v_type == VBLK);
@@ -176,8 +181,13 @@
*
* (2) All we want is the size, anyhow.
*/
- result = (*bdevsw[major(vp->v_rdev)].d_ioctl)(vp->v_rdev,
- DIOCGPART, (caddr_t)&pi, FREAD, curproc);
+ bdev = bdevsw_lookup(vp->v_rdev);
+ if (bdev != NULL) {
+ result = (*bdev->d_ioctl)(vp->v_rdev, DIOCGPART,
+ (caddr_t)&pi, FREAD, curproc);
+ } else {
+ result = ENXIO;
+ }
if (result == 0) {
/* XXX should remember blocksize */
used_vnode_size = (voff_t)pi.disklab->d_secsize *
Home |
Main Index |
Thread Index |
Old Index