summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2016-08-16 18:21:55 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2016-08-16 18:21:55 +0000
commitad68fbc7c23b820b2346658c81d4e768ed492dc9 (patch)
tree474d953230e1c9714982e3e3f881b85de73fee76 /sys
parent156358f1e735807dffd845dd2e5c4e0de3fa16ae (diff)
remove #define for /dev/mem minors. let the raw magic of the hardcoded
numbers serve as a warning not to touch them.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/arm/arm/mem.c20
-rw-r--r--sys/arch/sh/sh/mem.c24
2 files changed, 18 insertions, 26 deletions
diff --git a/sys/arch/arm/arm/mem.c b/sys/arch/arm/arm/mem.c
index 9c636f8cfc6..2e76a251861 100644
--- a/sys/arch/arm/arm/mem.c
+++ b/sys/arch/arm/arm/mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mem.c,v 1.17 2016/08/16 18:17:36 tedu Exp $ */
+/* $OpenBSD: mem.c,v 1.18 2016/08/16 18:21:54 tedu Exp $ */
/* $NetBSD: mem.c,v 1.11 2003/10/16 12:02:58 jdolecek Exp $ */
/*
@@ -134,10 +134,6 @@ mmclose(dev_t dev, int flag, int mode, struct proc *p)
#endif
return (0);
}
-#define DEV_MEM 0
-#define DEV_KMEM 1
-#define DEV_NULL 2
-#define DEV_ZERO 12
int
mmrw(dev_t dev, struct uio *uio, int flags)
@@ -149,7 +145,7 @@ mmrw(dev_t dev, struct uio *uio, int flags)
int error = 0;
vm_prot_t prot;
- if (minor(dev) == DEV_MEM) {
+ if (minor(dev) == 0) {
/* lock against other uses of shared vmmap */
error = rw_enter(&physlock, RW_WRITE | RW_INTR);
if (error)
@@ -167,7 +163,7 @@ mmrw(dev_t dev, struct uio *uio, int flags)
}
switch (minor(dev)) {
- case DEV_MEM:
+ case 0:
v = uio->uio_offset;
prot = uio->uio_rw == UIO_READ ? PROT_READ :
PROT_WRITE;
@@ -182,7 +178,7 @@ mmrw(dev_t dev, struct uio *uio, int flags)
pmap_update(pmap_kernel());
break;
- case DEV_KMEM:
+ case 1:
v = uio->uio_offset;
c = ulmin(iov->iov_len, MAXPHYS);
if (!uvm_kernacc((caddr_t)v, c,
@@ -191,12 +187,12 @@ mmrw(dev_t dev, struct uio *uio, int flags)
error = uiomove((caddr_t)v, c, uio);
break;
- case DEV_NULL:
+ case 2:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
- case DEV_ZERO:
+ case 12:
if (uio->uio_rw == UIO_WRITE) {
uio->uio_resid = 0;
return (0);
@@ -212,7 +208,7 @@ mmrw(dev_t dev, struct uio *uio, int flags)
return (ENXIO);
}
}
- if (minor(dev) == DEV_MEM) {
+ if (minor(dev) == 0) {
rw_exit(&physlock);
}
return (error);
@@ -231,7 +227,7 @@ mmmmap(dev_t dev, off_t off, int prot)
* and /dev/zero is a hack that is handled via the default
* pager in mmap().
*/
- if (minor(dev) != DEV_MEM)
+ if (minor(dev) != 0)
return (-1);
/* minor device 0 is physical memory */
diff --git a/sys/arch/sh/sh/mem.c b/sys/arch/sh/sh/mem.c
index 0eac7ab15fd..fdbe75a5b71 100644
--- a/sys/arch/sh/sh/mem.c
+++ b/sys/arch/sh/sh/mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mem.c,v 1.7 2016/08/15 22:01:59 tedu Exp $ */
+/* $OpenBSD: mem.c,v 1.8 2016/08/16 18:21:54 tedu Exp $ */
/* $NetBSD: mem.c,v 1.21 2006/07/23 22:06:07 ad Exp $ */
/*
@@ -97,19 +97,15 @@ boolean_t __mm_mem_addr(paddr_t);
#define mmwrite mmrw
cdev_decl(mm);
-#define DEV_MEM 0
-#define DEV_KMEM 1
-#define DEV_NULL 2
-#define DEV_ZERO 12
int
mmopen(dev_t dev, int flag, int mode, struct proc *p)
{
switch (minor(dev)) {
- case DEV_MEM:
- case DEV_KMEM:
- case DEV_NULL:
- case DEV_ZERO:
+ case 0:
+ case 1:
+ case 2:
+ case 12:
break;
default:
return (ENXIO);
@@ -145,7 +141,7 @@ mmrw(dev_t dev, struct uio *uio, int flags)
v = uio->uio_offset;
switch (minor(dev)) {
- case DEV_MEM:
+ case 0:
/* Physical address */
if (__mm_mem_addr(v)) {
o = v & PGOFSET;
@@ -157,7 +153,7 @@ mmrw(dev_t dev, struct uio *uio, int flags)
}
break;
- case DEV_KMEM:
+ case 1:
if (v < SH3_P1SEG_BASE) /* P0 */
return (EFAULT);
if (v < SH3_P2SEG_BASE) { /* P1 */
@@ -180,12 +176,12 @@ mmrw(dev_t dev, struct uio *uio, int flags)
}
break;
- case DEV_NULL:
+ case 2:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
- case DEV_ZERO:
+ case 12:
if (uio->uio_rw == UIO_WRITE) {
uio->uio_resid = 0;
return (0);
@@ -210,7 +206,7 @@ mmmmap(dev_t dev, off_t off, int prot)
{
struct proc *p = curproc;
- if (minor(dev) != DEV_MEM)
+ if (minor(dev) != 0)
return (-1);
if (__mm_mem_addr((paddr_t)off) == FALSE && suser(p, 0) != 0)