Allow multiple devices to mmap. It's impossible to prevent this with
checks on the open/close functions. MFC after: 1 week
This commit is contained in:
parent
238e75e505
commit
afe2c75694
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=275376
@ -67,7 +67,6 @@ static device_attach_t ti_pruss_attach;
|
||||
static device_detach_t ti_pruss_detach;
|
||||
static void ti_pruss_intr(void *);
|
||||
static d_open_t ti_pruss_open;
|
||||
static d_close_t ti_pruss_close;
|
||||
static d_mmap_t ti_pruss_mmap;
|
||||
static void ti_pruss_kq_read_detach(struct knote *);
|
||||
static int ti_pruss_kq_read_event(struct knote *, long);
|
||||
@ -83,14 +82,12 @@ struct ti_pruss_softc {
|
||||
bus_space_handle_t sc_bh;
|
||||
struct cdev *sc_pdev;
|
||||
struct selinfo sc_selinfo;
|
||||
uint32_t sc_inuse;
|
||||
};
|
||||
|
||||
static struct cdevsw ti_pruss_cdevsw = {
|
||||
.d_version = D_VERSION,
|
||||
.d_name = "ti_pruss",
|
||||
.d_open = ti_pruss_open,
|
||||
.d_close = ti_pruss_close,
|
||||
.d_mmap = ti_pruss_mmap,
|
||||
.d_kqfilter = ti_pruss_kqfilter,
|
||||
};
|
||||
@ -246,25 +243,9 @@ ti_pruss_intr(void *arg)
|
||||
}
|
||||
|
||||
static int
|
||||
ti_pruss_open(struct cdev *cdev, int oflags, int devtype, struct thread *td)
|
||||
ti_pruss_open(struct cdev *cdev __unused, int oflags __unused,
|
||||
int devtype __unused, struct thread *td __unused)
|
||||
{
|
||||
device_t dev = cdev->si_drv1;
|
||||
struct ti_pruss_softc *sc = device_get_softc(dev);
|
||||
|
||||
if (atomic_cmpset_32(&sc->sc_inuse, 0, 1) == 0)
|
||||
return (EBUSY);
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
ti_pruss_close(struct cdev *cdev, int fflag, int devtype, struct thread *td)
|
||||
{
|
||||
device_t dev = cdev->si_drv1;
|
||||
struct ti_pruss_softc *sc = device_get_softc(dev);
|
||||
|
||||
sc->sc_inuse = 0;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user