Add functions to access device flags. This restores simultaneous audio

open/close.

OK hannken@ christos@
This commit is contained in:
nat 2016-12-09 19:13:47 +00:00
parent 1311bb81d9
commit f1631e52a4
3 changed files with 28 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_devsw.c,v 1.34 2016/02/01 05:05:43 riz Exp $ */
/* $NetBSD: subr_devsw.c,v 1.35 2016/12/09 19:13:47 nat Exp $ */
/*-
* Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.34 2016/02/01 05:05:43 riz Exp $");
__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.35 2016/12/09 19:13:47 nat Exp $");
#ifdef _KERNEL_OPT
#include "opt_dtrace.h"
@ -795,6 +795,16 @@ bdev_dump(dev_t dev, daddr_t addr, void *data, size_t sz)
return rv;
}
int
bdev_flags(dev_t dev)
{
const struct bdevsw *d;
if ((d = bdevsw_lookup(dev)) == NULL)
return 0;
return d->d_flag & ~D_TYPEMASK;
}
int
bdev_type(dev_t dev)
{
@ -1025,6 +1035,16 @@ cdev_discard(dev_t dev, off_t pos, off_t len)
return rv;
}
int
cdev_flags(dev_t dev)
{
const struct cdevsw *d;
if ((d = cdevsw_lookup(dev)) == NULL)
return 0;
return d->d_flag & ~D_TYPEMASK;
}
int
cdev_type(dev_t dev)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: spec_vnops.c,v 1.166 2016/12/08 10:28:44 nat Exp $ */
/* $NetBSD: spec_vnops.c,v 1.167 2016/12/09 19:13:47 nat Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.166 2016/12/08 10:28:44 nat Exp $");
__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.167 2016/12/09 19:13:47 nat Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -1227,7 +1227,7 @@ spec_close(void *v)
sd->sd_bdevvp = NULL;
mutex_exit(&device_lock);
if (count != 0 && (vp->v_type != VCHR || cdev_type(dev) != D_MCLOSE))
if (count != 0 && (vp->v_type != VCHR || !(cdev_flags(dev) & D_MCLOSE)))
return 0;
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: conf.h,v 1.148 2016/12/08 20:53:12 nat Exp $ */
/* $NetBSD: conf.h,v 1.149 2016/12/09 19:13:47 nat Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -175,7 +175,9 @@ dev_type_kqfilter(cdev_kqfilter);
dev_type_discard(cdev_discard);
int cdev_type(dev_t);
int cdev_flags(dev_t);
int bdev_type(dev_t);
int bdev_flags(dev_t);
/* symbolic sleep message strings */
extern const char devopn[], devio[], devwait[], devin[], devout[];