From 369a12704f489199d41511822b1a41e10406841e Mon Sep 17 00:00:00 2001 From: Tomas Hruby Date: Tue, 7 Feb 2012 15:41:25 +0000 Subject: [PATCH] VFS - dev_style_asyn() - dev_style_asyn() tests whether a device is asynchronous - simplifies code and helps readability --- include/minix/dmap.h | 3 +++ servers/vfs/device.c | 8 +++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/minix/dmap.h b/include/minix/dmap.h index 562a20ab8..5a17c00e6 100644 --- a/include/minix/dmap.h +++ b/include/minix/dmap.h @@ -8,6 +8,9 @@ enum dev_style { STYLE_NDEV, STYLE_DEV, STYLE_DEVA, STYLE_TTY, STYLE_CTTY, STYLE_CLONE, STYLE_CLONE_A }; #define IS_DEV_STYLE(s) (s>=STYLE_NDEV && s<=STYLE_CLONE_A) +#define dev_style_asyn(devstyle) ((devstyle) == STYLE_DEVA || \ + (devstyle) == STYLE_CLONE_A) + /*===========================================================================* * Major and minor device numbers * *===========================================================================*/ diff --git a/servers/vfs/device.c b/servers/vfs/device.c index adbcd9e6b..8626550de 100644 --- a/servers/vfs/device.c +++ b/servers/vfs/device.c @@ -245,8 +245,7 @@ PUBLIC void dev_status(message *m) if (major >= NR_DEVICES) /* Device endpoint not found; nothing to do */ return; - if (dmap[major].dmap_style == STYLE_DEVA || - dmap[major].dmap_style == STYLE_CLONE_A) { + if (dev_style_asyn(dmap[major].dmap_style)) { printf("VFS: not doing dev_status for async driver %d\n", m->m_source); return; } @@ -477,8 +476,7 @@ PUBLIC int dev_io( /* Task has completed. See if call completed. */ if (ret == SUSPEND) { - if ((flags & O_NONBLOCK) && !(dp->dmap_style == STYLE_DEVA || - dp->dmap_style == STYLE_CLONE_A)) { + if ((flags & O_NONBLOCK) && !dev_style_asyn(dp->dmap_style)) { /* Not supposed to block. */ ret = cancel_nblock(dp, minor_dev, call_nr, ioproc, gid); if (ret == EINTR) @@ -868,7 +866,7 @@ PUBLIC int clone_opcl( r = (*dp->dmap_io)(dp->dmap_driver, &dev_mess); if (r != OK) return(r); - if (op == DEV_OPEN && dp->dmap_style == STYLE_CLONE_A) { + if (op == DEV_OPEN && dev_style_asyn(dp->dmap_style)) { /* Wait for reply when driver is asynchronous */ fp->fp_task = dp->dmap_driver; worker_wait();